Skip to content

ESDM — Tutorial

This is the tutorial part of the ESDM — Event-Sourced DDD guide. See also Short info and samples.

Know one command and the business fact that can follow it. Follow this as a conceptual/import walkthrough; no standalone ESDM canvas is required.

A command expresses an intention: ReserveSeat asks the system to do something. The operation can be accepted or refused according to the current state and rules. SeatReserved names a fact after a successful decision. Keeping these concepts separate prevents a model from treating a failed request as if it already changed the business.

An event history can supply the information needed to rebuild state. A read model organizes that information for a particular query, such as showing the remaining seats for a flight. The read model can be rebuilt from relevant history, but the rules for interpreting older events must remain understood as the system evolves.

Follow reactions without hiding side effects

Section titled “Follow reactions without hiding side effects”

A policy can react to SeatReserved by requesting payment or confirmation. A process manager may track a longer interaction and request a compensating action if a later step fails. Compensation records another meaningful action; it does not erase the fact that the first operation occurred.

This design raises operational questions. Replaying an event into a projection is different from sending another confirmation email. Duplicate delivery needs a stated handling strategy. A new event shape needs an evolution policy. The model helps expose those questions and makes the expected relationships reviewable. Importing a valid ESDM file checks a representation; proving replay safety, delivery behavior or recovery requires an implementation and an appropriate runner.

From an intention to a fact to a read model. A command card reaches a rule boundary; an event joins a history; a small availability view updates from that event.

Pause and predict: Which part may be rebuilt from history without charging the customer again?

This is the text storyboard for a proposed short illustrated film. The written walkthrough and exercises are available now; a published movie will be added after its scenes, captions and model references have been reviewed.

ESDM’s canonical file is .esdm.yaml — the import and export are a lossless round-trip (process-manager handles, emits, and compensations included), with deterministic output. Structural and referential integrity is checked by ctxbrew lint-esdm. The per-format toolkit applies: ctxbrew esdm validate|export|import|stats|diff. Details: Import & Export.