Implementation of the Dynamic Consistency Boundary (DCB) pattern for Node.js/TypeScript, based on Sara Pellegrini's design.
Monorepo managed with Lerna and Yarn workspaces.
packages/event-store(@dcb-es/event-store) — Core event store abstractions, in-memory implementation, event handling (decision models, tag matching)packages/event-store-postgres(@dcb-es/event-store-postgres) — Postgres implementation usingpg, tests usetestcontainers
examples/course-manager-cli— Simple CLI example (Course/Students domain)examples/course-manager-cli-with-readmodel— Extended example with read models
test/vitest.globalSetup.ts— Starts/stops a testcontainers Postgres instance, shares connection URI viaprocess.env.__PG_CONNECTION_URItest/testPgDbPool.ts— Creates isolated test databases per test suite; imported via@testVite resolve alias
npm test— Run all tests via Lerna (each package usesvitest run)npm run build— Build all packages (must build before running dependent package tests)npm run lint/npm run lint-fix— ESLint across all packages- Per-package:
cd packages/<name> && npm test
- TypeScript, Vitest, ESLint + Prettier
- Postgres tests require Docker (testcontainers)
- Dependencies: luxon (dates), uuid, pg
- EventStore: Interface for querying and appending events with optimistic concurrency
- Tags: Key-value pairs on events used for filtering/querying
- Query: Defines which events to fetch (by event types and tag filters)
- Decision Model (
buildDecisionModel): Builds state from events for command validation - Event Handlers: Projections/process managers that react to events
- SequencePosition: Global ordering of events, used for concurrency checks