/cqrs-fsharp

Example of a simple inventory management system implemented in F# using DDD, CQRS, and Event Sourcing.

Primary LanguageF#MIT LicenseMIT

CQRS Made (mostly) Functional

CI Workflow

Example of a simple inventory management system implemented in F# using DDD, CQRS, and Event Sourcing.

This project is intended to implement a solution with modularity and versioning (eventually), and serve as a boilerplate template for real-life projects.

It is still very much work in progress, so definitely not suitable to be a template for real-life projects just yet.

Solution Overview

Solution uses .NET 8 / F# and has following major parts:

  • Core domain components. Only types and pure functions are allowed here.
  • Application services that are aware of the outside world and intended to have effects - consume and publish messages, read and write DB data, make external HTTP/GRPC calls etc.
  • API sends Commands to Application (command API), and uses ProjectionStore to retrieve view models (query API).
  • Ports. Abstractions for event store, projections store, and message bus.
  • Adapters. Implementations of Ports abstraction that (typically) use external services, e.g. MartenDB or RabbitMQ.
  • CLI: example of an external client that interacts with the system via API.

See “Architecture” and “Solution Structure” documents for more information.

Building and Running

Prerequisites

Development Environment

Development environment is a personal choice, here are some options:

PowerShell helper script build.ps1 can be used to build and run the solution, see “Build and Run” document for more information.

Interacting with the running system

See “Interacting with the system using API” document.

References

  1. Wlaschin, Scott. “Domain Modeling Made Functional”, The Pragmatic Programmers, 2018-01, https://pragprog.com/titles/swdddf/domain-modeling-made-functional/.
  2. Evans, Eric. “Domain-Driven Design: Tackling Complexity in the Heart of Software”, Addison-Wesley Professional, 2003-09-11
  3. Fowler, Martin. “Bliki: CQRS” martinfowler.com, 2011-07-14, https://martinfowler.com/bliki/CQRS.html.
  4. Young, Gregory. “CQRS Documents” wordpress.com, 2010-11, https://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf.
  5. Young, Gregory. “Simple CQRS” github.com, 2015-01-13, https://github.com/gregoryyoung/m-r.
  6. Fowler, Martin. “Event Sourcing” martinfowler.com, 2005-12-12, https://martinfowler.com/eaaDev/EventSourcing.html.
  7. Microsoft Learning. “Event Sourcing pattern”, learn.microsoft.com https://learn.microsoft.com/en-us/azure/architecture/patterns/event-sourcing.