-
Notifications
You must be signed in to change notification settings - Fork 0
Home
IEvent interface and BaseEvent record for all events EventStoreEntry for persistence Type-safe event definitions using records
Base AggregateRoot class with event sourcing capabilities Uncommitted events tracking Version-based optimistic concurrency control Event application for state reconstruction
IEventStore interface for pluggable storage In-memory implementation with concurrency control Event serialization/deserialization Stream-based event organization
Generic IRepository interface Event-sourced repository implementation Automatic aggregate reconstruction from events
- Bank Account Aggregate
Rich domain model with business rules Event-driven state changes Factory methods for aggregate creation Proper encapsulation and validation
Strongly-typed events using records Immutable event data Clear event naming conventions
- Application Services
Command handling with business logic Transaction boundaries Error handling and validation
- Projections/Read Models
Separate read model for queries Event handlers for projection updates CQRS pattern implementation
Key Features:
Immutable Events: All events are immutable records Optimistic Concurrency: Version-based conflict detection Event Replay: Complete state reconstruction from events Type Safety: Strong typing throughout the system Testability: Easy to unit test with in-memory implementations Separation of Concerns: Clean architecture with distinct layers
Usage: The demo shows creating accounts, performing transactions, viewing event history, and maintaining projections. This foundation can be extended with:
Persistent event stores (SQL Server, PostgreSQL, EventStore DB) Snapshotting for performance Event publishing for integration Saga patterns for long-running processes Multiple bounded contexts
This implementation provides a solid foundation for building event-sourced systems in .NET!