event-store-design

Design and implement event stores for event-sourced systems using PostgreSQL, EventStoreDB, or DynamoDB.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill event-store-design-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: event-store-design
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/agents/.agents/skills/event-store-design
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill event-store-design-ravitejakarra24

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building event sourcing infrastructure requires choosing the right storage technology, designing append-only schemas, and implementing optimistic concurrency, subscriptions, and idempotency correctly—mistakes here cause data corruption and scaling pain. ## Core Features & Use Cases - Technology Selection Guidance: Compare EventStoreDB, PostgreSQL, Kafka, DynamoDB, and Marten against your throughput, query, and ecosystem constraints. - Ready-to-Use Templates: PostgreSQL schema DDL, a Python asyncpg event store with optimistic concurrency and subscription checkpoints, EventStoreDB client usage, and a DynamoDB single-table design. - Best Practices Checklist: Stream naming, correlation/causation IDs, event versioning, idempotent writes, and indexing strategies. - Use Case: You are building an order management system with event sourcing and need to decide between PostgreSQL and EventStoreDB, then implement append, stream reads, and global subscriptions with checkpointing. ## Quick Start Ask the agent to design an event store schema and implementation for your aggregate using PostgreSQL or EventStoreDB.

Frequently Asked Questions about event-store-design

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

FAQPage Schema
How do I implement an event store in PostgreSQL?

Create an append-only events table with stream_id, version, event_type, JSONB payload, and a global_position bigserial column, enforcing a unique constraint on (stream_id, version). Use optimistic concurrency by checking the expected version inside a transaction before inserting new events.

EventStoreDB vs PostgreSQL for event sourcing, which should I choose?

EventStoreDB is purpose-built for event sourcing with native streams, projections, and subscriptions, while PostgreSQL fits teams already running Postgres who accept manual implementation of concurrency and subscriptions. Kafka suits high-throughput streaming but is weak for per-stream queries.

How do I handle optimistic concurrency in an event store?

Pass an expected version when appending events and verify it matches the stream's current max version inside the same transaction. If the versions differ, raise a concurrency error and let the caller reload the stream and retry.

Can I use DynamoDB as an event store?

Yes, using a single-table design with PK as STREAM#{id} and SK as a zero-padded VERSION# number, plus a GSI for global ordering. Conditional writes provide concurrency control, though cross-stream queries and global ordering are more limited than relational stores.

Why should events never be updated or deleted in event sourcing?

Events are immutable facts that form the audit trail and the source of truth for rebuilding state. Updating or deleting them breaks replayability, corrupts projections, and destroys the ability to reconstruct historical aggregate state.