Skip to content

niharikabanothu/-AI-Agent-for-Code-Review-i

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Agent for Code Review & Task Automation

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.

Tech Stack

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

Features

  • 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

Project Structure

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

Getting Started

Prerequisites

  • Docker & Docker Compose
  • OpenAI API key (or Gemini — swap in app/agents/reviewer.py)

Run with Docker

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

Local Development

Backend:

cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Frontend:

cd frontend
npm install
npm run dev

API Endpoints

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

Agent Tools

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

Running Tests

# Backend
cd backend && pytest

# Frontend
cd frontend && npm run test

About

AI agent for automated code review using LangChain, GPT-4o, FastAPI, Next.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors