π‘ Summary
English summary.
π― Target Audience
π€ AI Roast: βPowerful, but the setup might scare off the impatient.β
Risk: Medium. Review: shell/CLI command execution; outbound network access (SSRF, data egress); API keys/tokens handling and storage; dependency pinning and supply-chain risk. Run with least privilege and audit before enabling in production.
ReviewBot - AI-Powered GitLab Code Review System
Automated code review bot for GitLab using Azure OpenAI Haiku 4.5. Provides intelligent code analysis, security checks, performance suggestions, and inline comments directly on merge requests.
πΈ Screenshots
Dashboard
Real-time metrics showing code quality scores, issue breakdown, and review history
GitLab Integration
AI-powered inline comments directly on merge request code changes
Comprehensive merge request summary with quality score and categorized issues
Developer Analytics
Track individual developer performance and improvement trends over time
Note: Add your screenshots to the
/imagesfolder to display them here.
π Features
Code Review Intelligence
- AI-Powered Analysis: Utilizes Azure OpenAI Haiku 4.5 for fast, accurate code reviews
- Multi-Language Support: Analyzes TypeScript, JavaScript, Python, Java, Go, Rust, PHP, and more
- Smart Batching: Combines multiple file changes into single LLM call for efficiency (β€500 lines)
- False Positive Filtering: Verifies LLM findings against actual file content to reduce noise
Review Capabilities
- Inline Comments: Posts comments directly on specific code lines for critical/high/medium issues
- Comprehensive Summary: Detailed MR-level summary with quality scores and issue breakdown
- Issue Categorization:
- Severity: Critical, High, Medium, Low
- Type: Security, Performance, Logic, Style
- Context-Aware: Includes Β±10 lines of context and imports for accurate analysis
Developer Metrics
- Quality Scoring: 0-100 score based on issue severity
- Historical Tracking: Review history and trends per developer
- Project Analytics: Aggregate metrics across projects
Integration
- GitLab Webhooks: Automatic review on MR open/update
- Queue Processing: Async job processing with Bull + Redis
- API Access: RESTful API for frontend consumption
ποΈ Architecture
reviewbot/
βββ reviewbot-backend/ # NestJS API + Queue Processor
β βββ src/
β β βββ webhook/ # GitLab webhook receiver
β β βββ llm/ # Azure OpenAI integration
β β βββ queue/ # Bull queue processing
β β βββ gitlab/ # GitLab API client
β β βββ prisma/ # Database models
β βββ prisma/ # Database schema
β βββ docker-compose.yml # Infrastructure stack
β
βββ reviewbot-frontend/ # React + Vite Dashboard
βββ src/
βββ pages/ # Dashboard, Projects, Developers, Reviews
βββ components/ # Reusable UI components
βββ api/ # API client
Tech Stack
Backend:
- NestJS (Node.js framework)
- Prisma ORM
- PostgreSQL (database)
- Redis + Bull (queue processing)
- Azure OpenAI API (Haiku 4.5)
- GitLab REST API (@gitbeaker/rest)
Frontend:
- React 19
- Vite (build tool)
- TanStack Query (data fetching)
- Tailwind CSS + shadcn/ui
- Recharts (visualization)
π Prerequisites
- Node.js: v18+ (backend and frontend)
- Docker & Docker Compose: For PostgreSQL and Redis
- Azure OpenAI: API key and Haiku 4.5 deployment
- GitLab: Personal access token with API scope
- Git: For version control
π Quick Start
1. Clone Repository
git clone <your-repo-url> cd reviewbot
2. Backend Setup
cd reviewbot-backend # Install dependencies npm install # Copy environment template cp .env.example .env # Edit .env with your credentials nano .env
Required Environment Variables:
# Database DATABASE_URL=postgresql://reviewbot:your_password@localhost:5432/reviewbot DB_PASSWORD=your_password # Redis REDIS_HOST=localhost REDIS_PORT=6379 # Azure OpenAI AZURE_OPENAI_KEY=your_api_key AZURE_OPENAI_ENDPOINT=https://your-resource.cognitiveservices.azure.com/ AZURE_OPENAI_DEPLOYMENT=haiku-4-5 AZURE_OPENAI_MODEL_NAME=haiku-4-5 # GitLab GITLAB_HOST=https://gitlab.com GITLAB_WEBHOOK_SECRET=your_webhook_secret GITLAB_ACCESS_TOKEN=your_gitlab_token # Auth JWT_SECRET=your_jwt_secret ADMIN_USERNAME=admin ADMIN_PASSWORD=change_me
3. Start Infrastructure
# Start PostgreSQL and Redis docker-compose up -d postgres redis # Run database migrations npm run prisma:generate npm run prisma:migrate
4. Start Backend
# Development mode with hot-reload npm run start:dev # Production mode npm run build npm run start:prod
Backend runs on http://localhost:3000
5. Frontend Setup
cd ../reviewbot-frontend # Install dependencies npm install # Create .env.local echo "VITE_API_URL=http://localhost:3000" > .env.local # Start development server npm run dev
Frontend runs on http://localhost:5173
βοΈ Configuration
GitLab Webhook Setup
- Go to your GitLab project β Settings β Webhooks
- Add webhook:
- URL:
http://your-server:3000/webhook - Secret Token: Use value from
GITLAB_WEBHOOK_SECRET - Trigger: β Merge request events
- SSL verification: Enable if using HTTPS
- URL:
- Click Add webhook
- Test by creating a test MR
Azure OpenAI Setup
- Create Azure OpenAI resource in Azure Portal
- Deploy Haiku 4.5 model (or your preferred model)
- Get API key and endpoint from Keys and Endpoint section
- Update
.envwith credentials
π Usage
Dashboard
Access the frontend at http://localhost:5173 to view:
- Code Quality Metrics: Issues found, review scores, trends
- Project Management: Configure webhooks, view project stats
- Developer Performance: Individual metrics, improvement trends
- Review History: Full review details with inline comments
API Endpoints
Webhook (GitLab calls this):
POST /webhook- Receive MR events
Projects:
GET /projects- List all projectsPOST /projects- Add projectGET /projects/:id/reviews- Project review history
Reviews:
GET /reviews- List all reviewsGET /reviews/:id- Review details
Developers:
GET /developers- List all developersGET /developers/:id/stats- Developer metrics
Review Workflow
- Developer creates/updates MR β GitLab webhook fires
- Backend receives webhook β Creates review job in queue
- Queue processor:
- Fetches MR diffs from GitLab
- Collects file context (imports, surrounding lines)
- Decides batching strategy (β€500 lines = batch)
- Calls Azure OpenAI for review
- Verifies issues to filter false positives
- Posts inline comments (critical/high/medium)
- Posts summary comment with all issues
- Frontend displays:
- Summary comment appears on MR
- Inline comments appear on specific lines
- Dashboard shows updated metrics
π§ Development
Project Structure
reviewbot-backend/src/
βββ main.ts # Application entry point
βββ webhook/
β βββ webhook.controller.ts # Webhook endpoint
β βββ webhook.service.ts # Webhook validation
βββ llm/
β βββ llm.service.ts # Azure OpenAI integration
β βββ diff-processor.ts # Diff parsing
β βββ issue-verifier.service.ts # False positive filter
βββ queue/
β βββ review-processor.ts # Bull queue job handler
βββ gitlab/
β βββ gitlab.service.ts # GitLab API client
βββ prisma/
βββ prisma.service.ts # Database client
Database Schema
model Project { id String @id @default(cuid()) gitlabProjectId Int @unique name String webhookUrl String? reviews Review[] } model Developer { id String @id @default(cuid()) gitlabUserId Int @unique username String email String? reviews Review[] } model Review { id String @id @default(cuid()) mergeRequestIid Int projectId String developerId String reviewContent Json qualityScore Int issuesFound Int status ReviewStatus createdAt DateTime @default(now()) project Project @relation(...) developer Developer @relation(...) }
Running Tests
# Backend tests cd reviewbot-backend npm test # Frontend tests cd reviewbot-frontend npm run test
Building for Production
# Backend cd reviewbot-backend npm run build # Frontend cd reviewbot-frontend npm run build
π³ Docker Deployment
Option 1: Docker Compose (Full Stack)
cd reviewbot-backend # Build and start all services docker-compose up -d # View logs docker-compose logs -f # Stop services docker-compose down
Services:
- PostgreSQL:
localhost:5432 - Redis:
localhost:6379 - Backend:
localhost:3000 - Frontend:
localhost:5173
Option 2: Separate Services
# Start only infrastructure docker-compose up -d postgres redis # Run backend locally npm run start:dev # Run frontend locally cd ../reviewbot-frontend npm run dev
π Monitoring & Debugging
Logs
# Backend logs (development) npm run start:dev # Docker logs docker-compose logs -f backend # Redis queue monitoring npm run pri
Pros
- p1
- p2
Cons
- c1
- c2
Related Skills
claude-domain-skills
BβPowerful, but the setup might scare off the impatient.β
my-skills
BβPowerful, but the setup might scare off the impatient.β
terraform-ibm-modules-skills
BβPowerful, but the setup might scare off the impatient.β
Disclaimer: This content is sourced from GitHub open source projects for display and rating purposes only.
Copyright belongs to the original author binhmuc.
