Projection patterns

From mtecoYY/ai-baike · View interactive version

Projection patterns is an AI agent skill from the GitHub repository mtecoYY/ai-baike. 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.

How to use this skill

Skill file

Projection Patterns

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

When to Use This Skill

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

Don'ts

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.