Overview
Resonance is a full-stack Next.js application that requires several cloud services to operate. This guide covers the prerequisites and architecture considerations for deploying to production.Architecture
Resonance consists of three main components:Next.js App
The web application (SSR + API routes)
PostgreSQL Database
Stores voices, generations, and metadata
Modal GPU Inference
Serverless TTS engine with voice cloning
Prerequisites
Required Services
Before deploying, you’ll need accounts and configuration for:Node.js Runtime
Node.js 20.9 or later is required. The application uses Next.js 16 with React 19 and server components.
PostgreSQL Database
A managed PostgreSQL database with the connection string ready.Recommended: Prisma Postgres for built-in connection pooling.Alternatives: Any managed Postgres provider (Railway, Supabase, Neon, etc.)
Cloudflare R2
S3-compatible object storage for audio files.Required credentials:
- Account ID
- Access Key ID
- Secret Access Key
- Bucket name
R2 offers 10GB free storage and zero egress fees, making it ideal for audio hosting.
Modal Account
Serverless GPU platform for the TTS inference engine.What you need:
- Modal CLI installed (
pip install modal) - Modal account with billing enabled
- Three secrets configured (see Self-Hosting)
Clerk Authentication
User authentication with Organizations support.Configuration:
- Enable Organizations in your Clerk dashboard
- Set up sign-in/sign-up pages
- Configure allowed authentication methods
- Copy API keys to environment variables
Environment Variables
The application validates environment variables using@t3-oss/env-nextjs. All required variables must be present at build time.
Build Requirements
Build Process
The application uses Next.js production build with these characteristics:Build Steps
Build Steps
- Dependency installation -
npm installrunspostinstallscript which generates Prisma client - Environment validation - All required env vars are validated at build time
- Next.js build - Creates optimized production bundle with SSR
- Sentry integration - Uploads source maps if
CIenv var is set
Build Configuration
Build Configuration
The
next.config.ts includes:- Sentry integration for error monitoring
- Proxy max body size set to 20MB for audio uploads
- Disabled dev indicators for cleaner production UI
- Source map uploads (silent unless in CI)
- Automatic Vercel Cron Monitors support
Database Migrations
Prisma migrations must be applied before the application starts.The seed script uploads 20 system voice WAV files to R2 and creates database entries. This only needs to run once per environment.
Deployment Checklist
Service Setup
- PostgreSQL database provisioned
- Cloudflare R2 bucket created
- Clerk application configured
- Modal secrets created
- Polar product configured (if using billing)
Deploy Modal TTS
- Update
chatterbox_tts.pywith R2 credentials - Run
modal deploy chatterbox_tts.py - Test endpoint with curl
- Copy endpoint URL to
CHATTERBOX_API_URL
Configure Environment
- All required env vars set on hosting platform
- Production URLs configured
- Secrets properly secured (not committed)
Database Setup
- Run
npx prisma migrate deploy - Run
npx prisma db seed - Verify 20 system voices created
Deploy Application
- Push code to hosting platform
- Build succeeds with no errors
- Application starts and responds to health checks
Next Steps
Self-Hosting Guide
Step-by-step deployment instructions for Railway and Docker
Troubleshooting
Common issues and solutions for Modal cold starts, R2, and more