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 published as 12 focused NuGet packages organised by Clean Architecture layer. Each package targets .NET 10 and carries only the dependencies it genuinely needs — you pull in the packages that match the layers you are building, keeping your final binary free from unnecessary transitive dependencies.
All SharedKernel packages follow semantic versioning and are published to nuget.org. Pin your versions centrally (e.g. with Directory.Packages.props) to keep every layer of your solution aligned.

Core layer

The Core packages provide the lowest-level shared contracts and utility infrastructure that every other layer depends on. They carry no domain or application semantics.

JordiAragonZaragoza.SharedKernel

Utility helpers and DI markup interfaces.Depends on Microsoft.Extensions.DependencyInjection, Microsoft.Extensions.Configuration, and the SharedKernel.Contracts project.
Key typePurpose
DI markup interfacesAuto-registration of scoped/transient/singleton services by convention
Configuration helpersStrongly typed options binding utilities

JordiAragonZaragoza.SharedKernel.Contracts

Cross-cutting abstraction interfaces (no implementations).Zero external NuGet dependencies — safe to reference from any layer.
Key typePurpose
IEventMarker for all event types
IEventsContainerAggregate event collection contract
IBaseModel<TId>Root model identity contract
IOptimisticLockableVersion property for optimistic concurrency
IRepository<T, TId>Generic repository abstraction
IReadRepository<T, TId>Read-only repository abstraction
ICachedSpecificationRepository<T, TId>Specification + cache repository
IDateTimeAbstraction over DateTimeOffset.UtcNow

Domain layer

The Domain packages contain every DDD building block your model needs. Domain.Contracts holds pure interfaces; Domain provides concrete base classes.

JordiAragonZaragoza.SharedKernel.Domain.Contracts

Pure domain interface contracts.No NuGet dependencies. Reference this from any project that needs to declare domain types without pulling in implementations.
Key typePurpose
IAggregateRoot<TId>Marks an entity as an aggregate root with event collection
IEventSourcedAggregateRoot<TId>Extends IAggregateRoot for event-sourced aggregates
IEntity<TId>Strongly typed entity identity contract
IEntityId / IEntityId<TIdType>Value-object ID contract
IDomainEventMarker for domain events with Id, AggregateId, DateOccurredOnUtc
IBusinessRuleMessage + IsBroken() for guard-clause validation
IEventBusIn-process domain-event dispatch contract
IEventsDispatcherServiceService contract for draining aggregate event queues
IDomainServiceMarker for domain service classes
IAggregateStoreRepository contract for event-sourced aggregates

JordiAragonZaragoza.SharedKernel.Domain

Concrete DDD building blocks.Depends on SharedKernel, SharedKernel.Domain.Contracts, Ardalis.SmartEnum, and Microsoft.Extensions.Logging.
Key typePurpose
BaseAggregateRoot<TId>Aggregate root with Apply(), When(), EnsureValidState(), and event collection
BaseEventSourcedAggregateRoot<TId>Event-sourced variant — state is fully rehydrated from events
BaseEntity<TId>Entity base with structural equality and CheckRule()
BaseValueObjectValue object with GetEqualityComponents(), cached hash code, ==/!= operators
BaseEntityId<TIdType>Value-object ID with implicit conversion to the underlying primitive
BaseAggregateRootId<TId>Specialisation of BaseEntityId for aggregate roots
BaseDomainEvent(AggregateId)Abstract record class base for all domain events
SmartEnumRe-exported Ardalis SmartEnum base for type-safe enumerations
BusinessRuleValidationExceptionThrown by CheckRule() when a rule is broken

Application layer

The Application packages wire CQRS abstractions, MediatR pipeline behaviors, integration-event contracts, and validation helpers. They sit between the domain and the infrastructure.

JordiAragonZaragoza.SharedKernel.Application.Contracts

CQRS and application service contracts.Depends on MediatR.Contracts, Ardalis.Result, and SharedKernel.Domain.Contracts.
Key typePurpose
ICommand<TResponse>Transactional command that returns Result<TResponse>
ICommandVoid transactional command that returns Result
ICommandHandler<TCommand, TResponse>MediatR handler for typed commands
ICommandBusSendAsync overloads for dispatching commands
IQuery<TResponse>Query that returns Result<TResponse>
IQueryHandler<TQuery, TResponse>MediatR handler for queries
IQueryBusSendAsync for dispatching queries
IUnitOfWorkExecuteInTransactionAsync wraps an operation in a database transaction, committing or rolling back automatically
ICacheServiceGet/set/remove cache abstraction
ICacheRequest / IInvalidateCacheRequestMarkers to opt a request into caching behavior
IUserContextServiceAuthenticated user identity and claims
IIdGeneratorDeterministic or random ID generation
IPaginatedQuery / PaginatedCollectionOutputDto<T>Pagination contracts
BaseReadModelAbstract record base class for read-model response DTOs, carrying Id and Version

JordiAragonZaragoza.SharedKernel.Application.Contracts.Integration

Cross-service integration messaging contracts.No external NuGet dependencies — safe to share between service boundaries.
Key typePurpose
IIntegrationEventMarker for events published across service boundaries
IIntegrationCommandCross-service command contract
IIntegrationQueryCross-service query contract
IIntegrationEventBusPublish integration events
IIntegrationCommandBusSend integration commands
IIntegrationQueryBusSend integration queries
IIntegrationMessageCommon base for all integration message types

JordiAragonZaragoza.SharedKernel.Application

Pipeline behavior implementations and DI extensions.Depends on SharedKernel.Application.Contracts, SharedKernel.Domain, FluentValidation, Ardalis.Result.FluentValidation, and Microsoft.Extensions.Logging.
Key typePurpose
RequestLoggerServiceStructured logging for every request
RequestExceptionHandlerServiceTranslates unhandled exceptions to Result.Error
RequestUnitOfWorkServiceWraps command handlers in a SaveChangesAsync transaction
RequestAuthorizationService<,>Policy-based authorization check before handling
RequestValidationService<,>FluentValidation execution; returns Result.Invalid on failure
RequestCachingServiceResponse caching for ICacheRequest queries
RequestInvalidateCachingServiceCache eviction for IInvalidateCacheRequest commands
RequestPerformanceTrackingServiceLogs slow requests above a configurable threshold
AddSharedKernelApplicationCommandBus()Registers all command-bus pipeline services
AddSharedKernelApplicationQueryBus()Registers all query-bus pipeline services

Infrastructure layer

Infrastructure packages contain concrete adapters: the MediatR bus, EF Core contexts and repositories, and the KurrentDB event store.

JordiAragonZaragoza.SharedKernel.Infrastructure

MediatR bus wires, caching, context services, and DI helpers.Depends on SharedKernel, SharedKernel.Application, SharedKernel.Domain, MassTransit, MassTransit.RabbitMQ, Ardalis.Result, FluentValidation, and Microsoft.Extensions.Options.
Key typePurpose
CommandBusICommandBus implementation via MediatR
QueryBusIQueryBus implementation via MediatR
InMemoryEventBusIEventBus implementation for in-process domain-event dispatch
CacheServiceICacheService implementation using IMemoryCache / IDistributedCache
DateTimeServiceIDateTime implementation wrapping DateTimeOffset.UtcNow
IdGeneratorServiceIIdGenerator backed by Guid.NewGuid()
UserContextServiceIUserContextService reading from IHttpContextAccessor claims
PartitionContextServiceMulti-tenant partition resolution
IdentityServiceIIdentityService implementation
AddSharedKernelInfrastructure()Registers all singleton/transient infrastructure services
AddSharedKernelInfrastructureCommandBus()Registers MediatR pipeline + ICommandBus
AddSharedKernelInfrastructureQueryBus()Registers MediatR pipeline + IQueryBus
AddSharedKernelInfrastructureProjections()Registers projection event bus

JordiAragonZaragoza.SharedKernel.Infrastructure.EntityFramework

EF Core base contexts and Ardalis Specification repositories.Depends on Ardalis.Specification.EntityFrameworkCore, Ardalis.SmartEnum.EFCore, and Microsoft.EntityFrameworkCore.
Key typePurpose
BaseContextBase DbContext that configures logging, sensitive-data logging, and Ardalis SmartEnum EF Core conventions
BaseBusinessModelContextSpecialised context for the write (business model) side
BaseReadModelContextSpecialised context for the read-model / projections side
BaseProjectionsStoreEF Core store for projection read models
BaseRepository<T, TId>Full read/write repository implementing Ardalis IRepository
BaseReadRepository<T, TId>Read-only repository implementing Ardalis IReadRepository
BaseCachedSpecificationRepository<T, TId>Caching wrapper for specification-based queries
BaseAggregateRootTypeConfiguration<T, TId>EF Core IEntityTypeConfiguration base for aggregate roots
SoftDeleteEntitySaveChangesInterceptorIntercepts SaveChanges to set DeletedAt instead of deleting rows

JordiAragonZaragoza.SharedKernel.Infrastructure.EventStore

KurrentDB (formerly EventStoreDB) event-sourcing integration.Depends on KurrentDB.Client and Newtonsoft.Json.
Key typePurpose
IEventStoreAppend and load event streams
KurrentDbEventStoreIEventStore implementation backed by KurrentDB
KurrentDbOptionsConnection and serialization configuration
StreamNameMapperConverts aggregate type + ID to a stream name string
EventTypeMapperBidirectional mapping between CLR event types and stream event-type names
BaseRepository<T, TId>Event-sourced aggregate repository using IEventStore
KurrentDbAllStreamSubscriptionCatch-up subscription worker for all-stream projections
AllStreamSubscriptionBackgroundWorkerIHostedService wrapper for persistent catch-up subscriptions

Presentation layer

Presentation packages add HTTP and messaging surface to your application. They depend on the Application contracts but remain ignorant of Infrastructure internals.

JordiAragonZaragoza.SharedKernel.Presentation.HttpRestfulApi

ASP.NET Core controllers, middleware, and response helpers.Depends on FastEndpoints, Ardalis.Result, SharedKernel.Application.Contracts, and SharedKernel.Infrastructure.
Key typePurpose
BaseApiCommandControllerControllerBase subclass pre-wired with ICommandBus
BaseApiQueryControllerControllerBase subclass pre-wired with IQueryBus
ExceptionMiddlewareConverts unhandled exceptions to ProblemDetails JSON responses
UserContextMiddlewarePopulates IUserContextService from the JWT bearer token
PartitionContextMiddlewarePopulates IPartitionContextService from request headers or claims
ResponseBuilderHelperMaps Result<T> to typed ActionResult<T> with correct HTTP status codes
ResultExtensionsExtension methods for translating Result to IResult (minimal APIs)

JordiAragonZaragoza.SharedKernel.Presentation.HttpRestfulApi.Contracts

HTTP presentation contracts shared between service and client.Minimal dependencies — safe to reference from API client projects.
Key typePurpose
Request/response DTOsShared contract types for HTTP endpoints
Pagination contractsPaginatedRequest and related types for consistent pagination

JordiAragonZaragoza.SharedKernel.Presentation.Integration

MassTransit integration event bus producers and consumers.Depends on MassTransit, MassTransit.RabbitMQ, and SharedKernel.Application.Contracts.Integration.
Key typePurpose
IntegrationEventBusIIntegrationEventBus implementation publishing via MassTransit
Integration consumersBase consumer wiring for receiving integration events
Integration producersHelpers for publishing integration events to the message broker

JordiAragonZaragoza.SharedKernel.Presentation.Integration.Contracts

Integration presentation contracts.No infrastructure dependencies — safe to reference from any service that needs to describe integration message shapes.
Key typePurpose
IIntegrationEventHandler<T>Consumer handler contract for integration events
Integration message base typesShared record bases for versioned integration messages

Build docs developers (and LLMs) love