Overview
This guide covers deploying ARCA to production environments. The monorepo structure allows you to deploy the backend and frontend independently to different platforms.Deployment Architecture
Backend
NestJS API deployed to Node.js hosting (Railway, Heroku, VPS)
Frontend
Next.js app deployed to Vercel, Netlify, or similar
Database
PostgreSQL on managed services (Supabase, Neon, AWS RDS)
File Storage
Document storage on S3, Cloudinary, or similar
Pre-Deployment Checklist
Security Review
Environment Variables
Environment Variables
- All secrets use strong, random values
-
JWT_SECRETis unique and secure -
NEXTAUTH_SECRETis generated properly - Database credentials are strong
- No secrets committed to git
Default Credentials
Default Credentials
- Changed all default user passwords
- Removed or disabled test accounts
- Admin accounts use strong passwords
CORS Configuration
CORS Configuration
-
CORS_ORIGINset to production domain(s) - No wildcards (
*) in CORS settings
Build Test
Test production builds locally:Verify:
- No build errors
- TypeScript compilation succeeds
- Applications start correctly
Database Preparation
Prepare your production database:
- PostgreSQL database created
- Database user has appropriate permissions
- SSL enabled
- Automated backups configured
- Connection pooling set up (if needed)
Backend Deployment
Option 1: Railway
Railway offers easy deployment with automatic SSL and PostgreSQL.Add PostgreSQL
In Railway dashboard:
- Click “New” → “Database” → “PostgreSQL”
- Copy the
DATABASE_URLconnection string
Option 2: Heroku
Option 3: Docker
Deploy using Docker containers.Frontend Deployment
Option 1: Vercel (Recommended)
Vercel offers the best Next.js deployment experience.Set Environment Variables
In Vercel dashboard:
- Go to Project Settings → Environment Variables
- Add:
NEXT_PUBLIC_API_URL: Your backend URL (e.g.,https://arca-backend.railway.app)NEXTAUTH_URL: Your frontend URL (e.g.,https://arca.vercel.app)NEXTAUTH_SECRET: Generated secret
Option 2: Netlify
Option 3: Self-Hosted
Post-Deployment
Verify Deployment
Backend Health Check
Backend Health Check
Frontend Access
Frontend Access
Open your frontend URL in a browser and verify:
- Application loads
- Can access login page
- No console errors
Database Connection
Database Connection
Test a login with default credentials to verify database connectivity.
Change Default Passwords
Login with each default user and update passwords:
Configure Monitoring
Set up monitoring and alerts:
Application Monitoring
- Sentry for error tracking
- LogRocket for session replay
- New Relic for APM
Infrastructure Monitoring
- Railway/Heroku built-in metrics
- Uptime monitoring (UptimeRobot)
- Database performance monitoring
Environment-Specific Configuration
- Production
- Staging
- Development
Scaling Considerations
Backend Scaling
- Use horizontal scaling (multiple instances)
- Implement connection pooling (PgBouncer)
- Add Redis for session storage
- Use CDN for static assets
Database Scaling
- Enable read replicas
- Implement connection pooling
- Add database indexes for common queries
- Consider partitioning for large tables
Frontend Scaling
- Vercel automatically handles scaling
- Enable Next.js Image Optimization
- Use ISR for static content
- Implement client-side caching
File Storage
- Move to S3/Cloudinary for documents
- Use signed URLs for secure access
- Implement CDN for file delivery
Troubleshooting
Database Connection Errors
Database Connection Errors
- Verify
DATABASE_URLis correct - Check SSL mode requirements
- Ensure database accepts connections from deployment IP
- Verify connection pooling settings
CORS Errors
CORS Errors
- Verify
CORS_ORIGINexactly matches frontend URL (including protocol) - Don’t include trailing slash
- For multiple origins, ensure proper format
- Check browser console for exact origin being rejected
Build Failures
Build Failures
- Check build logs for specific errors
- Verify all dependencies are in
package.json - Ensure TypeScript compilation succeeds locally
- Check Node.js version matches requirements (>= 18)
Environment Variables Not Loading
Environment Variables Not Loading
- Verify variables are set in platform dashboard
- Restart application after setting variables
- Check variable names (no typos)
- For Next.js, ensure
NEXT_PUBLIC_prefix for client-side variables
Security Checklist
- All default passwords changed
- Strong JWT and NextAuth secrets
- HTTPS enabled on all endpoints
- CORS restricted to specific origins
- Database uses SSL connections
- Environment variables not committed to git
- Rate limiting enabled
- SQL injection prevention (Prisma handles this)
- Input validation on all endpoints
- Audit logging enabled
Next Steps
After deploying to production, make sure to:
- Set up regular database backups
- Monitor application logs for errors
- Keep dependencies updated for security patches
- Review audit logs regularly for compliance
- Test disaster recovery procedures