Skip to content

Added EventStoreDB E-Commerce initial samples

Compare
Choose a tag to compare
@oskardudycz oskardudycz released this 03 Jul 08:01
· 588 commits to main since this release

E-Commerce sample of Event Sourcing with EvenStoreDB

Sample is showing the typical flow of the Event Sourcing app with EventStoreDB.

Prerequisities

  1. Install git - https://git-scm.com/downloads.
  2. Install .NET Core 5.0 - https://dotnet.microsoft.com/download/dotnet/5.0.
  3. Install Visual Studio 2019, 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:
    • Postgres DB running
    • 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!
    • EventStoreDB UI: http://localhost:2113/
  4. Open, build and run ECommerce.sln solution.

Overview

It uses:

  • CQRS with MediatR,
  • Stores events from Aggregate method results to EventStoreDB,
  • Builds read models using Subscription to $all.
  • Read models are stored as Marten documents.
  • App has Swagger and predefined docker-compose to run and play with samples.

Write Model

  • Most of the write model infrastructure was reused from other samples,
  • Added new project Core.EventStoreDB for specific EventStoreDB code,
  • Added EventStoreDBRepository repository to load and store aggregate state,
  • Added separate IProjection interface to handle the same way stream aggregation and materialised projections,
  • Thanks to that added dedicated AggregateStream method for stream aggregation
  • See sample Aggregate

Read Model

Tests

Other

Trivia

  1. Docker useful commands
    • docker-compose up - start dockers
    • docker-compose kill - to stop running dockers.
    • docker-compose down -v - to clean stopped dockers.
    • docker ps - for showing running dockers
    • docker ps -a - to show all dockers (also stopped)