Skip to content

Latest commit

ย 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI Code Review Agent

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.

Python FastAPI Next.js LangGraph Ollama


๐Ÿ“Œ Overview

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.


๐ŸŽฏ Problem

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.


โœจ Features

  • ๐Ÿค– 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

๐Ÿ—๏ธ Architecture

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.


๐Ÿง  How It Works

  1. A Pull Request is identified through GitHub integration.
  2. The backend receives the Pull Request information.
  3. Changed code is passed into the AI review workflow.
  4. Specialized agents analyze different review dimensions.
  5. Results are aggregated into a structured review.
  6. The final review is exposed through the backend and application interface.

๐Ÿ› ๏ธ Tech Stack

Frontend

  • Next.js
  • React
  • TypeScript
  • Tailwind CSS

Backend

  • Python
  • FastAPI
  • SQLAlchemy
  • Pydantic

AI / LLM

  • LangGraph
  • Ollama
  • Llama-family models

Database

  • SQLite

Integration

  • GitHub REST API

๐Ÿ“‚ Project Structure

AI-Code-Review-Agent/
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ database/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ main.py
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ””โ”€โ”€ lib/
โ”‚
โ””โ”€โ”€ README.md

โš™๏ธ Getting Started

Prerequisites

Make sure the following are installed:

  • Python 3.11+
  • Node.js
  • Ollama
  • Git

1. Clone the Repository

git clone https://github.com/abdullahk970/AI-Code-Review-Agent.git

cd AI-Code-Review-Agent

2. Backend Setup

cd backend

python -m venv venv

Windows

venv\Scripts\activate

Linux / macOS

source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

3. Environment Variables

Create 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=llama3

Security

Do not commit real tokens or credentials to GitHub.

Use environment variables for sensitive configuration.


4. Start the Backend

From the backend directory:

uvicorn main:app --reload

The FastAPI development server should then be available locally.


5. Ollama Setup

Start Ollama:

ollama serve

Pull the model configured for the project:

ollama pull llama3

The exact model can be changed through the application's configuration.


6. Frontend Setup

Open a new terminal:

cd frontend

npm install

npm run dev

Then open the local development URL shown by Next.js.


๐Ÿ“ก API

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.


๐Ÿ“Š Review Output

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.


๐Ÿงช Evaluation

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.


๐Ÿ” Security Considerations

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.

โš ๏ธ Limitations

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.

๐Ÿ”ฎ Future Improvements

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

๐Ÿค Contributing

Contributions are welcome.

  1. Fork the repository.
  2. Create a feature branch.
  3. Make your changes.
  4. Test the changes.
  5. Commit and push your branch.
  6. Open a Pull Request.

๐Ÿ‘จโ€๐Ÿ’ป Author

Muhammad Abdullah Khan


๐Ÿ“„ License

This project is licensed under the MIT License.

About

Multi-agent AI system for automated GitHub pull request analysis and code review using LangGraph, FastAPI, Ollama, and specialized review agents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages