Skill files2 files

references/

SKILL.md63 lines
1
---
2
name: projection-patterns
3
description: 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.
4
---
5
6
# Projection Patterns
7
8
Comprehensive guide to building projections and read models for event-sourced systems.
9
10
## When to Use This Skill
11
12
- Building CQRS read models
13
- Creating materialized views from events
14
- Optimizing query performance
15
- Implementing real-time dashboards
16
- Building search indexes from events
17
- Aggregating data across streams
18
19
## Core Concepts
20
21
### 1. Projection Architecture
22
23
```
24
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
25
│ Event Store │────►│ Projector │────►│ Read Model │
26
│ │ │ │ │ (Database) │
27
│ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │
28
│ │ Events │ │ │ │ Handler │ │ │ │ Tables │ │
29
│ └─────────┘ │ │ │ Logic │ │ │ │ Views │ │
30
│ │ │ └─────────┘ │ │ │ Cache │ │
31
└─────────────┘ └─────────────┘ └─────────────┘
32
```
33
34
### 2. Projection Types
35
36
| Type | Description | Use Case |
37
| -------------- | --------------------------- | ---------------------- |
38
| **Live** | Real-time from subscription | Current state queries |
39
| **Catchup** | Process historical events | Rebuilding read models |
40
| **Persistent** | Stores checkpoint | Resume after restart |
41
| **Inline** | Same transaction as write | Strong consistency |
42
43
## Templates and detailed worked examples
44
45
Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates.
46
47
## Best Practices
48
49
### Do's
50
51
- **Make projections idempotent** - Safe to replay
52
- **Use transactions** - For multi-table updates
53
- **Store checkpoints** - Resume after failures
54
- **Monitor lag** - Alert on projection delays
55
- **Plan for rebuilds** - Design for reconstruction
56
57
### Don'ts
58
59
- **Don't couple projections** - Each is independent
60
- **Don't skip error handling** - Log and alert on failures
61
- **Don't ignore ordering** - Events must be processed in order
62
- **Don't over-normalize** - Denormalize for query patterns
63

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…