$ show event-driven-io/emmett
Emmett is a TypeScript monorepo providing an opinionated event sourcing and CQRS framework for Node.js applications. It implements the decider pattern for business logic, with pluggable event store backends (PostgreSQL, SQLite, MongoDB, EventStoreDB, in-memory) and web framework integrations (Express, Hono, Fastify). The framework includes built-in projections (single/multi-stream, raw SQL, document-oriented via Pongo), consumer/processor pipelines with checkpointing and locking, workflow orchestration, and comprehensive observability via OpenTelemetry (tracing, metrics, logging). The codebase is modular with separate packages per database and web framework, extensive test coverage (unit, integration, e2e), and a CLI for schema migrations. It is actively maintained with a large community (539 stars, 53 forks) and zero dependabot alerts. The architecture demonstrates high craftsmanship with reusable patterns for middleware composition, streaming transformations, and BDD-style testing specifications.
The LLM identified 4 files worth highlighting for reuse:
Implements lazy async pipeline operators (map, flatMap, chunk, toArray) using Web Streams API. The chunk operator with size+deadline is a non-obvious pattern for batching with timeout. This module is self-contained and could be extracted as a standalone streaming utility library.
Provides a composable middleware system for command handlers with before/after hooks, decision-level middleware, and built-in operators (append, skip, stop, reject). Demonstrates a clean separation of cross-cutting concerns (validation, authorization, logging) from business logic. The pattern is reusable in any command-processing pipeline.
Implements a BDD-style given/when/then specification for testing decider-based business logic. Supports both sync and async deciders, error assertions, and event stream verification. This pattern is reusable for any event-sourced domain and can be extracted as a standalone testing utility.
A fully functional in-memory event store implementing the EventStore interface with optimistic concurrency, stream reading, and after-commit hooks. Designed for fast unit tests without external dependencies. The implementation is self-contained and demonstrates a clean contract that can be reused as a reference for custom event store implementations.