An automated code review system that analyzes pull requests using FastAPI, Django, and LLM (Groq). The system provides detailed feedback on code style, potential bugs, performance improvements, and best practices.
-
LLM Integration: The project utilizes advanced machine learning models to automatically analyze code for style issues, potential bugs, performance optimizations, and adherence to best practices. This makes it ideal for developers looking to streamline their workflows.
-
FastAPI: Acts as the API gateway, offering high-performance endpoints for initiating reviews, tracking progress, and retrieving results. Its lightweight and asynchronous nature ensures that the system can handle numerous requests efficiently.
-
Django: Serves as the backbone for managing tasks and storing data. Its robustness ensures reliable handling of complex workflows, such as fetching PR data from GitHub and orchestrating analysis tasks.
-
Asynchronous Processing: Leveraging Celery and Redis, the system processes PR reviews in the background, ensuring non-blocking operations and faster response times for users.
GitHub-PR-Reviewer gives developers the flexibility to automate tedious parts of the review process, allowing them to focus on critical tasks, reduce errors, and scale their development operations effectively.
- Automated PR analysis using LLM
- Real-time status tracking of review progress
- Detailed code feedback including style, bugs, and performance issues
- Asynchronous processing for better performance
- REST API endpoints for integration
- FastAPI: API Gateway
- Django: Backend Service
- Celery: Asynchronous Task Processing
- Redis: Task Queue Broker and Caching Layer
- Groq LLM: Code Analysis
- GitHub API: Repository Integration
- Python 3.8+
- Redis (for Celery)
- Groq API Key
- GitHub Personal Access Token (optional)
- Clone the repository:
git clone https://github.com/yourusername/github-pr-reviewer.git
cd github-pr-reviewer- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
cp .env.example .env
# Edit .env file with your configurations:
# GROQ_API_KEY=your_groq_api_key
# GITHUB_TOKEN=your_github_token (optional)
# DJANGO_SECRET_KEY=your_django_secret_key-
Django Settings:
- Update
django_app/settings.pywith your database configurations - Configure Celery broker URL (Redis)
- Update
-
FastAPI Settings:
- Update
DJANGO_API_URLinapp_fastapi/main.pyif needed
- Update
- Start Redis server:
redis-server- Start Celery worker:
celery -A django_app worker -l info- Start Django server:
python manage.py migrate
python manage.py runserver 8001- Start FastAPI server:
uvicorn app_fastapi.main:app --reload --port 8000The system follows this workflow:
- Client sends POST request to FastAPI Server
- FastAPI forwards request to Django REST Framework
- Django creates a task and stores in Redis
- Celery Worker processes the task:
- Fetches PR data from GitHub API
- Sends code for analysis to Groq LLM
- Updates task status in Redis
- Client can check task status through FastAPI
Send a POST request to initiate the code review, returns Task ID and Status:
Endpoint: POST http://127.0.0.1:8001/start_task/
Request Body:
{
"repo_url": "https://github.com/raghavsar/MyCurrency",
"pr_number": "3",
"github_token": null
}Get the status and results of the review:
Endpoint: GET http://127.0.0.1:8001/task_status/f18c229b-8300-4a9f-809c-0b2d5132d3b0/
Response Example:
{
"task_id": "f18c229b-8300-4a9f-809c-0b2d5132d3b0",
"status": "SUCCESS",
"result": {
"task_id": "bf71a58c-d0a5-4aab-bad5-79abee861091",
"status": "completed",
"results": {
"files": [
{
"name": "fx_rates/admin.py",
"issues": [
{
"type": "style",
"line": 3,
"description": "Expected import order: standard libraries first, then third-party libraries, and finally internal modules",
"suggestion": "Reorder imports according to PEP 8 guidelines"
}
]
}
],
"summary": {
"total_files": 1,
"total_issues": 3
}
}
}
}The system provides detailed feedback on:
- Code style violations
- Import order issues
- Line length problems
- Potential bugs
- Performance improvements
- Best practices recommendations
Each issue includes:
- Type of issue (style, bug, performance, etc.)
- Line number
- Description of the problem
- Suggested fix
├── app_fastapi/
│ ├── __init__.py
│ └── main.py
├── django_app/
│ ├── django_app/
│ │ ├── __init__.py
│ │ ├── celery.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ └── home/
│ ├── utils/
│ │ ├── ai_agent.py
│ │ └── github.py
│ ├── tasks.py
│ └── views.py
└── requirements.txt
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Groq for providing the LLM API
- FastAPI for the high-performance API framework
- Django for the robust backend framework


