SA-301a · Module 2

Projection Design

3 min read

Projections are the mechanism that transforms events into read models. A projection subscribes to an event stream, processes each event, and updates a materialized view optimized for a specific query pattern. The design of projections determines the read performance, the rebuild capability, and the operational complexity of the CQRS system. A well-designed projection is idempotent, rebuildable, and independently deployable.

Do This

  • Design every projection to be idempotent — processing the same event twice produces the same result
  • Build every projection with a rebuild capability — drop the read model and replay from the event store
  • Deploy projections independently — adding a new read model should not require changes to the command side

Avoid This

  • Assume projections will only process each event once — at-least-once delivery means duplicates happen
  • Build projections that cannot be rebuilt — the first data corruption will require a manual recovery
  • Couple projection deployment to the command model — the two sides should evolve independently