Getting started
Install
Section titled “Install”pnpm add effect-cqrs effectnpm install effect-cqrs effectyarn add effect-cqrs effectbun add effect-cqrs effectIt needs Node 24 or later and Effect 4. To store events in SQLite or PostgreSQL, add
that database’s effect/sql driver too:
pnpm add @effect/sql-sqlite-nodepnpm add @effect/sql-pgnpm install @effect/sql-sqlite-nodenpm install @effect/sql-pgyarn add @effect/sql-sqlite-nodeyarn add @effect/sql-pgbun add @effect/sql-sqlite-nodebun add @effect/sql-pgEverything is exported from effect-cqrs, and each module also has its own path, such
as effect-cqrs/ViewModel.
Try the examples
Section titled “Try the examples”The examples live in the repository, where they import the TypeScript sources directly.
-
Clone the repository and install the dependencies. It needs pnpm.
Terminal window git clone https://github.com/davidnussio/effect-cqrs.gitcd effect-cqrspnpm install -
Run the tests.
Terminal window pnpm test -
Run the tutorial’s shop, which uses every feature in one file.
Terminal window pnpm tutorial -
Run the todo example. It is the moleculer-cqrs README walkthrough as a program, on an in-memory SQLite database.
Terminal window pnpm example -
Serve the bank demo at http://localhost:5173.
Terminal window pnpm ui -
Serve the tutorial’s shop, with its traces, saga and stored rows.
Terminal window pnpm ui:shop
What’s where
Section titled “What’s where”Directorysrc/
- Aggregate.ts defines aggregates
- AggregateService.ts runs commands and reads state and history
- ViewModel.ts projects events into read models
- Checkpoints.ts remembers how far each view model has read
- EventStore.ts the log, and the store in memory
- SqliteEventStore.ts
- PostgresEventStore.ts
- Fixture.ts tests an aggregate in isolation
Directoryexamples/
Directorytutorial/ the shop of the tutorial
- …
Directorytodo/ the moleculer-cqrs walkthrough
- …
Directorybank-ui/ the bank demo, in the browser
- …
Directoryshop-ui/ the tutorial’s shop, in the browser
- …
Directoryworkshop/ a bank and a shop on a server, for a room
- …
Directorybench/ performance and stress tests, and their report
- …
Directorytest/
- …