← Lessons

quiz vs the machine

Gold1400

System Design

The Read Model Projection

Turning a stream of events into a query friendly view built for one job.

5 min read · core · beat Gold to climb

Views built from events

A projection is a process that reads events and writes them into a read model, a data shape optimized for a specific query. Instead of one general store, you build many narrow views, each answering one kind of question fast.

How a projection runs

  • It subscribes to one or more event streams.
  • For each event it applies a small handler that updates the view, such as incrementing a counter or upserting a row.
  • It tracks a position so it knows where to resume after a restart.

Why projections help

  • Fast reads because the view is already shaped for the query.
  • Many views from one source since the same events feed different projections.
  • Disposable because a broken view can be dropped and rebuilt by replaying events.

Things to watch

Projections are usually eventually consistent, lagging the writes by a small amount. Handlers must be idempotent so reprocessing an event does not double count.

Key idea

A projection folds events into a purpose built read model, giving fast queries and views you can drop and rebuild at will.

Check yourself

Answer to earn rating on the learn ladder.

1. What is a read model projection?

2. Why must projection handlers be idempotent?