Skip to content

Node.js project created to demonstrate homemade event sourcing patterns for educational purposes. The project implements basic event sourcing concepts like event storage, replay, and eventual consistency without relying on external libraries.

License

Notifications You must be signed in to change notification settings

jdevelop-io/event-sourcing-node

Repository files navigation

Event Sourcing in Node.js

Build Workflow Tests Workflow License WakaTime

This repository is a Node.js project created to demonstrate homemade event sourcing patterns for educational purposes. The project implements basic event sourcing concepts like event storage, replay, and eventual consistency without relying on external libraries. It's designed to help you understand the fundamentals of event sourcing in a practical, hands-on way.

To Do

  • Create an abstract Aggregate class.
  • Create an abstract DomainEvent class.
  • Implement the ability to record events in an Aggregate.
  • Implement the ability to replay events in an Aggregate.
  • Create the EventStore interface.
  • Implement an in-memory EventStore.
  • Implement the ability to store events in an EventStore.
  • Implement the ability to replay events from an EventStore for a specific Aggregate.
  • Implement the ability to replay events from an EventStore for all Aggregates ?
  • Create the Command interface.
  • Create the CommandHandler interface.
  • Create the CommandBus interface.
  • Implement an in-memory CommandBus.
  • Implement the ability to dispatch a command to a CommandBus.
  • Implement the ability to handle a command in a CommandHandler.
  • Create the QueryBus interface.
  • Implement an in-memory QueryBus.
  • Implement the ability to dispatch a query to a QueryBus.
  • Implement the ability to handle a query in a QueryHandler.
  • Create the EventBus interface.
  • Implement an in-memory EventBus.
  • Implement the ability to publish events to an EventBus.
  • Implement the ability to subscribe to events from an EventBus.

Getting Started

Prerequisites

Make sure you have Node.js and Bun installed on your machine before running the project.

  • Node.js (v22.5.1 or later)
  • Bun (v1.1.17 or later)

Installation

  1. Clone the repository:

    git clone --depth 1 https://github.com/jdevelop-io/event-sourcing-node.git
    cd event-sourcing-node
  2. Remove the .git directory to start with a clean git history:

    rm -rf .git
  3. Initialize a new git repository:

    git init
  4. Install the dependencies:

    bun install

Scripts

  • bun run build : Build the project.
  • bun run test : Run the tests.
  • bun run test:watch : Run the tests in watch mode.
  • bun run test:coverage : Run the tests with coverage.
  • bun run test:coverage:watch: Run the tests with coverage in watch mode.
  • bun run lint : Lint the code and fix linting errors.
  • bun run lint:check : Check the code for linting errors.
  • bun run format : Format the code and fix formatting errors.
  • bun run format:check : Check the code for formatting errors.

Project Structure

event-sourcing-node
├── .github
│   ├── workflows
│   │   ├── build.yml
│   │   └── tests.yml
├── node_modules
├── coverage
├── build
├── src
├── README.md
├── LICENSE
├── commitlint.config.mjs
├── eslint.config.mjs
├── jest.config.ts
├── lint-staged.config.mjs
├── prettier.config.mjs
├── tsconfig.json
├── bun.lockb
└── package.json

Contributing

Contributions are welcome! If you have any ideas, suggestions, or issues, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Node.js project created to demonstrate homemade event sourcing patterns for educational purposes. The project implements basic event sourcing concepts like event storage, replay, and eventual consistency without relying on external libraries.

Topics

Resources

License

Stars

Watchers

Forks