# Getting started

> Install effect-cqrs, or clone the repository to run its examples.

## Install

* pnpm

  ```bash
  pnpm add effect-cqrs effect
  ```

* npm

  ```bash
  npm install effect-cqrs effect
  ```

* yarn

  ```bash
  yarn add effect-cqrs effect
  ```

* bun

  ```bash
  bun 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:

* pnpm

  ```bash
  pnpm add @effect/sql-sqlite-node
  pnpm add @effect/sql-pg
  ```

* npm

  ```bash
  npm install @effect/sql-sqlite-node
  npm install @effect/sql-pg
  ```

* yarn

  ```bash
  yarn add @effect/sql-sqlite-node
  yarn add @effect/sql-pg
  ```

* bun

  ```bash
  bun add @effect/sql-sqlite-node
  bun add @effect/sql-pg
  ```

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

## Try the examples

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

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

   ```bash
   git clone https://github.com/davidnussio/effect-cqrs.git
   cd effect-cqrs
   pnpm install
   ```

2. Run the tests.

   ```bash
   pnpm test
   ```

3. Run the [tutorial](https://effect-cqrs.dambox.ch/tutorial/shop/)’s shop, which uses every feature in one file.

   ```bash
   pnpm tutorial
   ```

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

   ```bash
   pnpm example
   ```

5. Serve the bank demo at <http://localhost:5173>.

   ```bash
   pnpm ui
   ```

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

   ```bash
   pnpm ui:shop
   ```

## What’s where

* src/

  * 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

* examples/

  * tutorial/ the shop of the tutorial

    * …

  * todo/ the moleculer-cqrs walkthrough

    * …

  * bank-ui/ the bank demo, in the browser

    * …

  * shop-ui/ the tutorial’s shop, in the browser

    * …

  * workshop/ a bank and a shop on a server, for a room

    * …

* bench/ performance and stress tests, and their report

  * …

* test/

  * …

## Next steps

[Follow the tutorial](https://effect-cqrs.dambox.ch/tutorial/shop/)

[Define an aggregate](https://effect-cqrs.dambox.ch/guides/aggregates/)

[Walk through the bank](https://effect-cqrs.dambox.ch/tutorial/bank/)

[Use it with a coding agent](https://effect-cqrs.dambox.ch/using-with-ai/)
