BILLING PLATFORM ✦ STATE MACHINES
machina
A billing platform built on state machine instances. Every subscription, invoice, and payment lifecycle is an independently addressable state machine — running on Durable Objects, orchestrated by Workflows, projected into D1.
An interactive billing simulation built on SAO state machines. Advance the clock, trigger invoices, fail payments, and watch subscriptions degrade…
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.
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.
Globally unique identity. Single-threaded execution. Co-located SQLite storage. Alarms for scheduled transitions. One DO per billing resource.
Exactly-once step execution. Automatic retry with backoff. Event waiting up to one year. Spans Stripe, email, entitlements.
Buffer incoming webhooks and API calls. Batch delivery to consumer Workers. Dead letter queues for failed processing.
SQL queries across all state machines. Revenue by plan. Accounts in dunning. The queryable projection of distributed state.
State is derived from the outcome chain. Transitions are validated before persisting. Side effects are durable. The machine is the truth.