Optare v1.0 is now available. Get started →
Deployment
Production Guide

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 main

Step 2: Create Vercel Account

  1. Go to https://vercel.com (opens in a new tab)
  2. Sign up with GitHub
  3. Authorize Vercel to access your repositories

Step 3: Import Project

  1. Click "New Project"
  2. Select your Optare repository
  3. 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.one

Step 5: Deploy

  1. Click "Deploy"
  2. Wait for build to complete
  3. Your app is live at https://your-project.vercel.app

Step 6: Connect Custom Domain

  1. Go to Settings → Domains
  2. Add your domain (e.g., optare.one)
  3. Follow DNS setup instructions
  4. 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/database

Step 2: Create EC2 Instance

# Launch Ubuntu 22.04 LTS instance
# t3.medium or larger recommended
# Security group: Allow ports 80, 443, 22

Step 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 pm2

Step 4: Clone and Build

# Clone repository
git clone https://github.com/your-repo/optare.git
cd optare
 
# Install dependencies
pnpm install
 
# Build
pnpm build

Step 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.one

Step 6: Start Application

# Start with PM2
pm2 start "pnpm start" --name "optare"
 
# Save PM2 config
pm2 save
 
# Enable auto-restart on reboot
pm2 startup

Step 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 nginx

Step 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

  1. Go to https://www.digitalocean.com (opens in a new tab)
  2. Sign up
  3. Create a project

Step 2: Create Database

  1. Go to Databases
  2. Click Create Database
  3. Choose PostgreSQL
  4. Select region
  5. Get connection string

Step 3: Deploy App

  1. Go to App Platform
  2. Click Create App
  3. Connect GitHub repository
  4. Select branch: main
  5. Configure build command: pnpm build
  6. 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.one

Step 5: Deploy

  1. Click "Deploy"
  2. Wait for build and deployment
  3. 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.one

Recommended

# 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-dsn

Optional

# 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=require

Features:

  • Auto-scaling
  • Automatic backups
  • Point-in-time recovery
  • Read replicas available

Email (Resend)

RESEND_API_KEY=re_your_api_key

Features:

  • Transactional emails
  • 99.9% uptime
  • DKIM/SPF configured
  • Bounce handling

Redis (Upstash)

REDIS_URL=https://your-redis.upstash.io
UPSTASH_REDIS_TOKEN=your-token

Features:

  • Serverless Redis
  • Auto-scaling
  • Global replication
  • REST API

🚀 Deployment Steps Summary

Vercel (Fastest - 5 minutes)

  1. Push to GitHub
  2. Connect Vercel
  3. Add environment variables
  4. Deploy
  5. Add custom domain

AWS (Most Control - 30 minutes)

  1. Create RDS database
  2. Launch EC2 instance
  3. Install dependencies
  4. Configure environment
  5. Set up Nginx + SSL
  6. Start application

DigitalOcean (Middle Ground - 15 minutes)

  1. Create database
  2. Connect GitHub
  3. Add environment variables
  4. Deploy
  5. 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 certificate

Monitor Application

  1. Set up error tracking (Sentry)
  2. Set up performance monitoring (New Relic)
  3. Set up uptime monitoring (Pingdom)
  4. Set up log aggregation (LogRocket)

Backup Strategy

  1. Database: Daily automated backups
  2. Code: GitHub repository
  3. Secrets: Secrets manager (AWS Secrets, Vercel)
  4. Configuration: Version controlled

📞 Troubleshooting

Build Fails

# Check build locally
pnpm build
 
# Check for TypeScript errors
pnpm type-check
 
# Check for missing dependencies
pnpm install

Database Connection Error

# Verify DATABASE_URL is correct
# Format: postgresql://user:password@host:port/database
 
# Test connection
psql $DATABASE_URL

App Won't Start

# Check logs
pm2 logs optare
 
# Check port is available
lsof -i :3000
 
# Check environment variables
env | grep BETTER_AUTH

SSL Certificate Issues

# Renew certificate
sudo certbot renew
 
# Check certificate
openssl s_client -connect optare.one:443

🎯 Next Steps After Deployment

  1. Create admin user:

    pnpm tsx create-admin.ts
  2. Create test product:

    • Go to admin dashboard
    • Create a product (e.g., "Pro Plan")
    • Set pricing and seats
  3. Create test organization:

    • Go to portal
    • Create organization
    • Create subscription
  4. Test OAuth flow:

    • Create OAuth client
    • Test "Sign in with Optare"
    • Verify token exchange
  5. 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:

  1. Deploying to your chosen platform
  2. Creating admin user
  3. Setting up products and subscriptions
  4. Testing OAuth integration
  5. Monitoring performance

Good luck! 🚀