Architecture Overview
Before we begin, here’s how Nectr components connect:Prerequisites
GitHub Account
- Admin access to repositories you want to review
- Ability to create OAuth apps
- Ability to create personal access tokens
Required Services
- Anthropic Claude - AI model
- Neo4j Aura - Knowledge graph
- Mem0 - Semantic memory
- Supabase - PostgreSQL database
Part 1: Service Setup
1.1 PostgreSQL Database (Supabase)
Create Project
- Go to supabase.com and create an account
- Click New Project
- Enter:
- Name: nectr-db
- Database Password: Generate a strong password
- Region: Choose closest to your users
- Click Create new project (takes ~2 minutes)
Get Connection String
- Go to Project Settings → Database
- Scroll to Connection Pooling
- Select Session Mode (port 5432)
- Copy the connection string
- Convert to async format:
1.2 Neo4j Knowledge Graph
Create Instance
- Go to neo4j.com/cloud/aura
- Click Start Free
- Create an account or sign in
- Click Create Free Instance
- Select:
- Instance Type: AuraDB Free
- Region: Choose closest to your backend
- Click Create
Save Credentials
Verify Connection
- Click Open on your instance
- Use the credentials to connect via Neo4j Browser
- Run a test query:
MATCH (n) RETURN count(n)
1.3 Mem0 Semantic Memory
Create Account
- Go to mem0.ai
- Sign up for an account
- Verify your email
Generate API Key
- Navigate to API Keys in the dashboard
- Click Create New Key
- Copy the key (starts with
m0-)
1.4 Anthropic Claude
Get API Key
- Go to console.anthropic.com
- Create an account or sign in
- Navigate to API Keys
- Click Create Key
- Copy the key (starts with
sk-ant-)
Set Usage Limits (Optional)
- Go to Settings → Billing
- Set a monthly budget to avoid unexpected charges
- Enable email alerts
Part 2: GitHub Configuration
2.1 Create GitHub OAuth App
Register Application
- Go to github.com/settings/developers
- Click OAuth Apps → New OAuth App
- Fill in:
- Application name:
Nectr AI PR Review - Homepage URL:
https://your-app.vercel.app(temporary, update later) - Application description:
AI-powered PR review agent - Authorization callback URL:
https://your-app.up.railway.app/auth/github/callback(temporary, update later)
- Application name:
- Click Register application
Save Credentials
- Copy the Client ID:
- Click Generate a new client secret
- Copy the secret immediately:
2.2 Create GitHub Personal Access Token
Generate Token
- Go to github.com/settings/tokens
- Click Generate new token → Generate new token (classic)
- Configure:
- Note:
Nectr PR Review Bot - Expiration:
No expiration(or set a reminder to rotate) - Scopes: Select
repo(full control of private repositories)
- Note:
- Click Generate token
Save Token
ghp_):Part 3: Backend Deployment (Railway)
3.1 Deploy from GitHub
Fork Repository
- Go to the Nectr repository on GitHub
- Click Fork in the top-right
- Select your account
Create Railway Project
- Go to railway.app
- Click New Project
- Select Deploy from GitHub repo
- Authenticate with GitHub
- Select your forked Nectr repository
- Click Deploy Now
3.2 Configure Environment Variables
In Railway, go to your project → Variables and add the following:Required Variables
Required Variables
Optional Variables (MCP Integrations)
Optional Variables (MCP Integrations)
3.3 Get Backend URL
Wait for Deployment
Copy URL
- Go to your Railway project → Settings
- Scroll to Domains
- Click Generate Domain
- Copy the URL (e.g.,
nectr-production.up.railway.app)
Update Environment Variables
- Go back to Variables
- Update
BACKEND_URLto your Railway URL:
- Railway will auto-redeploy
3.4 Update GitHub OAuth Callback
Update Callback URL
- Go to github.com/settings/developers
- Click on your Nectr AI PR Review OAuth app
- Update Authorization callback URL to:
- Click Update application
Part 4: Frontend Deployment (Vercel)
4.1 Deploy from GitHub
Import Project
- Go to vercel.com
- Click Add New → Project
- Import your forked Nectr repository
Configure Build Settings
- Framework Preset: Next.js
- Root Directory:
nectr-web - Build Command:
npm run build(auto-detected) - Output Directory:
.next(auto-detected)
Add Environment Variable
Deploy
4.2 Get Frontend URL
Copy Vercel URL
nectr.vercel.app)Update Backend Environment
- Go back to Railway → Variables
- Update
FRONTEND_URL:
- Railway will auto-redeploy
Update GitHub OAuth Homepage
- Go to github.com/settings/developers
- Click on your Nectr AI PR Review OAuth app
- Update Homepage URL to your Vercel URL
- Click Update application
Part 5: Verification
5.1 Test Backend Health
Check Health Endpoint
https://your-backend.up.railway.app/healthYou should see:Check Logs
- Go to your project → Deployments
- Click the latest deployment
- Check logs for errors
5.2 Test Frontend
Open Dashboard
- Navigate to your Vercel URL
- You should see the Nectr landing page
Test OAuth Login
- Click Sign in with GitHub
- Authorize the OAuth app
- You should be redirected to
/dashboard
5.3 Connect First Repository
Navigate to Repos
- Click Repos in the sidebar
- You should see a list of your GitHub repositories
Install Webhook
- Find a test repository
- Click Connect or Install
- Wait for the installation to complete
- Installs a webhook on the repo
- Scans all files and creates Neo4j nodes
- Indexes contributors and file ownership
Test PR Review
- Create a test branch in your connected repo
- Make a small change (add a comment, fix typo)
- Open a pull request
- Within 30 seconds, check the PR for a review comment from your GitHub account
Part 6: Configuration
6.1 Database Migrations
Railway automatically runs database migrations on startup viaalembic. If you need to run migrations manually:
6.2 Neo4j Schema Initialization
Nectr automatically creates Neo4j constraints and indexes on first startup. To verify:Open Neo4j Browser
- Go to your Neo4j instance in the Aura console
- Click Open → Neo4j Browser
- Enter your credentials
Check Constraints
Repository.full_nameFile.pathDeveloper.github_idPullRequest.pr_numberIssue.number
Check Indexes
Troubleshooting
Railway build fails
Railway build fails
- Missing environment variables: Check that all required variables are set
- Python version mismatch: Nectr requires Python 3.14+. Check
runtime.txtor Railway settings - Dependency conflicts: Check Railway logs for pip errors
Vercel build fails
Vercel build fails
- Wrong root directory: Must be set to
nectr-web - Missing NEXT_PUBLIC_API_URL: Required environment variable
- Node version mismatch: Requires Node 20+
- Go to Vercel project → Settings → General
- Set Root Directory to
nectr-web - Go to Environment Variables
- Add
NEXT_PUBLIC_API_URL=https://your-backend.up.railway.app - Redeploy from Deployments tab
Database connection errors
Database connection errors
- Verify
DATABASE_URLusespostgresql+asyncpg://prefix - Check Supabase connection pooling is enabled (Session Mode)
- Test connection:
Neo4j connection errors
Neo4j connection errors
- Verify
NEO4J_URIstarts withneo4j+s://(notbolt://) - Check credentials in Neo4j Aura console
- Test connection:
Webhook not triggering
Webhook not triggering
- PR opened but no review posted
- No webhook events in Railway logs
- Check webhook is installed:
- Go to GitHub repo → Settings → Webhooks
- Verify webhook URL matches
{BACKEND_URL}/api/v1/webhooks/github
- Test webhook delivery:
- Click on the webhook → Recent Deliveries
- Click Redeliver on a recent event
- Check Railway logs for incoming requests:
OAuth login fails
OAuth login fails
- Redirects to GitHub but never returns
- “Invalid client” error
- Verify GitHub OAuth app callback URL:
- Check
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETin Railway - Verify
FRONTEND_URLmatches your Vercel domain - Check CORS configuration in
app/main.py:
Review posted but empty/incomplete
Review posted but empty/incomplete
- Review comment appears but has no content
- Review is cut off mid-sentence
- Check
ANTHROPIC_API_KEYis valid - Verify API key has sufficient credits
- Check Railway logs for Anthropic API errors:
- Increase timeout if reviews are large:
Next Steps
Quickstart Guide
MCP Integrations
Memory Configuration
API Reference
Local Development
To run Nectr locally for development:Clone Repository
Set Up Backend
Set Up Frontend
http://localhost:3001 (configured in package.json).Configure Tunnels (Optional)
Production Checklist
Before going to production, verify:- All environment variables are set in Railway and Vercel
-
SECRET_KEYis a cryptographically secure random value (not the default) -
BACKEND_URLandFRONTEND_URLmatch your actual domains - GitHub OAuth callback URL points to Railway backend
-
DATABASE_URLuses connection pooling (Session Mode) - Neo4j instance is running and accessible
- Mem0 API key is valid and has quota
- Anthropic API key has sufficient credits
-
GITHUB_PAThasreposcope and doesn’t expire soon - Railway auto-deploys from
mainbranch - Vercel auto-deploys from
mainbranch - Health endpoint returns
{"status": "healthy"} - Test PR review completes successfully
- MCP integrations are configured (or intentionally disabled)
- Logging level is set to
INFOorWARNING(notDEBUG) - CORS origins are restricted to your frontend domain