Skip to content

An ecommerce system that highlights event-driven design, architecture, and implementation details. Uses the event-native database EventStoreDB. For those new and experienced to event-driven architecture, event sourcing, and distributed systems.

License

Notifications You must be signed in to change notification settings

erikshafer/event-sourcing-ecommerce

Repository files navigation

Github Actions

blog Twitter Follow

πŸͺ„ Event Sourcing Ecommerce πŸ›’

TL;DR: A collection of use cases utilizing event sourcing and event-driven architecture in the ecommerce domain that leverage the event-native database EventStoreDB.

πŸ—ΊοΈ Table of Contents

πŸ€” What is this repository?

This repository's objective to demonstrate how an ecommerce backend can be built using the data storage technique known as event sourcing, along with related concepts frequently employed such as event-driven architecture (EDA), Command and Query Responsibility Segregation (CQRS), and more.

The aim is to provide an assortment of use cases of varying complexity across different technologies. That is to say, examples that are beyond the Hello World level that showcase different methodologies and technologies.

πŸ§‘β€πŸ’» Technologies, frameworks, and libraries, oh my!

Moderns tools are leveraged to demonstrate different ways to interact with EventStoreDB, the event-native database. While it was written from the ground up for Event Sourcing, there are other interesting uses the database can be used for that this repository may explore in the future.

πŸ”€ Polyglot

An exciting yet perhaps lofty idea is to have this single code repository be the home for different runtimes and programming languages that work in tandem. Where one module (service) is written in C# running in .NET, while another service it communicates with is written in TypeScript running Node.js.

If this proves to be too ambitious or if the community finds it confusing, changes can be made. Such as making different versions of this repository with each featuring a different language and runtime.

πŸ“¬ Suggestions

Is there a library, framework, or other piece of tech you would like to see here? Simply open an issue, pull request, or contact me directly (see above). I would love to hear more about what you think should be highlighted here.

Runtimes

Databases

Event Store

EventStoreDB Libraries

Other Databases (for reads, queries, analysis, etc.)

Messaging

  • TBD. Current candidates:
    • Kafka
      • Demonstrate how Kafka and ESDB can be great friends!
    • RabbitMQ
      • Classic. Stable. Easiest option to get up and running with.

πŸ“ Documentation

A companion guide is currently in development.

πŸ›£οΈ Roadmap

Details are being worked out and will be shared soon.

Value Streams

Value Streams are a core concept in Team Topologies. To Grossly simplify, think departments, divisions, or teams within a company. That is, organizing business and technology teams for fast flow.

Proposed breakdown of modules

This early on in development, this is effectively a loose roadmap of what technologies will be used where. Better fits may be found or other technologies may want to be explored. All subject to change.

Value Stream Module Progress Runtime Language ESDB Library Additional Data Stores, etc.
πŸ’Ό Vendor Management Portal πŸ”΄ nodejs typescript Emmet postgresql
πŸͺ Retail Storefront πŸ”΄ nodejs typescript Emmet elasticsearch
πŸͺ Retail Cart 🟒⚫⚫ dotnet csharp Eventuous mongodb
πŸ“ Catalog Listings πŸ”΄ dotnet csharp Eventuous mongodb
πŸ“ Catalog Products 🟒⚫⚫ dotnet csharp Eventuous mongodb elasticsearch
πŸ“ Catalog Prices 🟒⚫⚫ dotnet csharp Eventuous postgresql
πŸ“¦ Supply Chain Inventories πŸ”΄ dotnet csharp Eventuous postgresql
πŸ“¦ Supply Chain Procurement πŸ”΄ dotnet csharp Eventuous postgresql
πŸ“¦ Supply Chain Fulfillment πŸ”΄ dotnet csharp Eventuous postgresql
πŸ”¬ Data Analysis Data Science πŸ”΄ dotnet csharp N/A TBD
πŸ”¬ Data Analysis Data Reporting πŸ”΄ dotnet csharp N/A TBD
πŸ›οΈ Legacy Legacy πŸ”΄ dotnet csharp N/A sql server
TBD TBD πŸ”΄ dotnet csharp MicroPlumberd TBD
TBD TBD πŸ”΄ java Java TBD TBD

Disclaimer about similarities

Names, structure, and hierarchy are based on personal experiences and opinions derived from time spent in the ecommerce industry. They do not reflect the inner workings of any specific singular system, team, or organization.

πŸ”¨ Compatibility

At this time it is preferred you build the projects on your machine directly, the traditional way.

In the future there will be an easier way to choose between running modules traditionally or with Docker.

As this time the background services, such as the databases, are ran inside of Docker containers.

πŸ› οΈ Installation Requirements

  1. Install .NET 8.0 SDK
  2. Install Docker
TODO: enable projects to be built within Docker and not require the .NET SDK to be installed

πŸš€ How To Run

Clone the repo

Clone the repository via your preferred method. For example, using the command line:

git clone https://github.com/erikshafer/event-sourcing-ecommerce

Build via terminal

Open a terminal and navigate to the root of the repository.

Build the dotnet solution (AKA the container of projects) with the following command at the root of the repository:

dotnet build

If you see no errors and a Build succeeded. message output, that means all the dotnet requirements were met. Hooray!

Start services in Docker via terminal

Be sure that after Docker is installed it is also actively running, otherwise the commands below will result in a Docker daemon is not running error.

Run the following command to have Docker begin running (detached, so you can still use your terminal) all background services, such as databases, sinks, etc.:

docker-compose up -d

This may take a moment to complete if this is your first time running the code. Specifically if you need to pull down the Docker images and then run the containers.

If there are no visible errors, and you see a Running 6/6 message output, all the Docker components, AKA the background services, are running successfully. Hooray!

End services in Docker via terminal

As we ran docker-compose as a detached process, so we can continue to use the same terminal, we will need to manually stop the services as well with the docker-compose feature. That can be done with the following command:

docker-compose down

If you didn't run Docker detached earlier (with no -d param), you can just escape out of the process with CTRL+C or whatever the binding is on your machine.

Check the Docker Compose documentation for more details.

Running the API projects

Work In Progress 🚧

As more vertical slices and implemented and projects are more fleshed out as a whole.

TL;DR: execute dotnet run where applicable. If you're a dotnet developer you likely know what to do!

πŸ“– The Story

An ecommerce company has grown out of its startup phase. It is needing to scale not just the amount of requests and responses it's capable of per second, but make itself capable to adapt to changing trends and shifts in the industry.

Enter event sourcing with EventStoreDB!

To be continued ⚠️

🏫 Resources

More to come 🚧

Thanks

  • Oskar Dudycz and his EventSourcing.NetCore code repository and event-driven.io blog.
    • Oskar's style of developing applications using concepts like CQRS and Event Sourcing has certainly rubbed off on me. That will be evident when looking at some of this very code! Aggregate design especially.
  • Derek Comartin writes articles on CodeOpinion.com and produces accompanying videos on his YouTube channel of the same name.
  • Greg Young and his involvement in getting so much of this rolling. His contributions helped this community and interest in this way of storing data get its start. And no, I didn't mean CARS. I mean CQRS!
  • Event Store, at time of this writing, is my employer! The individuals at Event Store are phenomenal in too many ways to write here. Thank you all for your professional and personal support.
  • JetBrains, I love your IDEs and Kotlin. That is all.
  • More to come!

Tools Used

I've been a large fan of JetBrains' suite of Integrated Development Environments (IDEs) for the better part of a decade. That includes their dotnet IDE called Rider which is used to work on this effort.

jetbrains rider

πŸ‘·β€β™‚οΈ Maintainer

Erik "Faelor" Shafer

blog: www.event-sourcing.dev

βš–οΈ License

MIT license.

About

An ecommerce system that highlights event-driven design, architecture, and implementation details. Uses the event-native database EventStoreDB. For those new and experienced to event-driven architecture, event sourcing, and distributed systems.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published