Architecture
Plans and billing preview
The signed-in app's More page links to /billing: current commercial plan,
plan comparison from the platform database. Tenant invoices are queried and
displayed only for an authenticated ADMIN; participants and facilitators see
the plan summary without invoice documents. /billing/checkout
shows the selected plan's summary. Prices remain “on request” until approved
prices exist. Upgrade, payment-method and checkout actions are disabled. No
payment details are collected and no transaction is submitted.
The stable plan identifiers are core, pro, and agency. Pro includes custom
domain, email fallback and advanced automation entitlements. Agency adds white
label and multiple workspaces. These are plan policy records; existing product
features remain available as before this change. Inactive or expired entitlements
fail the new shared guard, and unknown plan or feature identifiers grant nothing.
Commercial metadata lives in the platform database, through the existing pg
connection helper. The additive migration is under
prisma/platform/migrations/20260930160000_billing_stub/. Run the existing
npm run db:platform:deploy command during the release migration gate.
The immutable migrator image includes both Prisma configuration files and both
migration histories. Its default command migrates the tenant database only.
The platform operator must run the same image with the command override
node ./node_modules/prisma/build/index.js migrate deploy --config prisma.platform.config.ts,
injecting PLATFORM_DATABASE_URL through the established operator secret path.
Do this once per platform database before activating billing. Do not grant the
tenant migration role access to the platform database or distribute its
credentials to tenant deployments.
No tenant database billing tables are added. A unique tenant scope and a partial
singleton index protect repeated or concurrent default-plan creation.
The runtime resolves billing scope from its trusted TENANT_ID environment,
after authenticating the caller. The legacy single-pilot deployment uses the
nullable scope. Requests cannot select another tenant through query parameters.
GET /api/billing returns only that scope's entitlement and, for admins only,
invoices and sends
private/no-store and no-index response headers. Other HTTP mutations are absent.
If the platform database is not configured, the page explains that state and
the API returns 503 BILLING_NOT_CONFIGURED.
If the platform connection is configured but billing migrations have not been
applied, the page remains an unavailable-state screen and APIs return sanitized
503 BILLING_UNAVAILABLE. Neither SQL nor connection/credential details are
returned. Billing becomes available once the operator applies the expansion.
The protected platform admin settings view retains a clearly labeled typed plan
catalog and separately loads aggregate entitlement counts per plan. Its
GET /api/platform/admin/billing endpoint uses the existing operator gate;
it exposes no tenant identities, invoice documents or payment credentials.
Real payments remain planned: no processor, wallet watcher, payment webhook, reconciliation, tax, refund or financial credential storage is implemented.
Explicit preview opt-in
The separately authorized SaaS demonstration at saas.feelcouch.tech may set the preview flag to true in its own deployment only. The friend project keeps the default off. This demonstration enables no real transactions or payment provider integration.
Billing is disabled by default. Only BILLING_PREVIEW_ENABLED=true enables the non-transacting preview; unset, false, uppercase or malformed values leave it disabled. Enable it only after explicit user agreement, never automatically in production. With preview off, More has no billing link, operator settings make no billing-count request, both billing pages and APIs return 404 before authentication or database access. The friend project and existing course features remain usable without any subscription, payment or entitlement requirement. Typed plans and future guards remain dormant for existing course access. Preview enablement does not enable real payments.