Automated GitHub PR code review agent powered by LangGraph and Dough.id (Llama 3.3)
Project description
🤖 AI Code Review Agent
Automated GitHub PR analysis using 3 parallel AI agents.
Architecture • Features • Quick Start • API • Demo
⚡ Overview
The AI Code Review Agent is a full-stack application that acts as an automated, multi-disciplinary code reviewer. By pasting a GitHub Pull Request URL, the system fetches the code changes and processes them through three specialized AI agents in parallel.
Each agent has a specific focus:
- 🔒 Security Agent: Hardcoded secrets, SQL injection, XSS, insecure dependencies.
- 🚀 Performance Agent: N+1 queries, memory leaks, blocking I/O, O(n²) loops.
- ✨ Code Quality Agent: Code smells, SOLID violations, naming conventions, missing error handling.
The agents parse the PR diff, generate a structured JSON report, and synthesize a comprehensive markdown review that can be automatically posted directly to the GitHub PR.
🏗️ Architecture
The backend utilizes FastAPI for high-performance async routing, while LangGraph orchestrates the multi-agent LLM workflow. Requests are routed through the Dough.id API (OpenAI compatible) to process using Meta's llama-3.3-70b-versatile model.
graph TD
%% Styling
classDef frontend fill:#2d3748,stroke:#4a5568,stroke-width:2px,color:#fff
classDef backend fill:#2c5282,stroke:#4299e1,stroke-width:2px,color:#fff
classDef agent fill:#702459,stroke:#d53f8c,stroke-width:2px,color:#fff
classDef external fill:#276749,stroke:#48bb78,stroke-width:2px,color:#fff
%% Nodes
UI[🖥️ React SPA Frontend]:::frontend
API[⚡ FastAPI Backend]:::backend
GH_API[🐙 GitHub API]:::external
DOUGH[🧠 Dough.id / Groq LLM]:::external
subgraph LangGraph Orchestration
SEC[🔒 Security Agent]:::agent
PERF[🚀 Performance Agent]:::agent
QUAL[✨ Code Quality Agent]:::agent
SYNTH[📝 Markdown Synthesizer]:::agent
end
%% Connections
UI -- "POST /review (PR URL)" --> API
API -- "Fetch Diff & Meta" --> GH_API
GH_API -- "Raw Git Diff" --> API
API -- "asyncio.gather()" --> SEC & PERF & QUAL
SEC -. "JSON Review" .-> DOUGH
PERF -. "JSON Review" .-> DOUGH
QUAL -. "JSON Review" .-> DOUGH
SEC & PERF & QUAL --> SYNTH
SYNTH -- "Combined Report" --> API
API -- "Post Comment (Optional)" --> GH_API
API -- "JSON + Markdown" --> UI
✨ Features
- Parallel Execution: All three AI agents run simultaneously using
asyncio.gather()to minimize latency. - Rate-Limit Resilient: Employs
tenacityfor exponential backoff retries and staggers agent starts by 2 seconds to avoid 429 errors. - Robust Parsing: Diff truncation ensures LLM token limits are respected (~8k char limit). Robust JSON extraction ignores markdown code fences.
- Dark Glassmorphism UI: A premium, responsive React dashboard built with Vite.
- Cloudflare Bypass: Configured with custom
User-Agentheaders to securely route through Dough.id's protected API gateway.
🚀 Quick Start
You can run this project in two ways: as a Standalone CLI or as a Full-Stack Web App.
1. Prerequisites
- Python
≥ 3.11 - Dough.id API Key (or Groq/OpenAI compatible key)
- GitHub Personal Access Token (Optional for public repos, required to post comments)
- Node.js
≥ 18(Only required for the Web App)
Option A: Use as a CLI Package
The fastest way to use the code reviewer is directly from your terminal. You do not need to clone this repository.
# 1. Install globally via pip
pip install pr-review-me
# 2. Set your API key (or pass it directly via --dough-api-key)
export DOUGH_API_KEY="sk-your-key-here"
# 3. Run the review against any public PR!
pr-review-me https://github.com/django/django/pull/21523
# (Add --post-comment to automatically post the review back to GitHub)
pr-review-me https://github.com/django/django/pull/21523 --post-comment
Option B: Run the Web Dashboard
If you prefer a visual interface, you can boot up the FastAPI backend and React frontend.
1. Backend Setup
# Enter the directory
cd pr_rev
# Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # macOS / Linux
# Install dependencies
pip install -r requirements.txt
3. Environment Variables
Create a .env file in the root directory:
# API Keys
DOUGH_API_KEY=sk-your-dough-api-key
GITHUB_TOKEN=ghp_your_github_token_here
4. Frontend Setup
cd frontend
npm install
cd ..
5. Running the Application
Open two terminals to run the services concurrently:
Terminal 1 — Backend (FastAPI)
.venv\Scripts\activate
uvicorn main:app --reload --port 8000
Terminal 2 — Frontend (Vite)
cd frontend
npm run dev
Navigate to http://localhost:5173 to access the dashboard.
📖 API Reference
GET /health
Liveness probe to verify the backend is running.
{ "status": "ok", "version": "1.0.0" }
POST /review
Executes the full multi-agent review pipeline.
Request:
{
"pr_url": "https://github.com/owner/repo/pull/123",
"post_comment": true
}
Response:
{
"success": true,
"pr_title": "Add user authentication",
"pr_author": "octocat",
"security": { "agent_name": "Security Agent", "issues": [], "summary": "..." },
"performance": { "agent_name": "Performance Agent", "issues": [], "summary": "..." },
"code_quality": { "agent_name": "Code Quality Agent", "issues": [], "summary": "..." },
"markdown_comment": "# 🤖 AI Code Review Report\n...",
"comment_posted": true,
"comment_url": "https://github.com/owner/repo/pull/123#issuecomment-12345",
"total_issues": 4,
"critical_count": 0,
"duration_seconds": 12.4
}
🛠️ Project Structure
pr_rev/
├── main.py # FastAPI Application & Endpoints
├── agents.py # LangGraph Agents & Dough.id Integration
├── github_utils.py # GitHub REST API interactions
├── requirements.txt # Python dependencies
├── .env # Environment variables
└── frontend/
├── src/
│ ├── App.jsx # Main React Dashboard Component
│ ├── App.css # Glassmorphism Styling
│ └── main.jsx # React Entry Point
├── package.json # Node dependencies
└── vite.config.js # Vite configuration & proxy
🔧 Troubleshooting
| Issue | Resolution |
|---|---|
401 Unauthorized (GitHub) |
Verify GITHUB_TOKEN is set in .env and has repo scope. |
404 Not Found (GitHub) |
Ensure the PR URL is formatted correctly: https://github.com/owner/repo/pull/NNN. |
403 / Blocked (Dough.id) |
Make sure User-Agent is configured in ChatOpenAI headers to bypass Cloudflare. |
| CORS Errors | Ensure the backend is running on port 8000. Vite automatically proxies /review to it. |
| Empty Diff | The PR might only contain merge commits without code changes. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pr_review_me-1.0.0.tar.gz.
File metadata
- Download URL: pr_review_me-1.0.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bde4dd6cbc0e925f833f425ab46b3e58acdc1d41496b2c16902ab5fa0e0ccd89
|
|
| MD5 |
662aa25c43dba8270f33eb7c9cbb53a5
|
|
| BLAKE2b-256 |
ec3570e9308bcd892af6fa641b9b5ba1c9ca161c30bed4328d476b4f6db49e10
|
Provenance
The following attestation bundles were made for pr_review_me-1.0.0.tar.gz:
Publisher:
publish.yml on kh-bikash/pr_agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pr_review_me-1.0.0.tar.gz -
Subject digest:
bde4dd6cbc0e925f833f425ab46b3e58acdc1d41496b2c16902ab5fa0e0ccd89 - Sigstore transparency entry: 1900438341
- Sigstore integration time:
-
Permalink:
kh-bikash/pr_agent@05b303e48c5879dd3c934a20f01ef532ade0c532 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kh-bikash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05b303e48c5879dd3c934a20f01ef532ade0c532 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pr_review_me-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pr_review_me-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3b96393a7daa61ac7154616af9c9ab067bda82e659a0186c92de4da1f601974
|
|
| MD5 |
f037b7554c76a3b10d4d99074b0efe9f
|
|
| BLAKE2b-256 |
81680fc00bd144d19ec38d7b16e6735ca9180ce3c3509163f106ab2bfd77fcc9
|
Provenance
The following attestation bundles were made for pr_review_me-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on kh-bikash/pr_agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pr_review_me-1.0.0-py3-none-any.whl -
Subject digest:
c3b96393a7daa61ac7154616af9c9ab067bda82e659a0186c92de4da1f601974 - Sigstore transparency entry: 1900438424
- Sigstore integration time:
-
Permalink:
kh-bikash/pr_agent@05b303e48c5879dd3c934a20f01ef532ade0c532 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kh-bikash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05b303e48c5879dd3c934a20f01ef532ade0c532 -
Trigger Event:
workflow_dispatch
-
Statement type: