Overview
Nectr is designed to be deployed with:- Backend: Railway (FastAPI + PostgreSQL)
- Frontend: Vercel (Next.js)
Prerequisites
- GitHub account
- Railway account (railway.app)
- Vercel account (vercel.com)
- Supabase account for PostgreSQL (supabase.com)
- Neo4j Aura account (neo4j.com/cloud/aura)
- Anthropic API key (console.anthropic.com)
Backend Deployment (Railway)
Create Railway project
- Go to railway.app and sign in with GitHub
- Click New Project
- Select Deploy from GitHub repo
- Choose your Nectr fork/repo
Configure build settings
Railway auto-detects the Dockerfile. Verify these settings:
- Root Directory:
/(repository root) - Dockerfile Path:
Dockerfile - Build Command: (auto-detected from Dockerfile)
- Start Command:
uvicorn app.main:app --host 0.0.0.0 --port $PORT
Railway automatically injects the
$PORT environment variable. The Dockerfile already handles this.Set up PostgreSQL
Option 1: Use Supabase (recommended)
- Go to supabase.com and create a new project
- Navigate to Project Settings → Database
- Copy the Connection Pooling string (Session Mode, port 5432)
- Format for SQLAlchemy:
- In your Railway project, click New → Database → PostgreSQL
- Railway will automatically set
DATABASE_URLin your environment
Set environment variables
In Railway project settings → Variables, add all required environment variables from
.env.example:Configure GitHub OAuth
- Go to github.com/settings/developers
- Create a new OAuth App (or update existing)
- Set Authorization callback URL to:
- Copy Client ID and Secret to Railway environment variables
Deploy
Railway will automatically deploy on every push to your main branch.Monitor the deployment:
- Click on your service in Railway dashboard
- View Deployments tab for build logs
- Check Logs tab for runtime logs
Frontend Deployment (Vercel)
Create Vercel project
- Go to vercel.com and sign in with GitHub
- Click Add New → Project
- Import your Nectr repository
Configure build settings
Set the following in Vercel project settings:
- Framework Preset: Next.js
- Root Directory:
nectr-web - Build Command:
npm run build(auto-detected) - Output Directory:
.next(auto-detected) - Install Command:
npm install(auto-detected)
Set environment variables
In Vercel project settings → Environment Variables, add:
NEXT_PUBLIC_* variables are embedded in the browser bundle at build time. Only set public, non-sensitive values.Deploy
Click Deploy. Vercel will:
- Clone your repository
- Install dependencies (
npm installinnectr-web/) - Build the Next.js app (
npm run build) - Deploy to edge network
Update backend URLs
After Vercel deployment completes:
- Copy your Vercel deployment URL (e.g.,
https://your-app.vercel.app) - Go back to Railway project settings → Variables
- Update
FRONTEND_URLto your Vercel URL - Railway will automatically redeploy with the new variable
Update GitHub OAuth callback
Update your GitHub OAuth App callback URL to include the production frontend:
- Go to github.com/settings/developers
- Edit your OAuth App
- Ensure callback URL is still:
Database Setup
PostgreSQL (Supabase)
Create Supabase project
- Go to supabase.com
- Click New Project
- Choose a region close to your Railway deployment
- Set a strong database password
Get connection string
- Navigate to Project Settings → Database
- Scroll to Connection Pooling
- Select Session mode
- Copy the connection string
Neo4j (Aura)
Create Neo4j Aura instance
- Go to neo4j.com/cloud/aura
- Click Create database → Free instance
- Wait for provisioning (2-3 minutes)
Get connection details
- Download the credentials file (shown once after creation)
- Or navigate to instance → Connect → URI, Username, Password
- Copy:
NEO4J_URI(e.g.,neo4j+s://xxxxx.databases.neo4j.io)NEO4J_USERNAME(usuallyneo4j)NEO4J_PASSWORD
Automatic Migrations
Alembic migrations run automatically on backend startup. No manual intervention needed.
app/main.py:88-117):
- Run Alembic migrations (
alembic upgrade head) - Create any missing tables (belt-and-suspenders)
- Initialize Neo4j schema (constraints and indexes)
- Scan connected repos not yet indexed in Neo4j
Continuous Deployment
Both Railway and Vercel support automatic deployments:- Railway: Auto-deploys on every push to
mainbranch - Vercel: Auto-deploys on every push to
mainbranch
Branch Previews
Vercel creates preview deployments for every PR. Railway can be configured for preview environments (paid plan).Monitoring
Railway
- Logs: Real-time logs in Railway dashboard → Logs tab
- Metrics: CPU, memory, network usage in Metrics tab
- Health checks: Railway monitors your
/healthendpoint
Vercel
- Deployments: View build logs and deployment history
- Analytics: Enable Vercel Analytics for performance monitoring
- Logs: Runtime logs in Vercel dashboard → Logs tab
Custom Health Checks
Set up external monitoring (e.g., UptimeRobot, Better Uptime) to ping:Rollback
Railway
- Go to Deployments tab
- Find the previous working deployment
- Click ⋯ → Redeploy
Vercel
- Go to Deployments tab
- Find the previous working deployment
- Click ⋯ → Promote to Production
Environment-Specific Configuration
Production Settings
Recommended settings for production:Feature Flags
Scaling
Railway
- Horizontal scaling: Add more replicas in Railway settings
- Vertical scaling: Upgrade to larger instance size
- Database connection pooling: Supabase handles this automatically
Vercel
- Automatic scaling: Vercel scales based on traffic
- Edge network: Global CDN for frontend assets
- ISR: Configure
revalidatein Next.js pages for Incremental Static Regeneration
Security Checklist
- Use strong, unique
SECRET_KEY(32+ bytes, generated withsecrets.token_hex(32)) - Set
DEBUG=Falsein production - Use Supabase connection pooling (Session mode)
- Whitelist only necessary IPs in Neo4j Aura
- Rotate
GITHUB_PATperiodically - Set
APP_ENV=production - Enable HTTPS (Railway and Vercel handle this automatically)
- Review CORS settings in
app/main.py(lines 143-157)
Troubleshooting
Railway build fails
Railway build fails
- Check Railway build logs for specific error
- Verify
requirements.txthas all dependencies - Ensure Dockerfile is in repository root
- Check that Python 3.14 is available (Railway supports 3.10+)
Database migrations fail
Database migrations fail
- Check
DATABASE_URLformat (must start withpostgresql+asyncpg://) - Verify database is accessible from Railway
- Check Railway logs for Alembic error messages
- Manually run migrations:
alembic upgrade headin Railway shell
OAuth redirect fails
OAuth redirect fails
- Verify GitHub OAuth callback URL matches Railway URL
- Check
BACKEND_URLandFRONTEND_URLin Railway environment - Ensure
FRONTEND_URLis in CORS allowed origins (seeapp/main.py:143-157)
Neo4j connection timeout
Neo4j connection timeout
- Check Neo4j Aura IP whitelist includes
0.0.0.0/0 - Verify
NEO4J_URIusesneo4j+s://protocol (notbolt://) - Check Neo4j Aura instance is running
- Test connection from Railway shell:
pip install neo4j && python -c 'from neo4j import GraphDatabase; ...'
Vercel build fails
Vercel build fails
- Check Vercel build logs
- Verify Root Directory is set to
nectr-web - Ensure
package.jsonhasbuildscript - Check Node.js version (needs 20+)
Next Steps
Environment Variables
Complete reference for all configuration options
Webhook Setup
Configure GitHub webhooks for PR reviews
Monitoring
Track PR review metrics
Architecture
Understand the deployment architecture