Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/jordiaragonzaragoza/JordiAragonZaragoza.SharedKernel/llms.txt

Use this file to discover all available pages before exploring further.

SharedKernel is an open-source suite of .NET NuGet packages authored by Jordi Aragón Zaragoza that gives .NET developers a ready-made foundation for building applications around Domain-Driven Design (DDD) and Clean Architecture principles. Instead of hand-rolling aggregate roots, domain events, CQRS pipelines, EF Core base contexts, and REST API plumbing from scratch on every project, SharedKernel packages those concerns into versioned, tested, and composable building blocks so your team can focus on modelling the domain rather than wiring infrastructure.

Layered architecture

SharedKernel mirrors the standard Clean Architecture dependency graph. Each layer maps to one or more NuGet packages, and inner layers never depend on outer ones.
LayerResponsibility
Core (SharedKernel + .Contracts)DI markup interfaces, IDateTime, IEvent, IRepository, utility helpers
Domain (.Domain + .Domain.Contracts)BaseAggregateRoot, BaseEventSourcedAggregateRoot, BaseEntity, BaseValueObject, BaseDomainEvent, SmartEnum, business-rule checking
Application (.Application + .Application.Contracts + .Application.Contracts.Integration)ICommand/IQuery CQRS interfaces, ICommandBus/IQueryBus, MediatR pipeline behaviors (logging, validation, UoW, caching, performance), integration-event contracts
Infrastructure (.Infrastructure + .Infrastructure.EntityFramework + .Infrastructure.EventStore)MediatR bus wires, BaseContext/BaseBusinessModelContext, Ardalis Specification repositories, KurrentDB event-store client, cache, user/partition context
Presentation (.Presentation.HttpRestfulApi + .Presentation.Integration)FastEndpoints/controller base classes, ExceptionMiddleware, ProblemDetails response builder, MassTransit integration-event bus

Jump in

Domain entities & aggregates

Learn how BaseAggregateRoot, BaseEntity, BaseValueObject, and BaseDomainEvent enforce DDD invariants in your model.

Application & CQRS

Wire commands and queries with ICommand, ICommandHandler, ICommandBus, and the built-in MediatR pipeline behaviors.

Infrastructure & Entity Framework

Use BaseBusinessModelContext, Ardalis Specification repositories, audit interceptors, and the soft-delete interceptor out of the box.

Presentation: HTTP RESTful API

Add BaseApiCommandController, ExceptionMiddleware, and the ProblemDetails ResponseBuilderHelper to your ASP.NET Core service.

Design philosophy

Persistence-agnostic aggregates. BaseAggregateRoot<TId> holds a private List<IDomainEvent> and exposes it as IEnumerable<IDomainEvent> Events. The aggregate never knows whether it will be persisted by EF Core or an event store — that decision lives entirely in the Infrastructure layer. Optional event sourcing. When you need a full audit trail you can switch the aggregate base class from BaseAggregateRoot<TId> to BaseEventSourcedAggregateRoot<TId> and back the repository with the JordiAragonZaragoza.SharedKernel.Infrastructure.EventStore package (built on KurrentDB). State-based and event-sourced aggregates live comfortably side-by-side in the same solution. Clean Architecture dependency rules. Contracts packages (.Contracts, .Domain.Contracts, .Application.Contracts) contain only interfaces and records. Implementation packages depend inward on contracts, never the reverse. This lets you swap infrastructure adapters (e.g. replace EF Core with Dapper) without touching the domain or application layers. MediatR pipelines as cross-cutting concerns. Validation (FluentValidation), logging, unit-of-work transaction management, response caching, cache invalidation, and performance tracking are each encapsulated in a dedicated IPipelineBehavior<,> implementation. Register only the behaviors you need via the provided AddSharedKernelInfrastructureCommandBus() and AddSharedKernelApplicationCommandBus() extension methods.

Example project

JordiAragonZaragoza.Cinema is the canonical showcase for SharedKernel. It models a fictional cinema management system and demonstrates DDD, Event Sourcing, Microservices Architecture with an Event-Driven approach, and Vertical Slice Architecture — all built on top of these packages.
The main branch targets .NET 10. If you need an older runtime, previous versions are available on dedicated branches: net9.0, net8.0, and net7.0.

Build docs developers (and LLMs) love