Self-hosting
Cloud API is two deployables sharing one Supabase database: a backend control plane and a Vercel frontend.
Architecture
- backend/ — a Fastify API (the control plane). Long-running; runs the billing loop and talks to the hosting panel. Deploy to Railway, Fly.io, Render or any VPS.
- frontend/ — a Next.js app (dashboard + docs). Deploy to Vercel. Talks to the backend through a server-side proxy that attaches the Clerk session token.
- Supabase — shared Postgres. The backend uses the service-role key; both apps point at the same project.
- Clerk — auth for both, plus the API Keys feature.
1. Database
Run schema.sql in the Supabase SQL editor. It creates all required tables and is safe to re-run.
2. Clerk
- Create a Clerk application; copy the publishable and secret keys.
- Enable API Keys under Configure → API Keys.
- Add your Vercel domain to allowed origins.
3. Backend
bashcd backend cp .env.example .env # fill in Clerk, Supabase, ADMIN_EMAILS, Stripe npm install npm run build npm start # listens on :8080
Set CORS_ORIGINS to your frontend origin and CLOUD_API_PUBLIC_URL to the API's public URL.
4. Frontend (Vercel)
bashcd frontend cp .env.example .env.local # set CLOUD_API_URL to the backend URL, plus Clerk + Supabase keys vercel deploy
5. Billing
Keep BILLING_LOOP=true to run metering in-process every 15 minutes. To bill from an external scheduler instead, set it to false and call:
bashcurl -X POST https://api.cloud.enzonic.com/internal/bill \ -H "x-internal-secret: $INTERNAL_SECRET"
6. Add a panel
Sign in with an admin email, open /admin, and register your first hosting instance. You're live.