projection-patterns

Generate Python projector templates for CQRS read models and materialized views.

38.6k|4.1k|Updated Jul 24, 2025
One-click install
npx skills add https://github.com/wshobson/agents --skill projection-patterns-wshobson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: projection-patterns
Source: https://github.com/wshobson/agents/tree/main/plugins/backend-development/skills/projection-patterns
Command: npx skills add https://github.com/wshobson/agents --skill projection-patterns-wshobson

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires asyncpg, elasticsearch, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide and templates for building read models and projections from event streams, crucial for optimizing query performance in event-sourced systems.

Core Features & Use Cases

  • CQRS Read Sides: Implement efficient read models for Command Query Responsibility Segregation.
  • Materialized Views: Create and maintain up-to-date views of aggregated data from events.
  • Query Optimization: Improve read performance by denormalizing event data into query-optimized structures.
  • Use Case: When building a dashboard that displays real-time order summaries, this Skill helps create and update a dedicated read model that aggregates order status, total amounts, and item counts from various order-related events.

Quick Start

Use the projection-patterns skill to generate a basic projector template.

Frequently Asked Questions about projection-patterns

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

FAQPage Schema
How do I build read models from event streams in a CQRS architecture?

Build read models from event streams by using projection patterns that process event data into query-optimized structures. This Skill provides Python templates for creating CQRS read sides and materialized views that aggregate and denormalize data for efficient querying.

What is the best way to create materialized views from event sourcing data?

The best way to create materialized views from event sourcing data is through aggregating projections. This Skill offers patterns to maintain up-to-date views by continuously processing event streams and updating dedicated read models with summarized information like order totals and item counts.

Can I use Elasticsearch for search projections in an event-driven architecture?

Yes, you can use Elasticsearch for search projections in an event-driven architecture. This Skill includes specific Python code examples for building Elasticsearch search projections that index event stream data, enabling optimized and denormalized search queries.

Do I need asyncpg to implement projections for event-sourced systems?

You need asyncpg or a similar database driver to implement projections for event-sourced systems when writing to PostgreSQL. This Skill uses asyncpg as a dependency to handle asynchronous database operations for creating and updating multi-table projections and read models.

How do I optimize queries for real-time order summary dashboards using event streams?

Optimize queries for real-time order summary dashboards by building dedicated read models that aggregate event streams. This Skill provides templates to project order status, total amounts, and item counts into a materialized view, avoiding expensive runtime event replay calculations.

When should I use projection patterns instead of querying the event store directly?

Use projection patterns instead of querying the event store directly when read performance is critical. By denormalizing event stream data into query-optimized structures and materialized views, projections eliminate the need to replay entire event histories for every query request.