---
title: Projection Patterns
category: product
entity_type: skill
price: $15
canonical: https://forgehouse.ai/skills/projection-patterns/
lang: en
hreflang_alt: https://forgehouse.ai/tr/skiller/projection-patterns/
last_updated: 2026-06-20
---

# Projection Patterns

> Build read models and projections from event streams.

Build read models and materialized views from event streams for CQRS read sides, complete with checkpointing, idempotent handlers, and disposable rebuilds. It turns raw event history into fast, query-optimized tables, search indexes, and aggregates that survive crashes and can be reconstructed from scratch at any time. Every pattern ships with the transaction and monitoring discipline that keeps read models trustworthy under at-least-once delivery.

## Use cases
- CQRS read sides and materialized views
- Real-time dashboards from event data
- Search indexes built from events
- Daily and aggregate reporting tables
- Customer activity rollups across streams
- Rebuilding read models after schema changes

## Benefits
- Query-optimized read tables that need no JOINs at runtime
- Crash-safe recovery via persistent checkpoints
- Zero-downtime read model rebuilds from event history
- Duplicate events handled safely with idempotent handlers

## What’s included
- Base Projection class plus a continuous Projector with batch processing
- Checkpoint store for exactly-once and resume-after-restart
- Order summary, daily sales aggregate, and multi-table projection templates
- Elasticsearch full-text search projection
- Multi-table transactional updates inside one DB transaction
- Projection lag monitoring with WARN/CRITICAL/PAGE thresholds

## Who it’s for
Backend engineers building event-sourced systems who need fast, rebuildable read models without sacrificing data consistency.

## How it runs
A read model you cannot rebuild is a liability. Every projection is disposable by design, updated exactly once per event, and watched for lag down to the second.
1. One read model per query pattern: each UI or report need gets its own denormalized table (a flat order summary, a daily sales aggregate, a search index), instead of bending a single schema to serve every screen. New need means new projection, never a riskier rewrite of the existing one.
2. The projector loop runs continuously: read events from checkpoint plus one in batches, dispatch each by event type to its handler, apply to the read table, save the new checkpoint position.
3. Exactly-once where it matters: the read-model update and the checkpoint write share one database transaction. Where they cannot, handlers are made idempotent with event_id dedup checks and UPSERT, so a replayed event never double-increments a counter.
4. Multi-table updates stay atomic: when one event touches both a summary table and a history table, both writes sit in the same transaction. Cross-store projections (database plus search engine) go through an outbox instead.
5. Every projection is disposable by design: a rebuild path resets the checkpoint, truncates the read tables and replays the full stream, with a blue-green switch so the old data keeps serving queries during the rebuild.
6. Lag is watched, not hoped about: store position minus checkpoint is emitted as a metric per projection, with thresholds at 1 second warn, 5 seconds critical and 30 seconds page.

## FAQ
### Do I need a full event-sourcing setup before this is useful?
Yes, the patterns assume your source of truth is an event stream, since read models are built and rebuilt from event history. If you run a plain CRUD database with no events, there is nothing for a projection to consume.

### How do the projections survive crashes and duplicate events?
A persistent checkpoint store records the last processed position so a restarted projector resumes instead of reprocessing everything, and idempotent handlers make duplicate events under at-least-once delivery safe. Multi-table updates happen inside one DB transaction to stay atomic.

### Does it manage the event store or message broker itself?
No. It gives you the Projection base class, the continuous Projector with batch processing, and lag monitoring with WARN/CRITICAL/PAGE thresholds, but the event store and delivery infrastructure are yours to run.

## Price
$15, one-time, no subscription. VAT included.

Related guide: [AI for data analytics](https://forgehouse.ai/guides/ai-data-analytics/)
