Getting Started with Merge Mind
Get your AI-powered code review bot up and running in less than 10 minutes.
Table of contents
- Prerequisites
- Step 1: Clone the Repository
- Step 2: Configure Environment Variables
- Step 3: Configure Your Projects
- Step 4: Start the Services
- Step 5: Access the Dashboard
- Step 6: Configure GitLab Webhook
- Step 7: Train on Your Codebase (Optional)
- Step 8: Test Your First Review
- Quick Tips
- Need Help?
Prerequisites
Before you begin, ensure you have:
- Self-hosted GitLab instance (version 12.0+)
- OpenAI API key (Get one here)
- Docker & Docker Compose installed
- 4GB+ RAM (8GB+ recommended for large codebases)
- 10GB+ disk space for vector database
Security Note: Never commit API keys or secrets to version control. Always use environment variables or
.envfiles.
Step 1: Clone the Repository
1
2
git clone https://github.com/omidbakhshi/merge-mind.git
cd merge-mind
Step 2: Configure Environment Variables
Create your environment configuration:
1
cp .env.example .env
Edit .env with your credentials:
1
2
3
4
5
6
7
8
9
10
11
12
# GitLab Configuration
GITLAB_URL=https://gitlab.yourcompany.com
GITLAB_TOKEN=glpat-xxxxxxxxxxxxx
GITLAB_WEBHOOK_SECRET=your-secret-token
# OpenAI Configuration
OPENAI_API_KEY=sk-xxxxxxxxxxxxx
OPENAI_MODEL=gpt-4-turbo-preview
# Server Configuration (optional)
SERVER_PORT=8080
SERVER_WORKERS=4
Getting Your GitLab Token
- Go to GitLab → User Settings → Access Tokens
- Create a new token with these scopes:
- ✅
api- Full API access - ✅
read_repository- Read repository content - ✅
write_repository- Post review comments
- ✅
- Copy the token immediately (you won’t see it again)
Store your token securely and rotate it regularly for security best practices.
Step 3: Configure Your Projects
You have two options for configuring projects:
Option A: Auto-Configure (Recommended)
Automatically fetch all your GitLab projects:
1
2
3
4
5
6
7
8
# Start containers
docker compose up -d
# Run auto-configuration
docker compose exec ai-reviewer python scripts/fetch_gitlab_projects.py
# Restart to apply configuration
docker compose up -d --build
This will:
- ✅ Fetch all accessible projects from GitLab
- ✅ Create default configurations
- ✅ Update
config/projects.yamlautomatically
Option B: Manual Configuration
Copy and edit the configuration file:
1
cp config/projects.yaml.example config/projects.yaml
Example configuration for a Laravel project:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
projects:
- project_id: 123
name: "backend-api"
review_enabled: true
auto_review_on_open: true
min_lines_changed: 10
max_files_per_review: 50
excluded_paths:
- vendor/
- node_modules/
- storage/
included_extensions:
- .php
- .blade.php
- .sql
review_model: gpt-4-turbo-preview
Step 4: Start the Services
Launch all services with Docker Compose:
1
docker compose up -d
This starts:
- ai-reviewer - Main application service (port 8080)
- qdrant - Vector database (ports 6333, 6334)
- dashboard - Web interface (port 3000)
- nginx - Reverse proxy (port 8000)
Verify Services
Check that all services are running:
1
docker compose ps
Expected output:
1
2
3
4
5
NAME STATUS
merge-mind Up (healthy)
qdrant Up
merge-mind-dashboard Up
merge-mind-proxy Up
View Logs
1
2
3
4
5
# All services
docker compose logs -f
# Specific service
docker compose logs -f ai-reviewer
Step 5: Access the Dashboard
Open your browser and navigate to:
- Dashboard: http://localhost:8000
- API Docs: http://localhost:8000/api/docs
- Health Check: http://localhost:8080/health
Step 6: Configure GitLab Webhook
Connect Merge Mind to your GitLab projects:
- Go to your GitLab project
- Navigate to Settings → Webhooks
- Add a new webhook:
- URL:
http://your-server:8080/webhook - Secret Token: (same as
GITLAB_WEBHOOK_SECRETin .env) - Trigger: ✅ Merge request events
- SSL verification: Enable if using HTTPS
- URL:
- Click Add webhook
For production, use HTTPS and ensure your server is accessible from GitLab. Consider using a reverse proxy like nginx with SSL certificates.
Test the Webhook
After adding the webhook:
- Click Test → Merge request events
- Check the webhook logs in GitLab
- Verify in Merge Mind logs:
docker compose logs ai-reviewer
You should see:
1
2
INFO - Received webhook event: merge_request
INFO - Webhook processed successfully
Step 7: Train on Your Codebase (Optional)
Train Merge Mind on your existing code for better reviews:
From Local Codebase (Recommended)
1
2
3
docker compose exec ai-reviewer \
python scripts/learn_local_codebase.py my_project /path/to/codebase \
--extensions .php .blade.php .vue .js .ts
From GitLab Repository
1
2
docker compose exec ai-reviewer \
python scripts/learn_codebase.py 123 --branch main
Training typically takes 5-15 minutes depending on codebase size.
Step 8: Test Your First Review
Create a test merge request:
- Create a new branch with some code changes
- Open a merge request in GitLab
- Watch as Merge Mind analyzes the code
- Review the AI-generated comments
The bot will post:
- Inline comments on specific lines
- A comprehensive summary comment
- Severity ratings (critical, major, minor, suggestion)
Quick Tips
Start Small: Enable reviews on 1-2 projects first to fine-tune settings before rolling out team-wide.
Use Hot Reload: Change OpenAI model without restarting:
1 2 export OPENAI_MODEL=gpt-4 curl -X POST http://localhost:8080/reload
Monitor Performance: Check metrics regularly:
1 curl http://localhost:8080/metrics | jq