An AI-powered GitHub code review bot that automatically analyzes pull requests and provides intelligent feedback using Claude AI.
- π 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
| 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 |
| Technology | Purpose |
|---|---|
| React 18 | Modern UI framework |
| TypeScript | Type-safe development |
| CSS3 | Custom styling with animations |
| Technology | Purpose |
|---|---|
| Docker | Container orchestration |
| ngrok | Webhook tunneling for development |
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
- Python 3.11+
- Node.js 20+
- Docker Desktop
- GitHub account
- Anthropic API key
git clone https://github.com/ke1ee/code-review-bot.git
cd code-review-bot# 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.txtCreate 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# 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=solocd frontend
npm install
npm startOpen http://localhost:3000 to view the dashboard.
- Go to https://github.com/settings/apps/new
- 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
- App name:
- Set permissions:
- Contents: Read
- Pull requests: Read & Write
- Metadata: Read
- Subscribe to events:
- βοΈ Pull request
- Generate and download a private key
- Install the app on your repositories
ngrok http 8000Update your GitHub App's webhook URL with the ngrok URL.
| 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 |
βββββββββββββββββββ
β GitHub PR β
β Opened β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Webhook β
β Received β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Celery Task β
β Queued β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Fetch Files β
β from GitHub β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Claude AI β
β Analysis β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Post Comments β
β on PR β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Save to Databaseβ
βββββββββββββββββββ
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
- 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
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)
- Python
- JavaScript / TypeScript
- Java
- Go
- Rust
- Ruby
- And more...
MIT Β© ke1ee