Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Simple, practical EventSourcing with EventStoreDB and EntityFramework

The is the simple Event Sourcing setup with EventStoreDB. For the Read Model, Postgres and Entity Framework are used.

You can watch the webinar on YouTube where I'm explaining the details of the implementation:

Practical introduction to Event Sourcing with EventStoreDB

or read the article explaining the read model part: "How to build event-driven projections with Entity Framework"

Main assumptions:

  • explain basics of Event Sourcing, both from the write model (EventStoreDB) and read model part (Postgres and EntityFramework),
  • CQRS architecture sliced by business features, keeping code that changes together at the same place. Read more in How to slice the codebase effectively?
  • no aggregates, just data (records) and functions,
  • clean, composable (pure) functions for command, events, projections, query handling instead of marker interfaces (the only one used internally is IEventHandler). Thanks to that testability and easier maintenance.
  • easy to use and self-explanatory fluent API for registering commands and projections with possible fallbacks,
  • registering everything into regular DI containers to integrate with other application services.
  • pushing the type/signature enforcement on edge, so when plugging to DI.

Overview

It uses:

  • pure data entities, functions and handlers,
  • Stores events from the command handler result EventStoreDB,
  • Builds read models using Subscription to $all.
  • Read models are stored to Postgres relational tables with Entity Framework.
  • App has Swagger and predefined docker-compose to run and play with samples.

Write Model

Read Model

Tests

API integration tests for:

Prerequisities

  1. Install git - https://git-scm.com/downloads.
  2. Install .NET Core 6.0 - https://dotnet.microsoft.com/download/dotnet/6.0.
  3. Install Visual Studio 2022, Rider or VSCode.
  4. Install docker - https://docs.docker.com/docker-for-windows/install/.
  5. Open ECommerce.sln solution.

Running

  1. Go to docker and run: docker-compose up.
  2. Wait until all dockers got are downloaded and running.
  3. You should automatically get:
    • EventStoreDB UI (for event store): http://localhost:2113/
    • Postgres DB running (for read models)
    • PG Admin - IDE for postgres. Available at: http://localhost:5050.
      • Login: admin@pgadmin.org, Password: admin
      • To connect to server Use host: postgres, user: postgres, password: Password12!
  4. Open, build and run ECommerce.sln solution.