Deployment Guide
Uxie is designed to deploy seamlessly to Vercel with minimal configuration. This guide covers production deployment, environment setup, database migrations, and troubleshooting.Deploying to Vercel
Quick Deploy
The fastest way to deploy Uxie:Import Repository
- Go to vercel.com and sign in
- Click Add New → Project
- Import your Git repository (GitHub, GitLab, or Bitbucket)
Vercel Configuration
Uxie uses default Vercel settings with Next.js 14. Novercel.json required.
Build Settings:
- Framework Preset: Next.js
- Build Command:
next build(default) - Output Directory:
.next(default) - Install Command:
pnpm install - Node Version: 18.x (recommended)
Override Package Manager
Override Package Manager
To use pnpm (recommended):
- Go to Project Settings → General
- Set Install Command to
pnpm install - Vercel will auto-detect
pnpm-lock.yaml
Automatic Deployments
Production
- Triggered by pushes to
mainbranch - Uses production environment variables
- Deployed to
uxie.vercel.app
Preview
- Triggered by PRs and branch pushes
- Uses preview environment variables
- Unique URL per deployment
- Great for testing before merge
Environment Variables
Required Production Variables
Add these in Vercel Dashboard → Settings → Environment Variables:Database
Database
Authentication
Authentication
https://uxie.vercel.app/api/auth/callback/google
File Upload
File Upload
AI Services
AI Services
- HuggingFace: Free tier sufficient for moderate usage
- Pinecone: Free tier includes 1 index with 100k vectors
- Google Gemini: Pay-per-token, 2.5 Flash is cost-effective
Optional Services
Optional Services
Environment Variable Security
Sensitive Keys
Never commit
.env to git.Ensure .gitignore includes:Public Variables
Only
NEXT_PUBLIC_* variables are exposed to browser.Keep API keys private unless intentionally public.Managing Multiple Environments
Vercel supports three environments:| Environment | Branch | Use Case |
|---|---|---|
| Production | main | Live app for users |
| Preview | Any branch | Testing PRs |
| Development | Local | Local development |
Database Migrations
Initial Production Setup
Create Production Database
- Create new Supabase project for production
- Note connection string
- Enable connection pooling
Prisma Migration Commands
Prisma Migration Commands
Development:Production:Schema Push (for prototyping):Warning:
db push can cause data loss. Use migrations in production.Automated Migrations
Add migration script topackage.json:
- Generate Prisma Client
- Apply pending migrations
- Build Next.js app
Schema Changes Workflow
Build Optimization
Environment-Specific Optimizations
next.config.mjs includes production optimizations:Bundle Analysis
Analyze bundle size:next.config.mjs:
Edge Runtime Support
Some API routes use edge runtime for low latency:/api/chat- AI chat streaming/api/completion- Text completion/api/evaluate- Flashcard evaluation
Monitoring & Troubleshooting
Vercel Analytics
Enable in project settings:- Web Analytics - Page views, performance
- Speed Insights - Core Web Vitals
- Log Drains - Export logs to external services
Error Tracking
Build Errors
View in Vercel deployment logs:
- TypeScript errors
- Linting errors
- Build failures
Runtime Errors
View in Vercel Functions logs:
- API route errors
- Server-side errors
- Database connection issues
Common Production Issues
Database Connection Timeout
Database Connection Timeout
Problem: Serverless functions timeout connecting to database.Solution: Enable connection pooling in Supabase:
- Get pooled connection string from Supabase dashboard
- Update
DATABASE_URLin Vercel - Redeploy
Environment Variable Not Found
Environment Variable Not Found
Problem: Build fails with missing environment variable.Solution:
- Check Vercel dashboard → Settings → Environment Variables
- Ensure variable is set for correct environment (Production/Preview)
- Redeploy
Prisma Client Not Generated
Prisma Client Not Generated
Problem: Build fails with “Cannot find module ‘@prisma/client’”.Solution: Ensure Vercel runs this automatically after
postinstall script runs:pnpm install.OAuth Redirect URI Mismatch
OAuth Redirect URI Mismatch
Problem: Google OAuth fails with redirect URI error.Solution: Update Google Cloud Console:
- Go to console.cloud.google.com
- APIs & Services → Credentials
- Edit OAuth 2.0 Client
- Add authorized redirect URI:
- Save and wait 5 minutes for propagation
Rate Limiting Issues
Rate Limiting Issues
Problem: AI features fail with 429 errors.Solution: Implement rate limiting:
-
Install Upstash Redis:
-
Add to API routes:
- Add Upstash environment variables to Vercel
Performance Monitoring
Monitor key metrics:Core Web Vitals
- LCP (Largest Contentful Paint): < 2.5s
- FID (First Input Delay): < 100ms
- CLS (Cumulative Layout Shift): < 0.1
API Response Times
Check Vercel Functions logs:
- tRPC calls: < 500ms
- AI chat: Streaming (1-3s)
- Vector search: < 200ms
Rollback Strategy
Instant Rollback
Vercel keeps all deployments:- Go to Deployments tab
- Find previous working deployment
- Click ⋯ → Promote to Production
- Instant rollback
Database Rollback
For schema changes:CI/CD Integration
GitHub Actions Example
Automate checks before deploy:Production Checklist
Before going live:Environment Variables
- All production variables set
- No development URLs/keys
- OAuth redirect URIs updated
- Database connection pooling enabled
Security
-
NEXTAUTH_SECRETis strong and unique - All API keys are production keys
- CORS configured if needed
- Rate limiting implemented
Performance
- Images optimized
- Bundle size checked
- Edge functions where appropriate
- Caching strategy verified
Custom Domain
Add your own domain:Scaling Considerations
Database
Supabase Limits:
- Free: 500 MB, 2 GB bandwidth
- Pro: 8 GB, 50 GB bandwidth
Vector Database
Pinecone Limits:
- Free: 1 index, 100k vectors
- Standard: Multiple indexes, unlimited vectors
File Storage
UploadThing Limits:
- Free: 2 GB
- Pro: 100 GB+
AI API Costs
Google Gemini Pricing:
- Input: $0.075 / 1M tokens
- Output: $0.30 / 1M tokens
Next Steps
Architecture
Review system architecture for optimization opportunities
Contributing
Learn how to contribute improvements
