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 a suite of .NET NuGet packages that give you the domain-driven design and Clean Architecture building blocks you need without writing them from scratch. From BaseAggregateRoot and BaseValueObject to MediatR pipeline behaviors and MassTransit integration buses, every layer of your architecture is covered.

Introduction

Learn what SharedKernel is, how it’s structured, and which packages to add to your project.

Quickstart

Install the packages and wire up a working aggregate with CQRS in under five minutes.

NuGet Packages

Browse all published packages, their responsibilities, and the dependency graph.

Domain Layer

Entities, aggregate roots, value objects, domain events, business rules, and smart enums.

What’s Included

Domain Primitives

BaseAggregateRoot, BaseEntity, BaseValueObject, BaseEntityId, and event-sourced variants.

CQRS & Pipelines

ICommand, IQuery, ICommandBus, IQueryBus with full MediatR pipeline behavior support.

EF Core Infrastructure

Base DbContext classes, repositories, soft-delete interceptor, and projection stores.

Event Store

KurrentDB-backed event store with catch-up subscriptions and stream mapping.

Integration Bus

MassTransit + RabbitMQ integration bus for cross-service events and commands.

REST API Helpers

BaseApiCommandController, exception middleware, and ResponseBuilder for Problem Details.

Get Started in Three Steps

1

Install the packages you need

Add the SharedKernel NuGet packages for the layers you’re building. At minimum, install the Domain package for DDD primitives.
dotnet add package JordiAragonZaragoza.SharedKernel.Domain
dotnet add package JordiAragonZaragoza.SharedKernel.Application
dotnet add package JordiAragonZaragoza.SharedKernel.Infrastructure
2

Define your aggregate root

Inherit from BaseAggregateRoot<TId> and implement the required When and EnsureValidState methods.
public sealed class Order : BaseAggregateRoot<OrderId>
{
    private Order(OrderId id) : base(id) { }

    public static Order Create(OrderId id)
    {
        var order = new Order(id);
        order.Apply(new OrderCreatedEvent(id));
        return order;
    }

    protected override void When(IDomainEvent domainEvent) { /* ... */ }
    protected override void EnsureValidState() { /* ... */ }
}
3

Register services and dispatch commands

Register SharedKernel services in Program.cs, define a command, and dispatch it through the ICommandBus.
builder.Services.AddSharedKernelInfrastructure();
builder.Services.AddSharedKernelInfrastructureCommandBus();
builder.Services.AddSharedKernelApplicationCommandBus();
See the Quickstart for the complete working example.
SharedKernel targets .NET 10 on the main branch. Previous versions for .NET 7, 8, and 9 are available on dedicated branches.

Build docs developers (and LLMs) love