Deployment Guide

Deploy ChatRAG to production on Vercel (recommended) or other Next.js-compatible platforms.

Deploying to Vercel

1

Prepare Your Repository

Push your ChatRAG code to GitHub, GitLab, or Bitbucket

git add .
git commit -m "Ready for deployment"
git push origin main
2

Create Vercel Project

  1. Visit vercel.com and sign in
  2. Click "New Project"
  3. Import your ChatRAG repository
  4. Select the repository and click "Import"
3

Configure Environment Variables

Add all environment variables from your local .env.local to Vercel:

Required Variables:

  • NEXT_PUBLIC_SUPABASE_URL
  • NEXT_PUBLIC_SUPABASE_ANON_KEY
  • SUPABASE_SERVICE_ROLE_KEY
  • OPENAI_API_KEY
  • OPENROUTER_API_KEY
  • NEXT_PUBLIC_LLAMA_CLOUD_API_KEY
  • NEXT_PUBLIC_SITE_URL (your production domain)
4

Deploy

Click "Deploy" and wait for the build to complete (~2-3 minutes)

Vercel will automatically:

  • Install dependencies
  • Build the Next.js application
  • Deploy to edge network
  • Provide a production URL
5

Configure Custom Domain (Optional)

  1. In Vercel project settings, go to Domains
  2. Add your custom domain (e.g., chatbot.yourdomain.com)
  3. Follow DNS configuration instructions
  4. Update NEXT_PUBLIC_SITE_URL to your custom domain
6

Update Supabase Settings

In Supabase Dashboard → Authentication → URL Configuration:

  • Add your production URL to allowed redirect URLs
  • Update site URL to production domain

Post-Deployment Configuration

Update Site URL

Set your production URL in environment variables:

NEXT_PUBLIC_SITE_URL=https://your-domain.vercel.app

Configure OAuth Providers

Update OAuth callback URLs for GitHub, Google, etc.:

Callback URL format: https://your-project.supabase.co/auth/v1/callback

Enable Production Features

  • Enable authentication if using
  • Configure payment webhooks (Stripe/Polar)
  • Set up email provider (Resend/SMTP)

Alternative Deployment Platforms

Self-Hosting (Docker/VPS)

Deploy on your own infrastructure using Docker, PM2, or similar tools

Requirements:

  • Node.js 18+
  • Environment variables configured
  • Reverse proxy (nginx/Apache)
  • SSL certificate for HTTPS

Coolify

Open-source self-hosting platform

Supports Next.js deployment with automatic SSL and environment management

Other Next.js Platforms

ChatRAG should work on any platform that supports Next.js 15+:

  • Netlify
  • Railway
  • Render
  • AWS (Amplify, EC2)

Important Production Notes

Monitoring & Maintenance

Vercel Analytics

Enable Vercel Analytics to track performance, visitors, and errors

Supabase Monitoring

Monitor database performance and usage:

  • Database size and growth
  • API request volume
  • Authentication logs
  • Storage usage

API Cost Monitoring

Set up usage alerts in provider dashboards:

  • OpenAI API usage
  • OpenRouter credits
  • LlamaCloud document processing
  • FAL.ai/Replicate media generation

Regular Updates

Keep dependencies and platform up to date:

# Update dependencies
npm update

# Redeploy
git push origin main

Common Deployment Issues

Build fails on Vercel

Solutions:

  • Check build logs for missing dependencies
  • Verify Node.js version (18+ required)
  • Ensure all environment variables are set
  • Check for TypeScript errors

Database connection errors

Solutions:

  • Verify Supabase credentials are correct
  • Check service role key is set
  • Ensure Supabase project is active (not paused)
  • Verify allowed origins in Supabase settings

Authentication not working

Solutions:

  • Update NEXT_PUBLIC_SITE_URL to production URL
  • Add production URL to Supabase redirect URLs
  • Update OAuth provider callback URLs
  • Check email provider configuration