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 tono-reply@commitmentdesk.com. - 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 protected Deploy hosted app workflow from main, or run the equivalent commands:
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 productionThe workflow requires the production environment and a typed confirmation. It records the commit
and migration result, deploys the Worker and assets, and runs the synthetic smoke check.
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 uses no client data:
CD_SMOKE_API_URL=https://app.commitmentdesk.com pnpm smoke:hostedA failed smoke check blocks the deployment’s success signal.
Monitoring
Section titled “Monitoring”Production runs with Workers observability enabled. The scheduled health workflow checks
/v1/health, recent 5xx responses, webhook delivery failures, and storage growth, and opens or updates
an operator issue on sustained failure. 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”- D1 supports Time Travel and export. Export before risky migrations.
- Enable R2 object versioning or replication and keep the bucket private.
- Rehearse restore into staging and run the smoke test against the restored environment before accepting client data.
Rollback
Section titled “Rollback”- Stop the deployment before traffic switches if a migration fails.
- Roll back to the previous Worker version from the Cloudflare dashboard or
wrangler rollback. - 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 scripts/seed-remote.mjs with the target environment to create a normal synthetic demo tenant and
explicit demo memberships. Keep the generated API key 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.