Production

Deployment Guide

Deploy LearnHub to production using Vercel and Neon PostgreSQL for a fully serverless, scalable architecture.

Deploy to Vercel

Vercel provides the best deployment experience for Next.js applications.

Step 1: Connect Repository

  1. Go to vercel.com and sign in
  2. Click "Add New Project"
  3. Import your GitHub repository
  4. Select the ai-lms repository

Step 2: Configure Build Settings

Vercel auto-detects Next.js. The build command is configured in vercel.json:

{
  "framework": "nextjs",
  "buildCommand": "prisma generate && next build",
  "installCommand": "npm install"
}

Step 3: Add Environment Variables

Add these environment variables in Vercel Dashboard → Settings → Environment Variables:

DATABASE_URL
Required
AUTH_SECRET
Required
AUTH_GOOGLE_ID
Optional
AUTH_GOOGLE_SECRET
Optional
AUTH_GITHUB_ID
Optional
AUTH_GITHUB_SECRET
Optional
OPENAI_API_KEY
Optional

Step 4: Deploy

# Via CLI
vercel deploy --prod

# Or push to main branch for auto-deploy

Database Setup (Neon)

Neon provides serverless PostgreSQL that scales automatically.

Step 1: Create Neon Project

  1. Go to neon.tech and sign up
  2. Click "New Project"
  3. Enter project name (e.g., ai-lms)
  4. Select a region close to your Vercel deployment
  5. Click "Create Project"

Step 2: Get Connection String

After creation, copy your connection string from the dashboard:

postgresql://username:password@ep-xxx-xxx-123456.us-east-2.aws.neon.tech/neondb?sslmode=require

Step 3: Initialize Database

Run these commands locally with your Neon DATABASE_URL:

# Set environment variable
export DATABASE_URL="your-neon-connection-string"

# Push schema to Neon
npm run db:push

# Seed with demo data
npm run db:seed

Environment Configuration

Complete list of environment variables for production deployment.

# Database (Neon PostgreSQL)
DATABASE_URL="postgresql://..."

# NextAuth
AUTH_SECRET="random-32-character-secret"
AUTH_URL="https://your-app.vercel.app"

# OAuth (Optional)
AUTH_GOOGLE_ID="your-google-client-id"
AUTH_GOOGLE_SECRET="your-google-client-secret"
AUTH_GITHUB_ID="your-github-client-id"
AUTH_GITHUB_SECRET="your-github-client-secret"

# AI Features (Optional)
OPENAI_API_KEY="sk-your-openai-api-key"
OPENAI_BASE_URL="https://api.openai.com/v1"

# File Storage (Optional)
BLOB_READ_WRITE_TOKEN="your-vercel-blob-token"

# Email (Optional)
RESEND_API_KEY="re_your-resend-api-key"

Deployment Checklist

Create Neon database project
Copy Neon connection string
Add DATABASE_URL to Vercel
Generate AUTH_SECRET (32+ chars)
Add AUTH_SECRET to Vercel
Run npm run db:push locally
Run npm run db:seed locally
Deploy to Vercel
Test login with demo accounts
(Optional) Configure OAuth providers
(Optional) Add OpenAI API key

Useful Links