Skip to content
Skillpedia
APIs & servers (backend)41k Β· #6640

projection-patterns

What it does

This tool helps organize past event information so you can query it quickly. It creates optimized 'views' of your data.

When to use it

  • βœ“When you need to see the current state of things in real-time.
  • βœ“When rebuilding information from an event history.
  • βœ“To make data queries faster and more efficient.

Skill link

https://github.com/wshobson/agents/blob/main/plugins/backend-development/skills/projection-patterns/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/wshobson/agents/blob/main/plugins/backend-development/skills/projection-patterns/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œHow can I create an optimized view of my sales data from transaction events?”

5 new skills a week. 1 minute to read.

How it works

It works by taking a sequence of events (like records of actions) and processing them to create a simpler, more direct data model. This model is then used to answer questions quickly.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Projection Patterns

Comprehensive guide to building projections and read models for event-sourced systems.

When to Use This Skill

  • Building CQRS read models
  • Creating materialized views from events
  • Optimizing query performance
  • Implementing real-time dashboards
  • Building search indexes from events
  • Aggregating data across streams

Core Concepts

1. Projection Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Event Store │────►│ Projector   │────►│ Read Model  β”‚
β”‚             β”‚     β”‚             β”‚     β”‚ (Database)  β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚     β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Events  β”‚ β”‚     β”‚ β”‚ Handler β”‚ β”‚     β”‚ β”‚ Tables  β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚     β”‚ β”‚ Logic   β”‚ β”‚     β”‚ β”‚ Views   β”‚ β”‚
β”‚             β”‚     β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚     β”‚ β”‚ Cache   β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

2. Projection Types

Type Description Use Case
Live Real-time from subscription Current state queries
Catchup Process historical events Rebuilding read models
Persistent Stores checkpoint Resume after restart
Inline Same transaction as write Strong consistency

Templates and detailed worked examples

Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.

Best Practices

Do's

  • Make projections idempotent - Safe to replay
  • Use transactions - For multi-table updates
  • Store checkpoints - Resume after failures
  • Monitor lag - Alert on projection delays
  • Plan for rebuilds - Design for reconstruction

Don'ts

  • Don't couple projections - Each is independent
  • Don't skip error handling - Log and alert on failures
  • Don't ignore ordering - Events must be processed in order
  • Don't over-normalize - Denormalize for query patterns
FAQ

What are 'events'?

Events are records of something that happened in the past, like 'user signed up' or 'order was placed'.

What is a 'read model'?

It's an organized way of viewing data, made specifically for answering questions, different from how the data was originally recorded.

Why 'optimize performance'?

So the system responds faster to your queries, even with a lot of data, avoiding slowdowns.

Details

Original description by the author

Build read models and projections from event streams. Use when implementing CQRS read sides, building materialized views, or optimizing query performance in event-sourced systems.

repo: wshobson/agents

Popularity

GitHub stars
41k
Ranking position
#6640
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills