Production Deployment Guide (Haven 2026)
Haven uses a distributed deployment model to ensure scalability and zero infrastructure costs in its beta phase.
🏠 Deployment Blueprint
Haven is deployed as two separate services:
- Next.js Application (Frontend + API Proxy)
- Matchmaking WebSocket Server (Microservice)
🖥️ Next.js App (Next.js 16)
Recommended Platform: Vercel or Render (Web Service)
- Framework:
Next.js 16 (App Router). - Node.js:
20.xor higher. - Build Command:
next build. - Output:
standalone(if using Docker/Render).
[!TIP] Environment Variables: Make sure to set
NEXT_PUBLIC_MATCHMAKING_WS_URLto point to your deployed WebSocket server (e.g.,wss://api-matchmaking-prod.render.com).
🛰️ Matchmaking Server (Websocket)
Recommended Platform: Render (Web Service) or Railway
Since this server maintains persistent WebSocket connections, it cannot be deployed as a serverless function (like Vercel Functions).
- Location:
matchmaking-server/. - Port:
8080. - Command:
npm run dev(for local) ornpm start(for production). - Heartbeat: The server expects a client-side heartbeat to prevent connection dropouts on Render's free tier.
🗄️ Database & Services (Supabase + Upstash)
-
Supabase:
- Auth: Configure redirect URLs to your production domain.
- Postgres: Ensure all migrations from
scripts/have been applied. - Realtime: Used for Sangha-wide broadcasts (ensure "Realtime" is enabled on
study_roomstable).
-
Upstash Redis:
- Create a global Redis instance.
- Disable TLS if your hosting provider doesn't support it (though Upstash usually defaults to TLS).
- Set the
60 requests per minuteglobal rate limit inmiddleware.ts.
-
LiveKit:
- Deploy your own LiveKit instance or use LiveKit Cloud.
- Ensure the
NEXT_PUBLIC_LIVEKIT_URLis set towss://....
🚦 Deployment Checklist
- [ ] Applied all SQL migrations to the production database.
- [ ] Set
NODE_ENVtoproduction. - [ ] Verified
NEXT_PUBLIC_MATCHMAKING_WS_URLuseswss://on production. - [ ] Configured
MIDDLEWARE_SECRETto match between Next.js and WS Server. - [ ] Enabled IP Hashing in
middleware.tsfor GDPR compliance. - [ ] Tested the
Cold Startbehavior of the matchmaking server (Render free tier).
Created by the Antigravity Ops Team.