HavenDOCS
Back to Home

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:

  1. Next.js Application (Frontend + API Proxy)
  2. 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.x or higher.
  • Build Command: next build.
  • Output: standalone (if using Docker/Render).

[!TIP] Environment Variables: Make sure to set NEXT_PUBLIC_MATCHMAKING_WS_URL to 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) or npm start (for production).
  • Heartbeat: The server expects a client-side heartbeat to prevent connection dropouts on Render's free tier.

🗄️ Database & Services (Supabase + Upstash)

  1. 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_rooms table).
  2. 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 minute global rate limit in middleware.ts.
  3. LiveKit:

    • Deploy your own LiveKit instance or use LiveKit Cloud.
    • Ensure the NEXT_PUBLIC_LIVEKIT_URL is set to wss://....

🚦 Deployment Checklist

  • [ ] Applied all SQL migrations to the production database.
  • [ ] Set NODE_ENV to production.
  • [ ] Verified NEXT_PUBLIC_MATCHMAKING_WS_URL uses wss:// on production.
  • [ ] Configured MIDDLEWARE_SECRET to match between Next.js and WS Server.
  • [ ] Enabled IP Hashing in middleware.ts for GDPR compliance.
  • [ ] Tested the Cold Start behavior of the matchmaking server (Render free tier).

Created by the Antigravity Ops Team.