MergeWise is an AI powered pull request reviewer that produces context aware, actionable feedback directly inside GitHub Checks. It blends retrieval augmented generation (FAISS + OpenAI) with a production ready FastAPI backend, optional Celery workers, and structured telemetry.
Want reviews without deploying anything? Share or install the hosted MergeWise GitHub App:
- Open the installation page: https://github.com/apps/mergewise.
- Choose the repositories you want reviewed. The app only requires Checks (Read & Write) and Pull Requests (Read) permissions.
- MergeWise automatically reviews pull requests and publishes a Check Run with per line annotations, severities, rationale, and fix-ready suggestions.
All secrets stay in the infrastructure you manage; installing organizations never see or provide credentials.
Run MergeWise locally or in your own cloud to inspect the architecture, extend features, or demo operational maturity.
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txtCreate a .env file (loaded via python-dotenv) with the required settings:
OPENAI_API_KEY=<your-openai-api-key>
OPENAI_MODEL=gpt-4.1-mini
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
GITHUB_APP_ID=<your-github-app-id>
GITHUB_APP_PRIVATE_KEY_PEM="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
GITHUB_WEBHOOK_SECRET=<optional>
ENABLE_TASK_QUEUE=0 # set to 1 when running Celery/Redis
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0
LOG_FILE=logs/mergewise.log
LOG_LEVEL=INFO
LOG_FORCE=1
LOG_CONSOLE=1
Additional knobs (chunk sizes, reranker toggle, queue depth, logging fallbacks) live in src/settings.py and src/context/config.py.
source venv/bin/activate
uvicorn app:app --reloadUseful endpoints:
GET /health– basic readiness probePOST /review– review an arbitrary diff payloadPOST /review/github– review by owner/repo/pr numberPOST /github/webhook– GitHub webhook handler (HMAC verified if secret set)
For large PRs or multi-tenant installs, offload work to Celery workers:
- Start Redis locally (or point
CELERY_BROKER_URLto a managed instance):docker run --rm -p 6379:6379 redis:7-alpine
- Toggle queue mode by setting
ENABLE_TASK_QUEUE=1in.env. - Launch a worker alongside the API:
source venv/bin/activate celery -A src.task_queue:celery_app worker --loglevel=info
Workers share the rotating file handler and structured logs, emitting queue depth, task durations, and fallback reasons. If Redis is unreachable, reviews fall back to inline execution and responses include a queue_error flag for visibility.
docker build -t mergewise .
docker run --rm -p 8000:8000 --env-file .env mergewise web
# Optional worker in a second container
docker run --rm --env-file .env mergewise worker(If you prefer inline execution inside the container, override ENABLE_TASK_QUEUE=0 when running mergewise web.)
Prefer to run everything yourself?
- Create a GitHub App with Checks (Read & Write) and Pull Requests (Read) permissions.
- Set the webhook URL to
/github/webhookand reuse the same secret in.env. - Deploy MergeWise (Render, Fly.io, Railway, AWS, etc.) using the provided Dockerfile. The entrypoint script exposes roles:
./docker-entrypoint.sh web→ FastAPI service./docker-entrypoint.sh worker→ Celery worker
- Install the app on target repositories. The service automatically discovers the installation ID and mints scoped tokens before each review.
- Production readiness – Celery/Redis queue, rotating file logs, structured telemetry, and validation show real deployment discipline.
- Context aware intelligence – FAISS embeddings, AST-aware chunking, and reranking demonstrate modern RAG patterns beyond prompt tinkering.
- Security conscious – HMAC webhook verification, short-lived GitHub installation tokens, and inline fallback for restricted environments.
- Extensible architecture –
ReviewService,ReviewQueue, context providers, and validators keep new features isolated and testable.
├─ app.py # FastAPI entrypoint & routes
├─ src/
│ ├─ context/ # Context indexing + retrieval (config, chunking, FAISS store, reranker, service)
│ ├─ github.py # GitHub REST client + helpers
│ ├─ reviewer.py # ReviewEngine (diff parsing, LLM prompts, aggregation)
│ ├─ services/ # Application-level orchestration (ReviewService, ReviewQueue)
│ ├─ security.py # GitHub App JWT + installation token helpers
│ ├─ settings.py # Centralized configuration (env-driven)
│ └─ ... # task_queue, utils, schemas, etc.
├─ docs/ # Architecture, deployment, and queue guides
├─ requirements.txt # Runtime dependencies
├─ Dockerfile # Containerized deployment
├─ tests/ # pytest suite with fixtures + integration tests
└─ README.md # Project documentation
- Request orchestration –
ReviewServicedecides between inline execution and queueing, prepares context services, and captures telemetry. - Diff parsing –
DiffParsersplits the unified diff into file-specific chunks. - Context retrieval –
RepositoryContextServiceindexes repository blobs with OpenAI embeddings + FAISS; optional reranking heightens relevance. - LLM prompts –
ReviewEnginesends the diff + context to OpenAI, enforcing strict JSON findings (severity, rationale, recommendation, patch). - Aggregation & reporting – Summaries, severity counts, and per-file diffs feed into GitHub Check annotations with fix-ready code snippets.
source venv/bin/activate
PYTHONPATH=. pytestThe suite covers chunking, FAISS persistence, context retrieval, reranking resiliency, reviewer orchestration, GitHub client behaviour, FastAPI routes, and annotation formatting.
- Fast retrieval – FAISS + JSON metadata allow quick reuse across webhook calls.
- LLM guardrails – prompts enforce strict JSON, severity tokens, and diff-formatted patches; utilities normalize model output.
- Extensible – plug in new chunkers, rerankers, or heuristics by extending
context/orservices/components. - Observable – unified logging writes queue depth, durations, fallback reasons, and worker outcomes to rotating files.
- Developer-friendly – modular code, clear interfaces, and thorough tests lower the barrier for new contributors.
- Auto-apply fix patches via GitHub Check actions.
- Repo-specific policy tuning (ignored paths, severity thresholds).
- Metrics dashboards for latency, model spend, and precision/recall tracking.
- Reviewer personas (language/framework hints) to tailor prompts.
PRs welcome! Please:
- Run
pytestlocally. - Add/adjust tests for new logic.
- Update documentation where relevant.
Happy reviewing!