Skip to content
indexwire

Event sourcing on Cloudflare, end to end

Why we run CQRS and event sourcing entirely on Workers and Durable Objects, and how the pieces fit together.

cqrsevent-sourcingcloudflare

This is a placeholder article. The content layer parses this frontmatter against a Zod schema, so a missing title or a malformed pubDate fails the build rather than shipping a broken page.

Every article route also emits a .md sibling (/articles/hello-cqrs.md) and is indexed in /llms.txt, so crawlers that do not execute JavaScript get the source directly.

Frequently asked questions

Why keep every event instead of just the current state?

Because the current state is derivable and the events are not. Once a fact is recorded it stays recorded, so a change to how we interpret those facts is a recomputation over data we already hold rather than a fresh round of collection.

What is a Durable Object doing in this design?

It gives a single stream one authoritative writer. Commands for an aggregate route to its own Durable Object, which decides them in order against the stream it owns — which is what makes an append-only log safe to write to concurrently.

Does the browser talk to the database directly?

No. The browser holds a local event store and projects its own read models, then syncs the log. Client-tier commands execute optimistically and replicate; server-tier commands are decided authoritatively on the server.