Deployment & Configuration
Complete guide for deploying ExportReady-Battery to production. Covers environment configuration, build commands, and hosting options.
Quick Deploy Checklist
Environment Variables
Backend (.env)
DATABASE_URLRequiredPostgreSQL connection string. Use sslmode=require for production.
postgresql://user:pass@host:5432/database?sslmode=requireJWT_SECRETRequiredSecret key for signing JWT tokens. Use a cryptographically random string.
your-secure-random-secret-key-at-least-32-charsPORTServer port. Defaults to 8080 if not specified.
8080FRONTEND_URLRequiredFrontend URL for CORS configuration.
https://app.exportready.comQR_BASE_URLRequiredBase URL for QR code links. Points to public passport pages.
https://app.exportready.comRAZORPAY_KEY_IDRazorpay API key ID for payment processing.
rzp_live_xxxxxxxxxxxxxRAZORPAY_KEY_SECRETRazorpay API secret key.
xxxxxxxxxxxxxxxxxxxxx# Backend .env example
DATABASE_URL=postgresql://postgres:password@db.supabase.co:5432/postgres
JWT_SECRET=your-super-secure-random-string-here
PORT=8080
FRONTEND_URL=https://app.exportready.com
QR_BASE_URL=https://app.exportready.com
RAZORPAY_KEY_ID=rzp_live_xxxx
RAZORPAY_KEY_SECRET=xxxxFrontend (.env.local)
NEXT_PUBLIC_API_URLRequiredBackend API base URL.
https://api.exportready.com/api/v1NEXT_PUBLIC_RAZORPAY_KEY_IDRazorpay public key for checkout.
rzp_live_xxxxxxxxxxxxx# Frontend .env.local example
NEXT_PUBLIC_API_URL=https://api.exportready.com/api/v1
NEXT_PUBLIC_RAZORPAY_KEY_ID=rzp_live_xxxxBuild Commands
Backend (Go)
Install dependencies:
go mod downloadRun development server:
make runBuild production binary:
make buildRun migrations:
make migrate-upRun tests:
make testFrontend (Next.js)
Install dependencies:
npm installRun development server:
npm run devBuild production bundle:
npm run buildStart production server:
npm run startRun linting:
npm run lintMakefile Commands Reference
# Development
make run # Start backend server
make dev # Start with hot reload (requires air)
# Build
make build # Build binary to ./bin/server
# Testing
make test # Run all tests
make test-coverage # Run tests with coverage
# Database Migrations
make migrate-up # Run pending migrations
make migrate-down # Rollback last migration
make migrate-reset # Rollback ALL migrations
make migrate-version # Show current version
make migrate-create # Create new migration file
# Utilities
make clean # Remove build artifacts
make lint # Run Go linterDatabase Setup
Option 1: Supabase (Recommended)
- 1.Create a new project at supabase.com
- 2.Copy the connection string from Settings → Database
- 3.Set
DATABASE_URLin your .env file - 4.Run
make migrate-upto create tables
Option 2: Local PostgreSQL
# Create database
createdb battery_db
# Set connection string
export DATABASE_URL="postgresql://postgres:password@localhost:5432/battery_db"
# Run migrations
cd backend
make migrate-upProduction Deployment
Railway
Deploy both frontend and backend to Railway with auto-scaling.
# Install Railway CLI
npm i -g @railway/cli
# Login
railway login
# Deploy backend
cd backend
railway up
# Deploy frontend
cd ../frontend
railway upVercel + Fly.io
Frontend on Vercel, backend on Fly.io.
# Deploy frontend to Vercel
cd frontend
vercel
# Deploy backend to Fly.io
cd ../backend
fly launch
fly deployNginx Reverse Proxy
# /etc/nginx/sites-available/exportready
server {
listen 443 ssl http2;
server_name app.exportready.com;
ssl_certificate /etc/letsencrypt/live/app.exportready.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.exportready.com/privkey.pem;
# Frontend
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# Backend API
location /api/ {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}Health Check Endpoints
Use these endpoints to verify your deployment is working:
GET /api/v1/healthGET /