event-store-design

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

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill event-store-design-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: event-store-design
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/event-store-design
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill event-store-design-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building event sourcing infrastructure requires choosing the right storage technology and implementing append-only, versioned, concurrency-safe event persistence, which is error-prone without proven patterns. ## Core Features & Use Cases - Technology Selection Guidance: Compare EventStoreDB, PostgreSQL, Kafka, DynamoDB, and Marten against your throughput, query, and ecosystem requirements. - Ready-to-Use Templates: Apply a PostgreSQL event store schema, a Python asyncpg implementation with optimistic concurrency, EventStoreDB client patterns, and a DynamoDB single-table design. - Use Case: When building an order management system with event sourcing, use the PostgreSQL schema and Python EventStore class to append order events with version checks, read streams to rebuild aggregate state, and run checkpointed subscriptions for projections. ## Quick Start Ask the AI to design an event store schema and implementation for your chosen database, for example a PostgreSQL event store with optimistic concurrency for an order aggregate.

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 events table with stream_id, event_type, JSONB event_data, version, and a BIGSERIAL global_position, plus a unique constraint on (stream_id, version) for optimistic concurrency. Add indexes on stream_id, global_position, event_type, and created_at for your query patterns.

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 checks 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 compare it against the stream's current maximum version inside a transaction, raising a concurrency error on mismatch. In PostgreSQL, the unique constraint on (stream_id, version) provides a second layer of protection.

Can I use DynamoDB as an event store?

Yes, model streams with a partition key like STREAM#{stream_id} and a sort key of zero-padded version numbers, using a GSI for global ordering. Conditional writes enforce concurrency, though cross-stream global ordering and query flexibility are limited compared to dedicated stores.

How do event store subscriptions and checkpoints work?

A subscription polls events by global_position in batches, invokes a handler per event, then persists the last processed position in a subscription_checkpoints table. On restart it resumes from the stored checkpoint, giving at-least-once delivery that handlers must make idempotent.

What are common event store design mistakes to avoid?

Avoid updating or deleting events, storing oversized payloads, and skipping optimistic concurrency checks, since these break immutability and corrupt state. Also include correlation and causation IDs from day one and plan for backpressure from slow subscription consumers.