Skip to content

Getting started

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 todo example. It is the moleculer-cqrs README walkthrough as a program, on an in-memory SQLite database.

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

    Terminal window
    pnpm ui
  • 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/
    • Directorytodo/ the moleculer-cqrs walkthrough
      • …
    • Directorybank-ui/ the bank demo, in the browser
      • …
  • Directorybench/ performance and stress tests, and their report
    • …
  • Directorytest/
    • …