A modern, lightweight, and extensible .NET framework for building event-sourced applications using Domain-Driven Design (DDD) principles and Command Query Responsibility Segregation (CQRS) patterns.
SourceFlow.Net empowers developers to build scalable, maintainable applications by providing a complete toolkit for event sourcing, domain modeling, and command/query separation. Built from the ground up for .NET 9.0 with performance and developer experience as core priorities.
- 🏗️ Domain-Driven Design Support - First-class support for aggregates, entities, value objects
- ⚡ CQRS Implementation - Complete command/query separation with optimized read models
- 📊 Event Sourcing Foundation - Event-first design with full audit trail
- 🧱 Clean Architecture - Clear separation of concerns and dependency management
- 💾 Flexible Persistence - Multiple storage options including Entity Framework Core
- 🔄 Event Replay - Built-in command replay for debugging and state reconstruction
- 🎯 Type Safety - Strongly-typed commands, events, and projections
- 📦 Dependency Injection - Seamless integration with .NET DI container
- 📈 OpenTelemetry Integration - Built-in distributed tracing and metrics for operations at scale
- ⚡ Memory Optimization - ArrayPool-based optimization for extreme throughput scenarios
- 🛡️ Resilience Patterns - Polly integration for fault tolerance with retry policies and circuit breakers
Aggregates
- An
Aggregateencapsulates a root domain entity within a bounded context (microservice) - Changes to aggregates are initiated by publishing commands
- Aggregates subscribe to events to react to external changes from other sagas or workflows that may affect their state
Sagas
- A
Sagarepresents a long-running transaction that orchestrates complex business processes - Sagas subscribe to commands and execute the actual updates to aggregate entities
- They manage both success and failure flows to ensure data consistency and preserve aggregate state
- Sagas can publish commands to themselves or other sagas to coordinate multi-step workflows
- Events can be raised by sagas during command handling to notify other components of state changes
Events
- Events are published to interested subscribers when state changes occur
- Two primary event subscribers exist in the framework:
- Aggregates: React to events from external workflows that impact their domain state
- Views: Project event data into optimized read models for query operations
Views
- Views subscribe to events and transform domain data into denormalized view models
- View models provide optimized read access for consumers such as UIs or reporting systems
- Data in view models follows eventual consistency patterns
Command Dispatcher
- Dispatches commands to cloud-based message queues for distributed processing
- Targets specific command queues based on bounded context routing
Command Queue
- A dedicated queue for each bounded context (microservice)
- Routes incoming commands to the appropriate subscribing sagas within the domain
Event Dispatcher
- Publishes domain events to cloud-based topics for cross-service communication
- Enables event-driven architecture across distributed systems
Event Listeners
- Bootstrap components that listen to subscribed event topics
- Dispatch received events to the appropriate aggregates and views within each domain context
- Enable seamless integration across bounded contexts
Click on Architecture for more details on how to extend SourceFlow.Net for bespoke requirements.
add nuget packages for SourceFlow.Net
- dotnet add package SourceFlow.Net
- dotnet add package SourceFlow.Stores.EntityFramework
- dotnet add package SourceFlow.Cloud.Aws (to be released)
- add custom implementation for stores, and extend for your cloud.
This comprehensive guide provides detailed information about the SourceFlow.Net framework, covering everything from basic concepts to advanced implementation patterns and troubleshooting guidelines.
Please click on Developer Guide for complete details.
If you are having problems, please let me know by raising a new issue.
This project is licensed with the MIT license.
We welcome contributions! Please see our Contributing Guide for details.
- 🐛 Bug Reports - Create an issue
- 💡 Feature Requests - Start a discussion
- 📝 Documentation - Help improve our docs
- 💻 Code - Submit pull requests
Thank you for reading. Please fork, explore, contribute and report. Happy Coding !! :)
