HARTWELL_LABS

Backend & Monetization

Novactorio's backend is **Supabase** (auth, realtime, Postgres, storage) with **Stripe** payments handled by four **Deno Edge Functions**.

Backend & Monetization

Novactorio's backend is Supabase (auth, realtime, Postgres, storage) with Stripe payments handled by four Deno Edge Functions.

Services

ServiceRole
Supabase AuthAccounts, sessions (@supabase/supabase-js ^2.57)
Supabase RealtimeCo-op multiplayer: player positions + build actions
Supabase PostgresWorld snapshots, profiles, trades
Supabase StorageSave data / snapshot storage
StripeCheckout subscriptions (Starter/Premium) + trade fees
Deno Edge FunctionsPayment orchestration + webhooks

Database (supabase-schema.sql)

Key tables:

TablePurpose
profilesUser profiles; premium_tier updated by webhooks
world_snapshotsCloud saves (save_data payload)
trades / trade statePlayer-to-player trading

Edge functions (supabase/functions/)

FunctionPurpose
stripe-checkoutCreates a Stripe Checkout session for premium subscriptions (Starter/Premium)
stripe-webhookVerifies Stripe webhooks; updates profiles.premium_tier
trade-fee-checkoutCheckout for trade fee payments
trade-webhookConfirms trade fees and settles trades

Flow: premium subscription

Player clicks "Go Premium"
      β”‚
      β–Ό
stripe-checkout (Edge Function)
      β”‚  creates Checkout Session
      β–Ό
Stripe Checkout page (hosted)
      β”‚  payment success
      β–Ό
stripe-webhook (Edge Function, signature-verified)
      β”‚  updates profiles.premium_tier
      β–Ό
Player has premium benefits

Flow: player trading

Player A initiates trade with Player B
      β”‚
      β–Ό
trade-fee-checkout (Edge Function)
      β”‚  fee payment processed
      β–Ό
trade-webhook (Edge Function)
      β”‚  settles trade, transfers assets
      β–Ό
Both players receive items

Co-op multiplayer

Supabase Realtime broadcasts:

  • Player positions β€” live movement of other players
  • Build actions β€” place/remove events replicated to all clients

Cloud saves

World snapshots are backed up to Supabase:

  • world_snapshots.save_data holds serialized world state
  • Restorable from the game's save/load UI

Environment variables

VariablePurpose
VITE_SUPABASE_URLSupabase project URL
VITE_SUPABASE_ANON_KEYSupabase anon (publishable) key
VITE_ADMIN_USERSComma-separated admin usernames
Stripe secret keysEdge function secrets (Stripe API + webhook signing)

Deployment

# Deploy edge functions
supabase functions deploy

# Deploy the game to Cloudflare
npm run deploy   # = npm run build && wrangler deploy

Configuration lives in wrangler.jsonc; Supabase CLI handles function deployments with per-function secrets.

On this page