Chronix is a modern .NET library that brings DDD-style aggregates, the Repository pattern, and Projections to EventStoreDB. It offers a clean and extensible way to build event-sourced systems with a focus on maintainability and developer experience.
- ✅ Clean Repository pattern over EventStoreDB
- ✅ Easily define aggregates, entities and value objects using Domain-Driven Design (DDD) principles
- ✅ Append and retrieve events as aggregates with minimal boilerplate
- ✅ Define projections alongside your domain
- ✅ Pluggable serialization and stream naming
dotnet add package Chronix.EventRepositoryChronix provides a simple way to register your aggregates and projections using the built-in IServiceCollection extensions.
Make sure you install the DI package:
dotnet add package Chronix.EventRepository.Extensions.DependencyInjectionRegisters an event repository for your aggregate, using the given stream prefix.
builder.Services.AddEventRepository<MyAggregate>("Member");Scans the given assembly for any inline projections (e.g., read models or handlers) and wires them automatically.
builder.Services.AddEventRepository<MyAggregate>("Member", typeof(ProjectionAssemblyToScan));Gives you full access to the builder to register serializers, encrypters, metadata enrichers and other options.
builder.Services.AddEventRepository<MyAggregate>(
"Member",
typeof(ProjectionAssemblyToScan),
(serviceProvider, builder) =>
{
builder.Encryption(new NoEncryptionEncrypter())
.MetadataEnricher(new BasicMetadataEnricher())
.Serializer(new AggregateRootSerializer())
.Options(new EventRepositoryOptions
{
AutoRevisionAfterNthEvent = 100
});
});Inject the IEventRepository<MyAggregate> eventRepository where you would require it.
var myAggregate = await eventRepository.GetById();
myAggregate.RaiseSomeEvents();
var result = await eventRepository.Append(myAggregate);