Skip to content

About

AI-powered GitHub code review bot using FastAPI and Claude

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Code Review Bot

An AI-powered GitHub code review bot that automatically analyzes pull requests and provides intelligent feedback using Claude AI.

Dashboard Preview Python React License

✨ Features

  • πŸ”— GitHub Integration - Installs as a GitHub App, automatically reviews PRs when opened or updated
  • 🧠 AI-Powered Analysis - Uses Claude AI to provide intelligent, context-aware code reviews
  • πŸ’¬ Automatic Comments - Posts review feedback directly on your pull requests
  • ⚑ Background Processing - Celery workers handle analysis asynchronously for fast response times
  • πŸ“Š Dashboard - View analysis history with a clean React frontend
  • πŸŒ™ Dark Mode - Beautiful UI with smooth animations and theme switching
  • πŸ”’ Secure - Webhook signature verification and secure token handling

πŸ—οΈ Tech Stack

Backend

Technology Purpose
FastAPI High-performance async Python web framework
Celery Distributed background task processing
Redis Task queue broker and caching
PostgreSQL Persistent database storage
Anthropic Claude AI-powered code analysis

Frontend

Technology Purpose
React 18 Modern UI framework
TypeScript Type-safe development
CSS3 Custom styling with animations

Infrastructure

Technology Purpose
Docker Container orchestration
ngrok Webhook tunneling for development

πŸ“ Project Structure

code-review-bot/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/routes/       # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ webhooks.py   # GitHub webhook handler
β”‚   β”‚   β”‚   └── analysis.py   # Analysis history API
β”‚   β”‚   β”œβ”€β”€ core/             # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ analyzer.py   # AI code analysis engine
β”‚   β”‚   β”‚   β”œβ”€β”€ filters.py    # Smart file filtering
β”‚   β”‚   β”‚   └── github.py     # GitHub API client
β”‚   β”‚   β”œβ”€β”€ db/               # Database layer
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py   # Async connection setup
β”‚   β”‚   β”‚   └── models.py     # SQLAlchemy models
β”‚   β”‚   β”œβ”€β”€ tasks/            # Background tasks
β”‚   β”‚   β”‚   β”œβ”€β”€ celery_app.py # Celery configuration
β”‚   β”‚   β”‚   └── analysis_tasks.py
β”‚   β”‚   β”œβ”€β”€ config.py         # Environment settings
β”‚   β”‚   └── main.py           # FastAPI application
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.tsx           # Main dashboard component
β”‚   β”‚   └── index.css         # Styles with dark mode support
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml        # PostgreSQL + Redis services
β”œβ”€β”€ .env.example
└── README.md

πŸš€ Getting Started

Prerequisites

  • Python 3.11+
  • Node.js 20+
  • Docker Desktop
  • GitHub account
  • Anthropic API key

1. Clone & Setup

git clone https://github.com/ke1ee/code-review-bot.git
cd code-review-bot

2. Backend Setup

# Create virtual environment
python -m venv venv

# Activate (Windows)
.\venv\Scripts\Activate

# Activate (Mac/Linux)
source venv/bin/activate

# Install dependencies
pip install -r backend/requirements.txt

3. Configure Environment

Create backend/.env:

DEBUG=true
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/code_review_bot
REDIS_URL=redis://localhost:6379/0
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0

# GitHub App
GITHUB_APP_ID=your-app-id
GITHUB_WEBHOOK_SECRET=your-webhook-secret
GITHUB_APP_PRIVATE_KEY_PATH=./github-app-private-key.pem

# AI Analysis
ANTHROPIC_API_KEY=sk-ant-xxxxx
AI_PROVIDER=anthropic

4. Start Services

# Start PostgreSQL and Redis
docker-compose up -d

# Terminal 1: Start API server
cd backend
uvicorn app.main:app --reload

# Terminal 2: Start Celery worker
cd backend
celery -A app.tasks.celery_app worker --loglevel=info --pool=solo

5. Frontend Setup

cd frontend
npm install
npm start

Open http://localhost:3000 to view the dashboard.

6. GitHub App Setup

  1. Go to https://github.com/settings/apps/new
  2. Configure:
    • App name: your-code-review-bot
    • Homepage URL: http://localhost:8000
    • Webhook URL: Your ngrok URL + /api/webhooks/github
    • Webhook secret: Same as in your .env
  3. Set permissions:
    • Contents: Read
    • Pull requests: Read & Write
    • Metadata: Read
  4. Subscribe to events:
    • β˜‘οΈ Pull request
  5. Generate and download a private key
  6. Install the app on your repositories

7. Webhook Tunneling (Development)

ngrok http 8000

Update your GitHub App's webhook URL with the ngrok URL.

πŸ“– API Endpoints

Method Endpoint Description
GET / API status
GET /health Health check with provider info
POST /api/webhooks/github GitHub webhook receiver
GET /api/analysis/history/{owner}/{repo} Get analysis history for a repo
GET /api/analysis/detail/{id} Get detailed analysis results

πŸ” How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   GitHub PR     β”‚
β”‚    Opened       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Webhook      β”‚
β”‚   Received      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Celery Task    β”‚
β”‚    Queued       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Fetch Files    β”‚
β”‚  from GitHub    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Claude AI      β”‚
β”‚  Analysis       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Post Comments   β”‚
β”‚    on PR        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Save to Databaseβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ€– AI Analysis Capabilities

The bot uses Claude AI to analyze code for:

  • Code Quality - Identifies bugs, logic errors, and potential issues
  • Best Practices - Suggests improvements based on language conventions
  • Security - Flags potential security vulnerabilities
  • Performance - Highlights inefficient code patterns
  • Readability - Recommends clearer naming and structure
  • Documentation - Suggests missing or improved comments

🎨 Dashboard Features

  • Analysis History - Browse all past code reviews with status indicators
  • Detailed Results - View every issue found with file paths and line numbers
  • Dark Mode - Toggle between light and dark themes with smooth transitions
  • Responsive Design - Works seamlessly on desktop and mobile
  • Real-time Updates - See analysis results as they complete

πŸ”§ Configuration

File Filtering

The bot automatically skips:

  • Binary files (images, compiled code)
  • Lock files (package-lock.json, yarn.lock)
  • Generated files (pycache, node_modules)
  • Configuration files (.gitignore, .env.example)

Supported Languages

  • Python
  • JavaScript / TypeScript
  • Java
  • Go
  • Rust
  • Ruby
  • And more...

πŸ“ License

MIT Β© ke1ee

About

AI-powered GitHub code review bot using FastAPI and Claude

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages