An AI-powered GitHub Pull Request review system designed to analyze code changes across bugs, security, performance, and code quality using FastAPI, LangGraph, Ollama, and Next.js.
AI Code Review Agent is a developer-focused AI application that analyzes GitHub Pull Requests and generates structured review feedback.
The system is designed around multiple review areas:
- ๐ Bug and logic analysis
- ๐ Security-focused analysis
- โก Performance considerations
- โจ Code quality and style
- ๐ Overall review risk assessment
The goal is to help developers identify potential issues earlier in the Pull Request workflow.
Code review is an important part of software development, but reviewing Pull Requests manually can take significant time.
This project explores how an AI-based workflow can assist developers by automatically analyzing changed code and producing structured review feedback.
The system is intended as an AI-assisted review tool, not a replacement for human code reviewers.
- ๐ค AI-assisted Pull Request analysis
- ๐ Multi-agent review workflow
- ๐ Bug and logic analysis
- ๐ Security-focused review
- โก Performance suggestions
- โจ Code quality feedback
- ๐ Review risk scoring
- ๐ Review analytics
- ๐ GitHub integration
- ๐ Web-based dashboard
- โก FastAPI backend
- ๐ง Local LLM inference with Ollama
The high-level workflow is:
GitHub Pull Request
โ
โผ
GitHub API / Webhook
โ
โผ
FastAPI Backend
โ
โผ
LangGraph Workflow
โ
โโโโโโโโผโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
Bug Security Performance
Agent Agent Agent
โ โ โ
โโโโโโโโผโโโโโโโโโโโ
โผ
Style / Quality
Agent
โ
โผ
Aggregator Agent
โ
โผ
Structured Review
โ
โโโโโโโโดโโโโโโโโโโโโ
โผ โผ
Dashboard GitHub Output
The architecture separates the application into frontend, backend, AI agents, database, and service layers.
- A Pull Request is identified through GitHub integration.
- The backend receives the Pull Request information.
- Changed code is passed into the AI review workflow.
- Specialized agents analyze different review dimensions.
- Results are aggregated into a structured review.
- The final review is exposed through the backend and application interface.
- Next.js
- React
- TypeScript
- Tailwind CSS
- Python
- FastAPI
- SQLAlchemy
- Pydantic
- LangGraph
- Ollama
- Llama-family models
- SQLite
- GitHub REST API
AI-Code-Review-Agent/
โ
โโโ backend/
โ โโโ agents/
โ โโโ api/
โ โโโ database/
โ โโโ models/
โ โโโ services/
โ โโโ utils/
โ โโโ main.py
โ
โโโ frontend/
โ โโโ app/
โ โโโ components/
โ โโโ hooks/
โ โโโ lib/
โ
โโโ README.md
Make sure the following are installed:
- Python 3.11+
- Node.js
- Ollama
- Git
git clone https://github.com/abdullahk970/AI-Code-Review-Agent.git
cd AI-Code-Review-Agentcd backend
python -m venv venvvenv\Scripts\activatesource venv/bin/activateInstall dependencies:
pip install -r requirements.txtCreate a .env file inside the backend directory.
Example:
GITHUB_TOKEN=your_github_token
DATABASE_URL=sqlite:///database.db
OLLAMA_BASE_URL=http://localhost:11434
MODEL=llama3Do not commit real tokens or credentials to GitHub.
Use environment variables for sensitive configuration.
From the backend directory:
uvicorn main:app --reloadThe FastAPI development server should then be available locally.
Start Ollama:
ollama servePull the model configured for the project:
ollama pull llama3The exact model can be changed through the application's configuration.
Open a new terminal:
cd frontend
npm install
npm run devThen open the local development URL shown by Next.js.
The project exposes backend endpoints for review and review-history functionality.
| Method | Endpoint | Purpose |
|---|---|---|
| GET | / |
Backend health check |
| POST | /review |
Submit a Pull Request for review |
| GET | /reviews |
Retrieve review history |
| GET | /stats |
Retrieve review statistics |
Endpoint availability may depend on the current repository implementation and configuration.
A review is represented as structured information such as:
{
"risk_score": 28,
"decision": "MINOR_FIXES",
"bugs": 2,
"security": 1,
"performance": 0,
"style": 4
}The exact output depends on the code under review and the configured model/workflow.
AI-generated code review should be evaluated carefully because LLM outputs can contain false positives or miss real issues.
Future evaluation for this project should measure areas such as:
- Bug-detection precision
- Security finding precision
- False-positive rate
- Review consistency
- Review latency
- Model/resource usage
No benchmark results are claimed here until they are measured on a defined evaluation dataset.
The application interacts with GitHub and may process repository code.
Important considerations include:
- Keep GitHub tokens outside source code.
- Use environment variables for secrets.
- Validate GitHub webhook requests when webhooks are enabled.
- Avoid exposing sensitive repository information in logs.
- Restrict production CORS origins.
- Apply authentication and authorization before production deployment.
This project currently has several limitations that should be considered:
- AI-generated findings may contain false positives.
- AI models may miss subtle bugs or security vulnerabilities.
- Review quality depends on the selected LLM.
- Local inference requires suitable hardware and model resources.
- The current project is primarily intended as an AI engineering and development project rather than a certified production security/code-analysis system.
Planned improvements include:
- Automated evaluation benchmarks
- Improved retrieval/context handling
- Additional review agents
- More structured review outputs
- GitHub Actions integration
- Docker-based deployment
- Additional LLM providers
- Improved authentication and security
- Review history and analytics improvements
Contributions are welcome.
- Fork the repository.
- Create a feature branch.
- Make your changes.
- Test the changes.
- Commit and push your branch.
- Open a Pull Request.
Muhammad Abdullah Khan
- GitHub: abdullahk970
- LinkedIn: Muhammad Abdullah Khan
This project is licensed under the MIT License.