This guide will take you from zero to your first AI-powered PR review. By the end, Nectr will automatically review every pull request opened on your connected repositories.
Prerequisites
Before you begin, ensure you have:
- A GitHub account with access to the repositories you want to review
- Access to create OAuth apps in GitHub
- API keys for the required services (see below)
Nectr is designed to be self-hosted. You own your data, your API keys, and your infrastructure.
Overview
Nectr requires five core services:
Railway (Backend)
Hosts the FastAPI backend that orchestrates PR reviews
Vercel (Frontend)
Hosts the Next.js dashboard for managing repos and viewing analytics
Neo4j (Knowledge Graph)
Tracks file ownership, developer expertise, and related PRs
Mem0 (Semantic Memory)
Remembers per-project patterns and per-developer habits
Anthropic Claude
Powers the AI analysis with Claude Sonnet 4.6
Step 1: Get Your API Keys
Anthropic API Key
- Go to console.anthropic.com
- Create an account or sign in
- Generate a new API key
- Copy the key (starts with
sk-ant-)
Nectr uses Claude Sonnet 4.6 (claude-sonnet-4-5-20250929) for PR reviews.
Neo4j Cloud Instance
- Visit neo4j.com/cloud/platform/aura-graph-database
- Create a free tier instance
- Note your connection URI (starts with
neo4j+s://)
- Save your username (default:
neo4j) and password
Save your Neo4j password immediately - it’s only shown once during instance creation.
Mem0 API Key
- Go to mem0.ai
- Sign up for an account
- Generate an API key
- Copy the key (starts with
m0-)
GitHub Personal Access Token
- Go to github.com/settings/tokens
- Click Generate new token → Classic
- Select scope:
repo (full control of private repositories)
- Generate and copy the token (starts with
ghp_)
This token is used by Nectr to post PR review comments on your behalf.
PostgreSQL Database
- Go to supabase.com and create a free project
- Navigate to Database → Connection Pooling
- Select Session Mode (port 5432)
- Copy the connection string
- Convert to async format:
# Supabase gives you:
postgresql://postgres.<project-id>:<password>@aws-0-<region>.pooler.supabase.com:5432/postgres
# Change to:
postgresql+asyncpg://postgres.<project-id>:<password>@aws-0-<region>.pooler.supabase.com:5432/postgres
Step 2: Create GitHub OAuth App
Register OAuth App
- Go to github.com/settings/developers
- Click New OAuth App
- Fill in the following:
- Application name: Nectr AI PR Review
- Homepage URL:
https://your-app.vercel.app (use your actual Vercel URL)
- Authorization callback URL:
https://your-backend.up.railway.app/auth/github/callback
- Click Register application
Get Client Credentials
- Copy the Client ID
- Click Generate a new client secret
- Copy the Client Secret immediately (it’s only shown once)
The callback URL must point to your Railway backend, not Vercel. This is where GitHub redirects after OAuth.
Step 3: Deploy Backend to Railway
Create Railway Project
- Go to railway.app and sign in
- Click New Project → Deploy from GitHub repo
- Select your forked Nectr repository
- Choose the root directory (backend is in the root)
Configure Environment Variables
In Railway’s Variables tab, add the following:# AI
ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_MODEL=claude-sonnet-4-5-20250929
# Database
DATABASE_URL=postgresql+asyncpg://...
# GitHub OAuth
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
GITHUB_PAT=ghp_...
# Auth
SECRET_KEY=your_random_secret_key
# Neo4j
NEO4J_URI=neo4j+s://xxx.databases.neo4j.io
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your_password
# Mem0
MEM0_API_KEY=m0-...
# URLs (update after deployment)
BACKEND_URL=https://your-app.up.railway.app
FRONTEND_URL=https://your-app.vercel.app
# App Config
APP_ENV=production
LOG_LEVEL=INFO
Generate a secure SECRET_KEY with: python -c "import secrets; print(secrets.token_hex(32))"
Deploy
Railway will automatically deploy your backend. Once complete:
- Copy your Railway URL (e.g.,
https://nectr-production.up.railway.app)
- Update
BACKEND_URL in Railway variables
- Redeploy if necessary
Step 4: Deploy Frontend to Vercel
Create Vercel Project
- Go to vercel.com and sign in
- Click Add New → Project
- Import your forked Nectr repository
- Set Root Directory to
nectr-web
Configure Environment Variables
Add the following environment variable:NEXT_PUBLIC_API_URL=https://your-app.up.railway.app
Replace with your actual Railway backend URL from Step 3.
Deploy
Click Deploy. Vercel will build and deploy your Next.js frontend.
Step 5: Connect Your First Repository
Open Dashboard
- Navigate to your Vercel URL (e.g.,
https://your-app.vercel.app)
- Click Sign in with GitHub
- Authorize the OAuth app
Connect a Repository
- Go to Repos in the sidebar
- Click Connect Repository
- Select a repository from the list
- Click Install
This will:
- Install a webhook on the repository
- Build the initial Neo4j knowledge graph
- Index all files and contributors
Open a Pull Request
- Create a new branch in your connected repository
- Make some changes and push
- Open a pull request on GitHub
Within 30 seconds, Nectr will post a structured review comment on your PR.
What Happens Next?
When a PR is opened or updated, Nectr automatically:
Receives Webhook
GitHub sends a webhook event to /api/v1/webhooks/github
Fetches Context
- Pulls PR diff and changed files
- Queries Neo4j for file experts and related PRs
- Retrieves project patterns and developer habits from Mem0
- (Optional) Fetches linked Linear issues, Sentry errors, and Slack messages
AI Analysis
Claude Sonnet 4.6 analyzes the PR for:
- Bugs: Logic errors, edge cases, race conditions
- Security: Injection risks, exposed secrets, auth issues
- Performance: N+1 queries, memory leaks, inefficient algorithms
- Style: Code consistency, naming conventions, best practices
Posts Review
- Posts a structured comment on GitHub with:
- Executive summary
- Verdict (APPROVE / REQUEST_CHANGES / COMMENT)
- Inline suggestions for each file
- Severity ratings (🔴 critical, 🟡 moderate, 🟢 minor)
Learns & Remembers
- Indexes PR in Neo4j knowledge graph
- Extracts and stores memories in Mem0:
- Project patterns (e.g., “Always use prepared statements for SQL”)
- Developer strengths (e.g., “Alice excels at React hooks”)
- Risk modules (e.g., “auth/ is security-critical”)
Example Review Output
Here’s what a typical Nectr review looks like:
## 🤖 Nectr AI Review
### Verdict: REQUEST_CHANGES
**Summary**: This PR adds user authentication but introduces a SQL injection vulnerability and skips input validation.
---
### Critical Issues 🔴
#### 1. SQL Injection Risk in `auth.py:45`
```python
# Current (UNSAFE)
query = f"SELECT * FROM users WHERE email = '{email}'"
# Suggested fix
query = "SELECT * FROM users WHERE email = %s"
cursor.execute(query, (email,))
Why: Direct string interpolation allows attackers to inject malicious SQL.
Moderate Issues 🟡
2. Missing Rate Limiting on /login
The login endpoint has no rate limiting, making it vulnerable to brute-force attacks.
Suggested fix: Add @limiter.limit("5 per minute") decorator.
Minor Issues 🟢
3. Inconsistent Error Messages
Some endpoints return {"error": ...}, others return {"message": ...}.
Context: This project uses {"error": ...} consistently (see api/v1/users.py).
---
## Next Steps
<CardGroup cols={2}>
<Card title="Add MCP Integrations" icon="link" href="/integrations/mcp-overview">
Connect Linear, Sentry, and Slack for richer context
</Card>
<Card title="Configure Memory" icon="brain" href="/features/semantic-memory">
Customize project patterns and coding rules
</Card>
<Card title="View Analytics" icon="chart-line" href="/api/analytics/summary">
Track team performance and review metrics
</Card>
<Card title="Enable Parallel Agents" icon="bolt" href="/configuration/feature-flags">
Run 3 specialized agents for deeper analysis
</Card>
</CardGroup>
---
## Troubleshooting
<AccordionGroup>
<Accordion title="Webhook not triggering">
1. Check Railway logs for incoming webhook events
2. Verify webhook is installed: `GET /api/v1/repos` should show `is_installed: true`
3. Check webhook secret matches in Railway env vars
4. Test webhook manually in GitHub repo settings → Webhooks → Recent Deliveries
</Accordion>
<Accordion title="Review posted but empty">
1. Check Railway logs for errors during PR processing
2. Verify `ANTHROPIC_API_KEY` is set and valid
3. Ensure Neo4j and Mem0 credentials are correct
4. Check `GITHUB_PAT` has `repo` scope
</Accordion>
<Accordion title="OAuth login fails">
1. Verify `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` match your OAuth app
2. Check callback URL in GitHub OAuth app matches `{BACKEND_URL}/auth/github/callback`
3. Ensure `FRONTEND_URL` and `BACKEND_URL` are set correctly in Railway
4. Check CORS settings in `app/main.py`
</Accordion>
<Accordion title="Database connection errors">
1. Verify `DATABASE_URL` starts with `postgresql+asyncpg://`
2. Check Supabase connection pooling is enabled (Session Mode, port 5432)
3. Test connection: `railway run python -c "from app.core.database import engine; import asyncio; asyncio.run(engine.connect())"`
</Accordion>
</AccordionGroup>
<Tip>
For more help, check the [Installation Guide](/installation) for detailed setup instructions.
</Tip>