An LLM-powered agentic system that reviews GitHub PRs, runs lint checks, and provides structured code feedback — with a real-time streaming Next.js chat UI and a FastAPI backend.
| Layer | Technology |
|---|---|
| Frontend | Next.js 14, React, TypeScript, Tailwind CSS |
| Backend | FastAPI, SQLAlchemy ORM, Pydantic v2 |
| AI Agent | LangChain, OpenAI GPT-4o, Tool Use |
| Database | PostgreSQL (session + review history) |
| DevOps | Docker Compose, GitHub Actions CI/CD |
| Testing | pytest, Vitest |
- LangChain agent with custom tools: GitHub PR diff fetcher, Python linter, file summarizer
- Streaming FastAPI endpoint (Server-Sent Events) for real-time agent thought display
- Next.js chat interface showing agent reasoning steps + final review report
- Structured JSON review output: issues list, severity, suggestions
- Review session history persisted in PostgreSQL
- Dockerized full-stack setup
project2-ai-code-reviewer/
├── backend/
│ ├── app/
│ │ ├── api/ # FastAPI routes (reviews, sessions)
│ │ ├── agents/ # LangChain agent setup
│ │ ├── tools/ # Custom agent tools
│ │ ├── models/ # SQLAlchemy ORM models
│ │ ├── schemas/ # Pydantic schemas
│ │ └── core/ # Config, DB session
│ ├── tests/
│ ├── Dockerfile
│ └── requirements.txt
├── frontend/
│ ├── src/
│ │ ├── app/ # Next.js App Router
│ │ ├── components/ # Chat UI components
│ │ ├── lib/ # API client, streaming utils
│ │ └── types/ # TypeScript types
│ ├── Dockerfile
│ └── package.json
├── docker-compose.yml
└── .github/workflows/ci.yml
- Docker & Docker Compose
- OpenAI API key (or Gemini — swap in
app/agents/reviewer.py)
git clone https://github.com/YOUR_USERNAME/ai-code-reviewer
cd ai-code-reviewer
cp .env.example .env
# Add your OPENAI_API_KEY to .env
docker-compose up --build- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
Backend:
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reloadFrontend:
cd frontend
npm install
npm run dev| Method | Endpoint | Description |
|---|---|---|
| POST | /api/reviews/ |
Start a new code review (streaming SSE) |
| GET | /api/reviews/ |
List all past reviews |
| GET | /api/reviews/{id} |
Get a specific review + result |
| POST | /api/sessions/ |
Create a chat session |
| GET | /api/sessions/{id}/messages |
Get session messages |
| Tool | Description |
|---|---|
fetch_github_diff |
Fetches PR diff from GitHub API |
run_python_linter |
Runs pyflakes on provided code |
summarize_file |
Summarizes a code file's purpose |
search_best_practices |
Returns language-specific best practices |
# Backend
cd backend && pytest
# Frontend
cd frontend && npm run test