Overview
This guide covers deploying Resonance to production environments. The application is designed to run on any Node.js 20+ hosting platform.Before starting, complete the prerequisites and have all required service accounts ready.
Modal Setup
The TTS inference engine must be deployed to Modal before deploying the Next.js application.1. Install Modal CLI
2. Configure R2 Credentials
Updatechatterbox_tts.py with your R2 bucket information:
chatterbox_tts.py
3. Create Modal Secrets
Create three secrets in your Modal dashboard:cloudflare-r2
R2 API credentials for bucket mounting.
R2 uses S3-compatible API, so the keys are named
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.hf-token
Hugging Face token for downloading Chatterbox model weights.Get your token from Hugging Face settings.
4. Deploy to Modal
Understanding the Modal Deployment
Understanding the Modal Deployment
The
chatterbox_tts.py script deploys:- GPU container: NVIDIA A10G (configured at
chatterbox_tts.py:84) - Model: Chatterbox TTS v0.1.6 with Turbo architecture
- Scale-down window: 5 minutes of inactivity before GPU is released
- Max concurrent: 10 requests can be processed simultaneously
- R2 mount: Read-only access to your audio bucket at
/r2
/generate with voice cloning parameters.5. Test the Endpoint
Verify the deployment works:test.wav file with generated audio.
6. Generate API Types
After deploying Modal, generate the TypeScript client:src/types/.
Railway Deployment
Railway provides one-click deployment with built-in database and automatic HTTPS.Quick Deploy
Fork the Repository
Fork resonance to your GitHub account.
Create Railway Project
- Go to Railway and create a new project
- Select “Deploy from GitHub repo”
- Choose your forked repository
- Railway will detect Next.js automatically
Add PostgreSQL
- Click “New” → “Database” → “Add PostgreSQL”
- Railway automatically sets
DATABASE_URLenvironment variable - The Prisma adapter connects automatically
Configure Build Settings
Railway auto-detects Next.js, but verify:
- Build command:
npm run build - Start command:
npm run start - Watch paths: Leave default (triggers rebuild on push)
Railway provides a free tier with 5/month + usage).
Docker Deployment
For self-hosted environments, use Docker with a custom Dockerfile.Create Dockerfile
CreateDockerfile in your project root:
Dockerfile
Update next.config.ts
Enable standalone output:next.config.ts
Build and Run
Docker Compose
For local development with database:docker-compose.yml
Other Platforms
Vercel
- Import project from GitHub
- Add environment variables
- Deploy automatically on push
Generic Node.js Host
Any platform supporting Node.js 20+ works:Post-Deployment Steps
Verify Modal Connectivity
Test the connection from your app to Modal:
- Sign in to your deployed application
- Navigate to Text-to-Speech
- Generate a sample with any system voice
- Check browser console and server logs for errors
Test R2 Storage
Verify audio uploads work:
- Clone a voice or record a new one
- Check R2 bucket for
voices/custom/<id>object - Generate TTS with the custom voice
- Verify playback works
Configure Webhooks
If using Polar billing:
- Set webhook URL:
https://yourdomain.com/api/webhooks/polar - Enable events:
checkout.completed,subscription.updated - Test with sandbox mode checkout
Next Steps
Troubleshooting
Encountering issues? Check common problems and solutions