DSR.Architecture
A personal set of .NET libraries for building modular, maintainable backends with DDD, Clean Architecture and CQRS. In development.
A personal set of .NET libraries for building modular, maintainable backends with DDD, Clean Architecture and CQRS. In development.
Infrastructure
depends on Application
Implements the contracts for a specific store.
Application
depends on Domain
Commands and queries pass through a pipeline of behaviors before reaching their use case.
Domain
depends on nothing
Knows nothing about infrastructure.
Planned
Not in the repository yet.
DSR.Architecture is a personal project: a set of .NET libraries that give a backend application its architectural skeleton, so that a new service starts from consistent building blocks instead of a blank solution.
It is where I work out, in code, how I think a .NET backend should be layered.
Most backend services re-create the same foundations: base entities, a result type, repositories, a unit of work, a request pipeline with validation and transactions. Written ad hoc, those foundations drift between projects and business logic ends up coupled to the persistence technology of the day.
The goal is to make the right structure the easy one: domain code that knows nothing about infrastructure, and infrastructure that can be swapped without touching use cases.
Result instead of relying on exceptions for expected failures.A request enters the Application layer as a command or query and passes through a chain of behaviors before reaching its use case. The use case works with aggregates from the Domain layer and reaches data through repository contracts. Infrastructure packages implement those contracts for a specific store.
Queries are expressed as specifications defined next to the domain. The Entity Framework package evaluates them into IQueryable and can execute them as compiled queries, caching by the structural shape of the expression.
Specifications in their own package. They depend only on LINQ expressions, so the same specification can be evaluated by EF Core, translated for MongoDB or run in memory.
Read and write repositories are separate contracts. A use case that only reads cannot accidentally write, and read paths can be optimized independently.
Compiled queries behind an executor. Compilation is an optimization that should not leak into use cases. Logging, shadow and canary executors exist to compare the compiled path against the standard one before trusting it.
Idempotency as a behavior. Commands can opt in through a marker interface rather than each handler implementing its own de-duplication.
Everything listed under Domain, Application, Persistence and Supporting in the component map below exists as source code in the public repository, targets .NET 10 and is set up for NuGet packaging with a publish workflow per package.
This is an early-stage project in active development. It is not a mature framework and I do not present it as one:
Two of my other repositories, DsrWebApp and UserPermissionApi, use these packages and serve as its first real consumers.
Dsr.Architecture.Domain
Aggregates, entities, value objects, domain events, a Result type and a validation collector with guards.
Dsr.Architecture.Domain.Specifications
Persistence-agnostic specifications: criteria, includes, ordering, paging, plus analytics specifications for grouping and aggregation.
Dsr.Architecture.Application
Use case, command and query contracts with pipeline behaviors for validation, authorization, transactions, idempotency, logging, metrics and exception handling.
Dsr.Architecture.Persistence.Abstractions
Read and write repository contracts, unit of work and transactional unit of work, and an event-sourced repository contract.
Dsr.Architecture.Infrastructure.Persistence.EntityFramework
EF Core repositories, a specification evaluator, compiled-query execution with a bounded cache, and logging, shadow and canary executors.
Dsr.Architecture.Infrastructure.Persistence.Mongo
MongoDB repository and entity base types.
…Persistence.SqlServer / …Persistence.SqlLite
Provider-specific repositories and registration for SQL Server and SQLite.
Dsr.Architecture.Infrastructure.Provider
HTTP client abstraction for external service integrations.
Dsr.Architecture.TryCatch / Utilities
Centralized try/catch handling and general-purpose helpers.
Dsr.Architecture.Outbox
Outbox pattern for reliable event publication.
Planned: Not yet in the repository
Dsr.Architecture.EventSourcing
Event sourcing implementation behind the existing repository contract.
Planned: Not yet in the repository
I am open to conversations about engineering roles, architecture and web projects.