Hosted deployment
The hosted application runs on Cloudflare Workers with D1, R2, static web assets, and Cloudflare Email
Service. The application and API are served same-origin at https://app.commitmentdesk.com, with the
API under /v1. The public documentation site at https://commitmentdesk.com is deployed separately;
see documentation site.
Deployment is manual and owner-approved. Pull-request CI has no production credentials and cannot deploy.
Environments and resources
Section titled “Environments and resources”| Environment | Worker | D1 database | R2 bucket | Host |
|---|---|---|---|---|
| Development | local Wrangler | local D1 | local R2 | http://localhost:8787 |
| Staging | commitment-desk-api-staging |
commitment-desk-staging |
commitment-desk-attachments-staging |
https://app-staging.commitmentdesk.com |
| Production | commitment-desk-api |
commitment-desk |
commitment-desk-attachments |
https://app.commitmentdesk.com |
inbox.commitmentdesk.com is a permanent redirect to the application host and preserves path and
query. See ADR 0011.
Prerequisites
Section titled “Prerequisites”- Cloudflare Workers Paid, which is required for arbitrary email recipients and included D1/R2 usage.
- An account-owned Cloudflare API token scoped to
commitmentdesk.comwith Workers Scripts, Workers Routes, Workers R2 Storage, D1, Cloudflare Pages, Email Sending, DNS, SSL and Certificates, Zone Settings, Single Redirect, and read/analytics permissions. - The GitHub
productionenvironment withCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDsecrets. - Cloudflare Email Service onboarding for
commitmentdesk.com. See email delivery.
Never commit the token. Store it in the password manager and the protected GitHub environment.
Provisioning
Section titled “Provisioning”Create remote resources once per environment:
pnpm --filter @commitment-desk/api exec wrangler d1 create commitment-desk-stagingpnpm --filter @commitment-desk/api exec wrangler d1 create commitment-deskpnpm --filter @commitment-desk/api exec wrangler r2 bucket create commitment-desk-attachments-stagingpnpm --filter @commitment-desk/api exec wrangler r2 bucket create commitment-desk-attachmentsPut the returned D1 ids into the matching env.staging and env.production blocks in
apps/api/wrangler.jsonc. Keep the staging and production ids distinct.
Configuration
Section titled “Configuration”Each Wrangler environment sets:
ENVIRONMENT=productionso session cookies areSecureandHttpOnly.WEB_BASE_URLto the environment’s own HTTPS origin.EMAIL_FROM,EMAIL_FROM_NAME, andEMAIL_REPLY_TO.- The
send_emailbinding restricted to[email protected]. - The environment’s D1 and R2 bindings.
- Workers Static Assets from
apps/web/dist, with/v1and/v1/*routed to the Worker first.
The Worker has no application secret bindings: sessions are random tokens stored hashed in D1, and API keys and webhook secrets are generated per tenant.
Migrations
Section titled “Migrations”Build the web app first, then apply migrations before deploying the Worker:
pnpm --filter @commitment-desk/web buildpnpm --filter @commitment-desk/api exec wrangler d1 migrations apply DB --remote --env stagingpnpm --filter @commitment-desk/api exec wrangler d1 migrations apply DB --remote --env productionMigrations are ordered by filename in infra/cloudflare/migrations. A failed migration stops the
deployment before traffic switches; fix forward or restore the previous Worker version as described
under rollback.
Deploy
Section titled “Deploy”Use the manual Deploy hosted app workflow from main. Choose staging or production, type
deploy, and approve the production environment if the repository plan supports required reviewers.
The workflow builds the web assets, applies migrations, deploys the Worker and assets, records the
commit and Worker version, seeds the synthetic demo tenant, and runs the smoke check.
The equivalent operator commands are:
pnpm --filter @commitment-desk/web buildpnpm --filter @commitment-desk/api exec wrangler d1 migrations apply DB --remote --env productionpnpm --filter @commitment-desk/api exec wrangler deploy --env productionPull-request CI does not have deployment credentials and cannot deploy. The workflow is the only automated path to production.
Hosts and redirect
Section titled “Hosts and redirect”app.commitmentdesk.comis a Worker custom domain attached by Wrangler.app-staging.commitmentdesk.comis the staging custom domain.inbox.commitmentdesk.comhas a proxied placeholder DNS record and a Cloudflare Single Redirect rule tohttps://app.commitmentdesk.com, preserving path and query.commitmentdesk.comis owned by the documentation Pages project, not the Worker.
Verify:
curl -fsS https://app.commitmentdesk.com/v1/healthcurl -fsSI https://inbox.commitmentdesk.com/some/path?q=1The redirect must return a 301 to https://app.commitmentdesk.com/some/path?q=1.
Smoke test
Section titled “Smoke test”The smoke script verifies health, reviewer session, capture submission, parcel review, export, and a signed webhook delivery against a dedicated synthetic tenant. It mints short-lived operator sessions directly in D1 and removes them afterwards; it does not send magic-link email.
node scripts/seed.mjs --remote --env stagingSMOKE_WEBHOOK_URL=https://example.com/webhook pnpm smoke:hosted:stagingnode scripts/seed.mjs --remote --env productionSMOKE_WEBHOOK_URL="$SMOKE_WEBHOOK_URL" pnpm smoke:hosted:productionThe Deploy hosted app workflow passes SMOKE_DEMO_API_KEY and the SMOKE_WEBHOOK_URL repository
variable to the same scripts. If SMOKE_WEBHOOK_URL is unset, the webhook portion is skipped with a
warning; production deployments should keep it set to a receiver that verifies the
X-CommitmentDesk-Signature header.
Monitoring
Section titled “Monitoring”.github/workflows/hosted-health.yml runs every fifteen minutes and on demand. It checks
/v1/health, recent Worker errors from Cloudflare analytics, final webhook failures in the last hour,
and upload bytes in the last day. A failure opens or updates a Hosted deployment health alert issue
labeled ops-alert; recovery comments and closes it.
Workers observability is enabled in every environment. Logs identify tenant and request identifiers where appropriate and never contain capture payloads, attachment contents, tokens, or credentials.
Backups and restore
Section titled “Backups and restore”Before a risky migration, export the database:
pnpm --filter @commitment-desk/api exec wrangler d1 export commitment-desk --remote --env production --output backup.sqlD1 Time Travel provides point-in-time restore for the recent window. Keep R2 object versioning or replication enabled, keep the bucket private, and rehearse a restore into staging before accepting client data. After a restore, run the smoke check against the restored environment.
Rollback
Section titled “Rollback”-
Stop the deployment before traffic switches if a migration fails.
-
Roll back to the previous Worker version:
Terminal window pnpm --filter @commitment-desk/api exec wrangler rollback --env production -
Do not drop production tables. Fix forward with a new migration when possible.
-
Re-run the smoke check and record the incident and version.
Synthetic demo organization
Section titled “Synthetic demo organization”Use the remote seed command with the target environment to create or refresh a normal synthetic demo tenant and explicit demo memberships:
CD_DEMO_API_KEY="$SMOKE_DEMO_API_KEY" node scripts/seed.mjs --remote --env productionThe generated API key is written to .remote-demo-<environment>.json (gitignored) or supplied through
CD_DEMO_API_KEY; keep it in the secret manager, never in the repository. Demo data is isolated by
tenant and contains no real taxpayer information. A public demo host with automated reset remains a
separate change.