A fully interactive billing simulation running entirely in the browser. Every button triggers a real SAO state machine transition.

Five new Gutenberg block types that compose an interactive billing dashboard from declarative YAML.

State machines where state is derived from history, not stored independently.

Every subscription is a Durable Object. The outcome chain lives in co-located SQLite. State is derived by replay.

API Layer REST webhooks INGRESS
Queues event buffer dead letter DELIVERY
Durable Objects subscription invoice payment STATE MACHINES
Workflows charge provision notify SIDE EFFECTS
D1 projections queries READ MODEL
R2 invoices receipts DOCUMENTS
KV plans idempotency CACHE
enqueue events route by ID side effects project state store documents idempotency

Each billing resource — subscription, invoice, payment intent — is a Durable Object with its own SQLite store. State transitions are serialized. Side effects are durable. The read model is eventually consistent. The state machine is the source of truth.

Subscription

activepast_dueunpaidcanceled. Alarms drive trial expiration, period advance, and dunning escalation.

Invoice

draftopenpaid | void | uncollectible. Finalization triggers payment via Workflow. Credit notes adjust without mutation.

Payment

requires_pmrequires_confirmationprocessingsucceeded | failed. Gateway-agnostic confirm-then-settle model.

Durable Objects
State machine instances

Globally unique identity. Single-threaded execution. Co-located SQLite storage. Alarms for scheduled transitions. One DO per billing resource.

Workflows
Durable side effects

Exactly-once step execution. Automatic retry with backoff. Event waiting up to one year. Spans Stripe, email, entitlements.

Queues
Event delivery

Buffer incoming webhooks and API calls. Batch delivery to consumer Workers. Dead letter queues for failed processing.

D1
CQRS read model

SQL queries across all state machines. Revenue by plan. Accounts in dunning. The queryable projection of distributed state.