An intelligent code review bot that combines static analysis tools with Large Language Models (LLMs) to provide automated, contextual code reviews for GitHub pull requests.
- Automated Code Review: Analyzes pull requests and provides actionable feedback
- Static Analysis Integration: Uses Pylint, Bandit, and other tools for code quality and security scanning
- AI-Powered Insights: Leverages OpenAI GPT models for contextual code review
- GitHub Integration: Seamlessly integrates with GitHub via webhooks
- Multi-Language Support: Currently supports Python (extensible to other languages)
See ARCHITECTURE.md for detailed system architecture and design decisions.
- Python 3.11+
- PostgreSQL 15+
- Redis 7+
- GitHub App (for GitHub integration)
- OpenAI API key (for LLM functionality)
git clone <repository-url>
cd "Code Review and Documentation Bot"Copy the example environment file and fill in your values:
cp .env.example .envEdit .env and configure:
GITHUB_APP_ID: Your GitHub App IDGITHUB_APP_PRIVATE_KEY_PATH: Path to your GitHub App private keyGITHUB_WEBHOOK_SECRET: Webhook secret from GitHub App settingsOPENAI_API_KEY: Your OpenAI API keyDATABASE_URL: PostgreSQL connection stringREDIS_URL: Redis connection string
- Go to GitHub Settings → Developer settings → GitHub Apps
- Create a new GitHub App with the following permissions:
- Repository permissions:
- Pull requests: Read & Write
- Contents: Read
- Metadata: Read
- Repository permissions:
- Set up webhook URL:
https://your-domain.com/webhook/pr - Download the private key and save it as
github_app_private_key.pem - Note your App ID and webhook secret
pip install -r requirements.txtUsing Docker Compose (recommended):
docker-compose up -d postgres redisOr manually:
- Start PostgreSQL and Redis services
- Create database:
CREATE DATABASE code_review_bot;
alembic upgrade headDevelopment mode:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Using Docker Compose:
docker-compose upThe API will be available at http://localhost:8000
GET /health
POST /webhook/pr
Configure this URL in your GitHub App webhook settings.
GET /api/v1/reviews/{review_id}
GET /api/v1/reviews/{review_id}/comments
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
In your GitHub App settings, set the webhook URL to:
https://your-domain.com/webhook/pr
Install your GitHub App on the repositories where you want code reviews.
When you create or update a pull request, the bot will:
- Receive the webhook event
- Fetch the PR diff
- Run static analysis on changed files
- Generate AI-powered review comments
- Post comments to the PR
The bot will post inline comments on the PR with:
- Code quality issues
- Security vulnerabilities
- Best practice suggestions
- Actionable feedback
.
├── app/
│ ├── api/ # API routes
│ ├── core/ # Core components (database, etc.)
│ ├── models/ # Database models
│ ├── services/ # Business logic services
│ └── main.py # FastAPI application
├── alembic/ # Database migrations
├── config.py # Configuration management
├── requirements.txt # Python dependencies
└── docker-compose.yml # Docker setup
pytestblack .
ruff check .Create a new migration:
alembic revision --autogenerate -m "Description"Apply migrations:
alembic upgrade head| Variable | Description | Default |
|---|---|---|
GITHUB_APP_ID |
GitHub App ID | Required |
GITHUB_APP_PRIVATE_KEY_PATH |
Path to private key | ./github_app_private_key.pem |
GITHUB_WEBHOOK_SECRET |
Webhook secret | Required |
DATABASE_URL |
PostgreSQL connection string | Required |
REDIS_URL |
Redis connection string | redis://localhost:6379/0 |
OPENAI_API_KEY |
OpenAI API key | Required |
OPENAI_MODEL |
OpenAI model to use | gpt-4-turbo-preview |
LOG_LEVEL |
Logging level | INFO |
The bot currently supports:
- Pylint: Python code quality
- Bandit: Python security scanning
Additional tools can be added by extending StaticAnalyzer service.
- Currently processes reviews synchronously (async queue coming in Phase 2)
- Limited to Python files (other languages coming in Phase 4)
- No RAG integration yet (coming in Phase 3)
- Single-agent workflow (multi-agent LangGraph coming in Phase 2)
See ARCHITECTURE.md for the detailed implementation roadmap:
- Phase 1 (MVP): ✅ Current - Basic review with single agent
- Phase 2: Multi-agent LangGraph workflow
- Phase 3: RAG integration for context-aware reviews
- Phase 4: Multi-language support and documentation generation
- Phase 5: Production hardening and scaling
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
[Add your license here]
For issues and questions, please open an issue on GitHub.
- Built with FastAPI, LangGraph (planned), OpenAI, and PostgreSQL
- Uses Pylint, Bandit, and other open-source static analysis tools