Skip to content
Terminal window
pnpm add effect-cqrs effect

It needs Node 24 or later and Effect 4. To store events in SQLite or PostgreSQL, add that database’s effect/sql driver too:

Terminal window
pnpm add @effect/sql-sqlite-node
pnpm add @effect/sql-pg

Everything is exported from effect-cqrs, and each module also has its own path, such as effect-cqrs/ViewModel.

The examples live in the repository, where they import the TypeScript sources directly.

  1. Clone the repository and install the dependencies. It needs pnpm.

    Terminal window
    git clone https://github.com/davidnussio/effect-cqrs.git
    cd effect-cqrs
    pnpm install
  2. Run the tests.

    Terminal window
    pnpm test
  3. Run the tutorial’s shop, which uses every feature in one file.

    Terminal window
    pnpm tutorial
  4. Run the todo example. It is the moleculer-cqrs README walkthrough as a program, on an in-memory SQLite database.

    Terminal window
    pnpm example
  5. Serve the bank demo at http://localhost:5173.

    Terminal window
    pnpm ui
  6. Serve the tutorial’s shop, with its traces, saga and stored rows.

    Terminal window
    pnpm ui:shop
  • 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/
    • …