FCQRS Documentation
FCQRS is a F#-based implementation of the Command Query Responsibility Segregation (CQRS) pattern. By leveraging Akka.NET for actor-based concurrency, FCQRS allows you to encapsulate aggregates within actors that process commands, generate events, and manage long-running business processes via sagas. The framework is designed to protect your core domain logic while providing the flexibility to evolve your read models independently.
Introduction
FCQRS is designed to simplify the implementation of CQRS in F#. It integrates with Akka.NET, allowing developers to leverage the actor model for representing aggregates. This separation between command handling and query processing protects your core domain from changes that arise due to evolving reporting requirements.
Why CQRS and Event Sourcing?
The primary motivation behind adopting CQRS is the differing requirements of the read and write sides of an application:
- Independent Evolution: Query-side requirements tend to evolve (e.g., new reporting needs) while the write side—your core domain—remains stable.
- Protecting the Core Domain: By decoupling these responsibilities, changes in reporting or querying do not risk the integrity of your domain logic.
- Comprehensive Change Tracking: Event sourcing records every change as an event, enabling you to reconstruct state history and easily implement features such as versioning or rollbacks.
Key Features
Abstraction of Akka.NET
FCQRS abstracts away the complexities of Akka.NET, so you can focus on defining your aggregates as actors without needing to manage the low-level details of actor management.
Command and Event Handling
- Command Handlers: Manage incoming commands and validate or transform them into events.
- Event Handlers: Process events generated by aggregates to update read models or trigger further actions.
Saga Implementation
FCQRS supports sagas (process managers) that orchestrate long-running business processes. This separation allows your domain aggregates to remain free of side effects, improving testability and maintainability.
Getting Started
Installation and Setup
- Prerequisites: .NET 9 SDK.
-
Packages: Add the following nuget packages to your project using your preferred package manager:
FCQRS
Hocon.Extensions.Configuration
(optional, for HOCON configuration)Microsoft.Extensions.Logging.Console
(optional, for logging)