Optare Production Deployment Guide
Overview
This guide walks you through deploying Optare to production on a cloud platform.
🎯 Deployment Options
Recommended: Vercel (Easiest)
- ✅ Remix-optimized
- ✅ Zero-config deployment
- ✅ Free tier available
- ✅ Auto-scaling
- ✅ Global CDN
Alternative: AWS (Most Control)
- ✅ EC2 + RDS
- ✅ Full control
- ✅ Enterprise-grade
- ✅ More complex setup
Alternative: DigitalOcean (Middle Ground)
- ✅ Simple setup
- ✅ Affordable
- ✅ Good performance
- ✅ App Platform
📋 Pre-Deployment Checklist
- Database URL configured (Neon)
- Environment variables set
- Build passes locally (
pnpm build) - Tests pass (if applicable)
- Domain name ready
- SSL certificate (auto-handled by most platforms)
- Email service configured (Resend)
- Redis configured (optional but recommended)
🚀 Option 1: Deploy to Vercel (Recommended)
Step 1: Prepare Your Code
# Make sure everything is committed
git add .
git commit -m "Ready for production"
git push origin mainStep 2: Create Vercel Account
- Go to https://vercel.com (opens in a new tab)
- Sign up with GitHub
- Authorize Vercel to access your repositories
Step 3: Import Project
- Click "New Project"
- Select your Optare repository
- Click "Import"
Step 4: Configure Environment Variables
In Vercel dashboard, go to Settings → Environment Variables and add:
# Database
DATABASE_URL=postgresql://user:password@host/database
# Better Auth
BETTER_AUTH_SECRET=your-secret-key-min-32-chars
BETTER_AUTH_URL=https://optare.one
# Resend
RESEND_API_KEY=re_your_api_key
# Redis (optional)
REDIS_URL=redis://your-redis-url
# Production URL
PRODUCTION_URL=https://optare.oneStep 5: Deploy
- Click "Deploy"
- Wait for build to complete
- Your app is live at
https://your-project.vercel.app
Step 6: Connect Custom Domain
- Go to Settings → Domains
- Add your domain (e.g.,
optare.one) - Follow DNS setup instructions
- Wait for DNS propagation (5-30 minutes)
🚀 Option 2: Deploy to AWS
Step 1: Set Up RDS Database
# Create PostgreSQL database on AWS RDS
# Get connection string: postgresql://user:password@host:5432/databaseStep 2: Create EC2 Instance
# Launch Ubuntu 22.04 LTS instance
# t3.medium or larger recommended
# Security group: Allow ports 80, 443, 22Step 3: Install Dependencies
# SSH into instance
ssh -i your-key.pem ubuntu@your-instance-ip
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install pnpm
npm install -g pnpm
# Install PM2 (process manager)
npm install -g pm2Step 4: Clone and Build
# Clone repository
git clone https://github.com/your-repo/optare.git
cd optare
# Install dependencies
pnpm install
# Build
pnpm buildStep 5: Configure Environment
# Create .env file
nano .env
# Add production variables:
DATABASE_URL=postgresql://user:password@host/database
BETTER_AUTH_SECRET=your-secret-key
BETTER_AUTH_URL=https://optare.one
RESEND_API_KEY=re_your_api_key
PRODUCTION_URL=https://optare.oneStep 6: Start Application
# Start with PM2
pm2 start "pnpm start" --name "optare"
# Save PM2 config
pm2 save
# Enable auto-restart on reboot
pm2 startupStep 7: Set Up Nginx Reverse Proxy
# Install Nginx
sudo apt install -y nginx
# Create config
sudo nano /etc/nginx/sites-available/optare
# Add:
server {
listen 80;
server_name optare.one www.optare.one;
location / {
proxy_pass https://yourapp.com;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_cache_bypass $http_upgrade;
}
}
# Enable site
sudo ln -s /etc/nginx/sites-available/optare /etc/nginx/sites-enabled/
# Test config
sudo nginx -t
# Restart Nginx
sudo systemctl restart nginxStep 8: Set Up SSL with Let's Encrypt
# Install Certbot
sudo apt install -y certbot python3-certbot-nginx
# Get certificate
sudo certbot --nginx -d optare.one -d www.optare.one
# Auto-renewal
sudo systemctl enable certbot.timer🚀 Option 3: Deploy to DigitalOcean App Platform
Step 1: Create DigitalOcean Account
- Go to https://www.digitalocean.com (opens in a new tab)
- Sign up
- Create a project
Step 2: Create Database
- Go to Databases
- Click Create Database
- Choose PostgreSQL
- Select region
- Get connection string
Step 3: Deploy App
- Go to App Platform
- Click Create App
- Connect GitHub repository
- Select branch:
main - Configure build command:
pnpm build - Configure start command:
pnpm start
Step 4: Add Environment Variables
In App Platform settings, add:
DATABASE_URL=postgresql://...
BETTER_AUTH_SECRET=...
BETTER_AUTH_URL=https://optare.one
RESEND_API_KEY=...
PRODUCTION_URL=https://optare.oneStep 5: Deploy
- Click "Deploy"
- Wait for build and deployment
- Your app is live
🔧 Production Environment Variables
Required
# Database (Neon recommended)
DATABASE_URL=postgresql://user:password@host/database
# Better Auth
BETTER_AUTH_SECRET=generate-random-32-char-string
BETTER_AUTH_URL=https://optare.one
# Production URL
PRODUCTION_URL=https://optare.oneRecommended
# Email Service
RESEND_API_KEY=re_your_api_key
# Redis Cache (for performance)
REDIS_URL=redis://your-redis-url
# Monitoring
SENTRY_DSN=https://your-sentry-dsnOptional
# OAuth Providers
TWITTER_CLIENT_ID=...
TWITTER_CLIENT_SECRET=...
# Enterprise SSO
OKTA_CLIENT_ID=...
OKTA_CLIENT_SECRET=...🔐 Security Checklist
- HTTPS enabled (SSL certificate)
- Environment variables not in code
- Database backups configured
- Rate limiting enabled
- CORS properly configured
- API keys rotated
- Secrets manager used (AWS Secrets, Vercel, etc.)
- Database encryption enabled
- Regular security updates
- Monitoring and alerts set up
📊 Production Configuration
Database (Neon)
DATABASE_URL=postgresql://neondb_owner:password@ep-xxx.us-east-1.aws.neon.tech/neondb?sslmode=requireFeatures:
- Auto-scaling
- Automatic backups
- Point-in-time recovery
- Read replicas available
Email (Resend)
RESEND_API_KEY=re_your_api_keyFeatures:
- Transactional emails
- 99.9% uptime
- DKIM/SPF configured
- Bounce handling
Redis (Upstash)
REDIS_URL=https://your-redis.upstash.io
UPSTASH_REDIS_TOKEN=your-tokenFeatures:
- Serverless Redis
- Auto-scaling
- Global replication
- REST API
🚀 Deployment Steps Summary
Vercel (Fastest - 5 minutes)
- Push to GitHub
- Connect Vercel
- Add environment variables
- Deploy
- Add custom domain
AWS (Most Control - 30 minutes)
- Create RDS database
- Launch EC2 instance
- Install dependencies
- Configure environment
- Set up Nginx + SSL
- Start application
DigitalOcean (Middle Ground - 15 minutes)
- Create database
- Connect GitHub
- Add environment variables
- Deploy
- Add custom domain
🔍 Post-Deployment
Verify Deployment
# Check if app is running
curl https://optare.one
# Check database connection
# Should see login page without errors
# Check SSL certificate
# Should show valid certificateMonitor Application
- Set up error tracking (Sentry)
- Set up performance monitoring (New Relic)
- Set up uptime monitoring (Pingdom)
- Set up log aggregation (LogRocket)
Backup Strategy
- Database: Daily automated backups
- Code: GitHub repository
- Secrets: Secrets manager (AWS Secrets, Vercel)
- Configuration: Version controlled
📞 Troubleshooting
Build Fails
# Check build locally
pnpm build
# Check for TypeScript errors
pnpm type-check
# Check for missing dependencies
pnpm installDatabase Connection Error
# Verify DATABASE_URL is correct
# Format: postgresql://user:password@host:port/database
# Test connection
psql $DATABASE_URLApp Won't Start
# Check logs
pm2 logs optare
# Check port is available
lsof -i :3000
# Check environment variables
env | grep BETTER_AUTHSSL Certificate Issues
# Renew certificate
sudo certbot renew
# Check certificate
openssl s_client -connect optare.one:443🎯 Next Steps After Deployment
-
Create admin user:
pnpm tsx create-admin.ts -
Create test product:
- Go to admin dashboard
- Create a product (e.g., "Pro Plan")
- Set pricing and seats
-
Create test organization:
- Go to portal
- Create organization
- Create subscription
-
Test OAuth flow:
- Create OAuth client
- Test "Sign in with Optare"
- Verify token exchange
-
Monitor production:
- Check error logs
- Monitor performance
- Track user signups
📈 Scaling for Production
Phase 1: MVP (Current)
- Single database
- Single app instance
- Basic monitoring
Phase 2: Growth
- Database read replicas
- Multiple app instances
- Load balancer
- CDN for static assets
- Redis caching
Phase 3: Enterprise
- Multi-region deployment
- Database sharding
- Kubernetes orchestration
- Advanced monitoring
- DDoS protection
💰 Cost Estimation
Vercel
- Free tier: Up to 100GB bandwidth/month
- Pro: $20/month + usage
- Enterprise: Custom pricing
AWS
- EC2: $10-50/month (t3.medium)
- RDS: $15-100/month (db.t3.micro)
- Total: $25-150/month
DigitalOcean
- App Platform: $12/month (basic)
- Database: $15/month (basic)
- Total: $27/month
✅ Production Ready Checklist
- Database configured and backed up
- Environment variables set
- SSL certificate installed
- Email service configured
- Monitoring set up
- Error tracking enabled
- Backups automated
- Security audit completed
- Performance tested
- Documentation updated
🎉 You're Ready!
Your Optare instance is now production-ready. Start by:
- Deploying to your chosen platform
- Creating admin user
- Setting up products and subscriptions
- Testing OAuth integration
- Monitoring performance
Good luck! 🚀