Kongroo.BuildingBlocks.Domain 0.1.0

dotnet add package Kongroo.BuildingBlocks.Domain --version 0.1.0
                    
NuGet\Install-Package Kongroo.BuildingBlocks.Domain -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kongroo.BuildingBlocks.Domain" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kongroo.BuildingBlocks.Domain" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Kongroo.BuildingBlocks.Domain" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kongroo.BuildingBlocks.Domain --version 0.1.0
                    
#r "nuget: Kongroo.BuildingBlocks.Domain, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kongroo.BuildingBlocks.Domain@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kongroo.BuildingBlocks.Domain&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Kongroo.BuildingBlocks.Domain&version=0.1.0
                    
Install as a Cake Tool

🦘 Kongroo.BuildingBlocks.Domain

CI NuGet Downloads License: MIT

DDD tactical building blocks for the domain layer of my .NET microservices — entities, aggregate roots, domain events, strongly-typed ids, and a domain-exception hierarchy. Dependency-free (BCL only) and AOT-compatible, so it stays at the center of a clean-architecture dependency graph.

Installation

dotnet add package Kongroo.BuildingBlocks.Domain

Building blocks

Type Purpose
Entity<TId> Identity-equality base with a required init, strongly-typed Id
AggregateRoot<TId> Consistency boundary that buffers domain events ([NotMapped])
IHasDomainEvents Hook for infrastructure to collect buffered events (e.g. an outbox)
IDomainEvent Marker for domain events
DomainEvent Optional event base record with a UUIDv7 EventId and UTC OccurredAt
IStronglyTypedId / IStronglyTypedId<TSelf, TValue> Typed-id markers enforcing a static From factory
IGuidId<TSelf> Guid-backed typed id, additionally enforcing a static Create factory
DomainException (+ ConflictException, NotFoundException, UnauthorizedException) Domain error channel; map to HTTP/problem-details in your API's exception handler

Usage

using Kongroo.BuildingBlocks.Domain;
using Kongroo.BuildingBlocks.Domain.Exceptions;

// Strongly-typed id — implement the two one-line factories:
public readonly record struct OrderId(Guid Value) : IGuidId<OrderId>
{
    public static OrderId From(Guid value) => new(value);
    public static OrderId Create() => From(Guid.CreateVersion7());
}

// Domain event carrying standard metadata (EventId + OccurredAt):
public sealed record OrderPlaced(OrderId OrderId) : DomainEvent;

// Aggregate root — identity equality plus a buffered domain-event stream:
public sealed class Order : AggregateRoot<OrderId>
{
    public static Order Place() => new() { Id = OrderId.Create() };

    public void Confirm()
    {
        if (DomainEvents.Count > 0)
        {
            throw new ConflictException(nameof(Order), "already placed");
        }

        RaiseDomainEvent(new OrderPlaced(Id));
    }
}

After persisting an aggregate, infrastructure detects IHasDomainEvents to dispatch its buffered events and then call ClearDomainEvents(). Strongly-typed ids carry no converters of their own — wire generic JSON / EF Core converters off IStronglyTypedId<TSelf, TValue> and its TSelf.From(value) factory.

Design notes

  • Value objects are plain C# record / readonly record struct types — records already give value equality, so the kernel ships no ValueObject base.
  • Errors are exceptions, not a Result<T> type: throw a DomainException and let the API layer translate it.
  • Identity is exact-type: two entities are equal only when their concrete type and Id match.
  • Strongly-typed ids use static-abstract interface members (the INumber<TSelf> mechanism), so the From / Create factories are reachable from generic infrastructure with no reflection.

What's baked in

  • Target: net10.0, nullable + implicit usings, warnings-as-errors, latest .NET analyzers + SonarAnalyzer.
  • Zero dependencies: BCL only, IsAotCompatible.
  • API stability: the public surface is tracked with the public-API analyzer.
  • Packaging: deterministic build, SourceLink, symbols (snupkg), and a MinVer-derived version.

Requirements

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Kongroo.BuildingBlocks.Domain:

Package Downloads
Kongroo.BuildingBlocks.Application

DDD application building blocks (domain-event dispatch, CQRS contracts, unit of work, integration events, startup initializers) for Kongroo microservice application layers.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 229 6/27/2026

See the project's GitHub Releases for changes.