This repository contains the open-source core of Kaavhi, an AI-powered code review assistant. Our mission is to help developers write better, safer, and cleaner code without sacrificing control or data privacy.
As part of our commitment to transparency and trust, our core review logic is open source. You can inspect the code to verify that we never store your code and handle your data securely.
The backend provides a single API endpoint that accepts a code diff and returns a structured JSON object containing AI-generated review comments.
- Receive Diff: The API receives a code diff as a string.
- AI Analysis: The diff is sent to Google's Gemini 2.5 Pro model with a detailed prompt instructing it to act as an expert code reviewer.
- Return JSON: The model's response is parsed and returned as a structured JSON array of review comments.
- Python 3.9+
- A Gemini API Key
-
Clone the repository:
git clone git@github.com:SanthoshSiddegowda/kaavhi-core.git cd kaavhi-core -
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate pip install -r requirements.txt -
Set up your environment variables: Create a
.envfile in the project root and add your Gemini API key:GEMINI_API_KEY="your-gemini-api-key"
Use uvicorn to run the FastAPI server locally:
uvicorn app.main:app --reloadThe server will be available at http://localhost:8000.
-
Method:
POST -
Body:
{ "diff": "--- a/file.js\n+++ b/file.js\n@@ -1,3 +1,3 @@\n- const oldVar = 1;\n+ const newVar = 2;" } -
Success Response (200 OK):
A JSON object containing an array of review comments.
{ "comments": [ { "id": "1", "type": "suggestion", "severity": "low", "line": 3, "code": "+ const newVar = 2;", "comment": "Variable name changed, ensure this is updated across all usages.", "suggestion": "N/A", "confidence": 90, "filePath": "b/file.js" } ] }
We welcome contributions! Please see our CONTRIBUTING.md for details on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.
app/- Main application codemain.py- FastAPI app and routes__init__.py- Makes app a package
requirements.txt- Python dependencies
GET /- Health check endpoint, returns{ "status": "ok" }