Event Sourcing
Skill files7 files

references/

scripts/

templates/

SKILL.md99 lines
1
---
2
name: event-sourcing
3
description: >
4
Implement event sourcing and CQRS patterns using event stores, aggregates, and
5
projections. Use when building audit trails, temporal queries, or systems
6
requiring full history.
7
---
8
9
# Event Sourcing
10
11
## Table of Contents
12
13
- [Overview](#overview)
14
- [When to Use](#when-to-use)
15
- [Quick Start](#quick-start)
16
- [Reference Guides](#reference-guides)
17
- [Best Practices](#best-practices)
18
19
## Overview
20
21
Store state changes as a sequence of events rather than the current state, enabling temporal queries, audit trails, and event replay.
22
23
## When to Use
24
25
- Audit trail requirements
26
- Temporal queries (state at any point in time)
27
- Event-driven microservices
28
- CQRS implementations
29
- Financial systems
30
- Complex domain models
31
- Debugging and analysis
32
- Compliance and regulation
33
34
## Quick Start
35
36
Minimal working example:
37
38
```typescript
39
interface DomainEvent {
40
id: string;
41
aggregateId: string;
42
aggregateType: string;
43
eventType: string;
44
data: any;
45
metadata: {
46
userId?: string;
47
timestamp: number;
48
version: number;
49
};
50
}
51
52
interface Aggregate {
53
id: string;
54
version: number;
55
}
56
57
class EventStore {
58
private events: DomainEvent[] = [];
59
60
async appendEvents(
61
aggregateId: string,
62
expectedVersion: number,
63
events: Omit<DomainEvent, "id" | "metadata">[],
64
// ... (see reference guides for full implementation)
65
```
66
67
## Reference Guides
68
69
Detailed implementations in the `references/` directory:
70
71
| Guide | Contents |
72
|---|---|
73
| [Event Store (TypeScript)](references/event-store-typescript.md) | Event Store (TypeScript) |
74
| [Projections (Read Models)](references/projections-read-models.md) | Projections (Read Models) |
75
| [Event Store with PostgreSQL](references/event-store-with-postgresql.md) | Event Store with PostgreSQL |
76
| [Snapshots for Performance](references/snapshots-for-performance.md) | Snapshots for Performance |
77
78
## Best Practices
79
80
### ✅ DO
81
82
- Store events immutably
83
- Version your events
84
- Use optimistic concurrency
85
- Create snapshots for performance
86
- Use projections for queries
87
- Keep events small and focused
88
- Include metadata (timestamp, user, etc.)
89
- Handle event versioning/migration
90
91
### ❌ DON'T
92
93
- Mutate past events
94
- Store current state only
95
- Skip concurrency checks
96
- Query event store for reads
97
- Make events too large
98
- Forget about event schema evolution
99

© AJ Geddes · 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…