projection-patterns

Build read models and projections from event streams for CQRS systems.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill projection-patterns-sanketadlak
Or copy as Structured Prompt for Agentā–¼
Please help me install this Agent Skill.
Skill: projection-patterns
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/projection-patterns
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill projection-patterns-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Event-sourced systems store data as append-only event streams, which are inefficient for querying. This Skill provides templates and patterns for building projections that transform event streams into queryable read models, materialized views, and search indexes. ## Core Features & Use Cases - Projection Templates: Ready-to-use Python templates for basic projectors, order summaries, Elasticsearch search indexes, daily sales aggregations, and multi-table customer activity projections. - Checkpointing & Rebuilds: Patterns for persistent checkpoints so projections resume after restarts and can be rebuilt from scratch. - Use Case: Imagine you run an event-sourced e-commerce platform and need a real-time dashboard of daily revenue. Use the aggregating projection template to consume OrderCompleted events and maintain a daily_sales table with upsert logic. ## Quick Start Ask the AI to create a projection that builds a customer order summary read model from OrderCreated and OrderCompleted events using the projection-patterns skill.

Frequently Asked Questions about projection-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a read model from an event stream?ā–¼

Define a Projection class with a name, a list of handled event types, and an apply method that updates your read model tables. A Projector then reads events from the event store in batches, dispatches them to matching handlers, and saves checkpoints after each event.

How to project events into Elasticsearch for full-text search?ā–¼

Create a projection that handles product or document events and calls the Elasticsearch index, update, or delete APIs per event type. Use the event's entity ID as the document ID so updates and deletes target the correct document.

What is the difference between live, catchup, and persistent projections?ā–¼

Live projections process events in real time from a subscription for current-state queries. Catchup projections process historical events to rebuild read models. Persistent projections store checkpoints so they can resume from the last processed position after a restart.

How do I rebuild a projection from scratch in event sourcing?ā–¼

Delete the projection's stored checkpoint, optionally clear its read model tables, then rerun the projector from position zero with a larger batch size. This replays all historical events through the projection handlers to reconstruct the read model.

Why must event projections be idempotent?ā–¼

Projections must be idempotent because events can be replayed during rebuilds or redelivered after failures, and applying the same event twice must not corrupt the read model. Use upserts, unique constraints, and version checks to make handlers safe to replay.

When should I not use an inline projection?ā–¼

Avoid inline projections, which update the read model in the same transaction as the write, when read model updates are slow or target external systems like Elasticsearch. Inline projections add latency to writes and couple availability of the read side to the write path.