Start a Cloudflare backend
On this page 5 sections
Maintainers can separately rehearse a disposable rollout, including missing setup assets, code rollback and class-lifecycle forward repair. This is optional tooling; adopters choose their own deployment checks.
npx @notabenda/cloudflare init creates a Worker project with a SQLite-backed Durable Object, the evidence admin and setup assets. Authentication comes from your application. The generated hook denies all access until you implement it.
The packages are currently unpublished developer previews. Build/pack them from this repository and install their local tarballs first. The installed CLI is then available as npx --no-install notabenda-cf.
npx @notabenda/cloudflare init --out-dir ./privacy-backend \
--name example-evidence --site-id example-site --base-path /backoffice
The output directory must not exist; its parent must already exist. Existing files and symlinks are never replaced. Initialization reads the bundled templates and writes a new local project. It performs no network call, package installation, login, resource creation or deployment. A write failure leaves its partial new directory for inspection rather than deleting files automatically.
Where the backend fits
Technical architecture and storage
Where the software and records live
The frontend can stand alone. Add a recording backend when the selected workflow needs durable evidence; the adopter supplies authorization and operations.
Your build
Reviewed inputs → pinned output
Visitor browser
Information, controls and local state
Optional host backend
Authorize before reaching storage
The build serves public assets to the browser. Configured host transports connect selected actions to scoped backend recording.
Browser preferences are distinct from durable evidence. Public documents, private archives and operator access have different boundaries. Recording, scheduling, delivery and retention require explicit host integration.
For the purpose of each legal document or control, start with the compliance map.
What you edit
src/settings.mjs: public site ID, admin path and workspace label.src/authorize.mjs: your existing authentication/session policy. Return explicit inspection, configuration, export and private-source permissions, ornull. No login, cookie/token format, key or identity provider is supplied.src/workspace.mjs: fixed-scope store composition and trusted application integrations.wrangler.json: Worker entry, assets, private binding and SQLite class declaration. Add your own account/routing/environment decisions when ready.
The generated README explains local tarball installation while the packages remain unpublished. After installing both packages and the declared build tools:
npm run doctor # Read-only local starter checks; manual acceptance remains.
npm run check # Build setup assets and perform a local Wrangler dry run.
npm run dev # Local Worker using the same host authorization policy.
npm run deploy # Explicit remote deployment through your Cloudflare account.
Only the last command deploys. Initialization runs none of these commands. The read-only doctor reports local blockers and separate manual reviews. It runs no build or deployment. There is no notabenda-cf deploy wrapper. Use Wrangler's existing account, routing and environment controls; adopters decide whether to connect their project to CI.
Access and data flow
The host checks authorization before any protected assets or namespace access. Setup and its static assets need configuration permission; evidence exports need a separate export permission. Private MD/MDX source inspection requires an explicit source: true grant; ordinary metadata inspection excludes its source hook. Forged headers, query parameters and URL paths cannot choose a site/object or grant either permission. The configured site chooses the object's stable name. Keep its identity/class/binding stable for existing data and plan any migration deliberately.
The admin provides history, cookie choices, terms agreements, processing opt-outs, form permissions, contract declarations and guided setup. Evidence starts empty. Setup uses the same six-stage local questionnaire; answers/imports stay in the tab until downloaded. Its private report is not written into the Durable Object.
Trusted host code can call the private object's recordRelease method with a compiled public artifact or private MD/MDX archive for the configured site. The package validates the artifact and retains immutable history. Recording does not publish or activate a document. Other trusted recording/activation helpers can be integrated inside the object as application work. This starter exposes no public write, arbitrary-object, deletion or anonymous identity endpoint.
The private inspect RPC receives only the permission already resolved by the host. Protect any service/namespace binding callers with your own policy. Do not turn it into a public generic RPC dispatcher or pass a browser-supplied grant through to it.
Build dependencies
The generated private npm manifest pins Miniflare's Undici client to 7.30.1 through a scoped override. Keep that override when installing the starter: the pinned Wrangler toolchain otherwise selects an affected version. This concerns local build/development tooling, not a new Worker or visitor dependency. See the dependency verification for upstream advisories and checks.
Deployment and removal
The generated Wrangler configuration declares assets with run_worker_first and a private object binding. Its Durable Object class export uses SQLite storage; it does not mix the current declarative flow with legacy migration declarations. Package adapters use the asynchronous key/value API on SQLite-backed storage.
Remote deployment can provision a Worker and namespace. Keep staging and production explicit. Host code owns authorization, origin/session defenses for any added writes, rate limits, data retention/holds/erasure, backups, restored-data barriers, logs and downloaded copies. No universal retention or data-location guarantee is chosen by the scaffold.
Removing the mount/routes stops serving the integration; uninstalling packages or deleting the local project does not remove remote records. Preserve required archives and evidence first. Deleting a Cloudflare namespace is a separate destructive operation governed by the current provider procedure; the CLI never performs it.
For optional maintainer runtime verification, build the workspace and run node scripts/check-cf-starter-runtime.mjs. It uses a disposable loopback Worker, verifies default denial, substitutes fictional host permissions only in that test copy, checks private archive RPC and restarts against the same SQLite state. Its recovery rehearsal also restores a pre-erasure KV snapshot into a different local object, replays a later retirement before opening it and checks preserved records and private source bytes. It stops its own server and retains the ignored fixture for inspection. This is optional project tooling; adopters choose their own CI.
See the CF API, scope decisions, deployment feature status and verification.
Setup starts with the reusable pack library. Its module and both stylesheets require the host configuration permission; the questionnaire and imports stay in the operator tab. The local doctor checks all generated setup and preview assets.
The page reader is built as assets/setup-preview.mjs and loaded when an operator requests a preview. It requires the same configuration permission as setup; the local doctor checks its presence.
The starter also exposes Recording setup under its existing inspection authorization. It starts with no readers. In the generated Worker constructor, supply fixed host-owned recordingTargets to createWorkspace; no request can select a site or object. The overview link does not inspect selections until the operator opens that page.
For a complete application-owned cookie recording connection, see the recorded-cookie application. Its separate denying visitor/operator hooks, explicit notice registration/activation and required browser controls demonstrate the integration without adding a public ingestion policy to this starter.