Boutquin.Domain 0.7.0

dotnet add package Boutquin.Domain --version 0.7.0
                    
NuGet\Install-Package Boutquin.Domain -Version 0.7.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="Boutquin.Domain" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Boutquin.Domain" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Boutquin.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 Boutquin.Domain --version 0.7.0
                    
#r "nuget: Boutquin.Domain, 0.7.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 Boutquin.Domain@0.7.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=Boutquin.Domain&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Boutquin.Domain&version=0.7.0
                    
Install as a Cake Tool

Boutquin.Domain

Nuget License

A .NET domain layer library providing DDD building blocks, guard clauses, result types, JSON converters, and ASP.NET Core middleware for modular monolith applications.

Solution Structure

The solution contains three library projects and a test project:

Project NuGet Package Description
Domain (Boutquin.Domain) boutquin.domain Core domain abstractions, helpers, extensions, converters, and exceptions
Boutquin.AspNetCore ASP.NET Core middleware, module system, and exception handling
Boutquin.Validation FluentValidation integration and validation exception handling
UnitTests (Boutquin.UnitTests) xUnit tests with FluentAssertions (308 tests, ~91% line coverage)

Domain Project

Abstractions

The building blocks for Domain-Driven Design:

  • Entity<TEntityId> — Abstract base class with identity-based equality, domain event buffering, and ORM-compatible constructors.
  • Result / Result<TValue> — Functional error handling — return success/failure instead of throwing exceptions.
  • Error — Immutable record representing a domain error with code and name.
  • IEntity — Interface for entities that generate domain events.
  • IDomainEvent — Marker interface for domain events (implements INotification).
  • IUnitOfWork — Defines the persistence boundary (SaveChangesAsync).

Helpers

  • Guard — Static utility class for parameter validation with two API styles: expression-based (auto-extracts parameter names) and CallerArgumentExpression-based (zero overhead).
  • GuardCondition — Fluent chaining helper for Guard.Against().With<TException>().
  • StronglyTypedId<TValue> — Abstract record for wrapping primitives as domain-specific ID types, preventing primitive obsession.

Extensions

  • StringExtensionsIsNullOrEmpty, IsNullOrWhiteSpace, ToUppercaseFirst, ToLowerCaseFirst, Compare, CompareOrdinal, Format.
  • DateTimeExtensionsConvertTimeZone for converting between time zones.
  • EnumExtensionsGetDescription for retrieving [Description] attribute values.
  • ResultExtensionsMatch methods for functional-style pattern matching on Result types.
  • JsonElementExtensionsToObject<T> for deserializing JsonElement to typed objects.
  • DecimalArrayExtensionsVariance and StandardDeviation for decimal arrays.

Converters

Exceptions

  • DomainExceptions — Self-describing exception hierarchy mapping to HTTP status codes (400–503), plus non-HTTP exceptions for data validation (EmptyOrNullArrayException, InsufficientDataException, etc.).

Boutquin.AspNetCore Project

  • CustomExceptionHandlerMiddleware — Catches unhandled exceptions and produces RFC 7807 ProblemDetails JSON responses with application/problem+json content type.
  • ModuleExtensions — Module discovery, registration, and endpoint mapping for modular monolith applications. Includes an injectable assembly resolver for testability.
  • IModule — Interface for self-registering application modules (RegisterModule + MapEndpoints).

Boutquin.Validation Project

  • ValidationException — Exception wrapping FluentValidation failures with structured error data. Integrates with the middleware to produce grouped error responses.

Quick Start

// 1. Define a domain entity with strongly typed ID:
public record OrderId(Guid Value) : StronglyTypedId<Guid>(Value);

public sealed class Order : Entity<OrderId>
{
    public Order(OrderId id) : base(id) { }

    public void Place()
    {
        // Business logic...
        RaiseDomainEvent(new OrderPlacedEvent(Id));
    }
}

// 2. Use the Result pattern for operations that can fail:
public Result<Order> GetOrder(OrderId id)
{
    var order = repository.Find(id);
    return order is not null
        ? Result.Success(order)
        : Result.Failure<Order>(new Error("Order.NotFound", "Order not found"));
}

// 3. Register modules in Startup:
builder.Services.RegisterModules();
var app = builder.Build();
app.UseCustomExceptionHandler();
app.MapEndpoints();

// 4. Throw domain exceptions — middleware handles the rest:
throw new NotFoundException("Order 42 was not found.");
// -> 404 ProblemDetails JSON response

Architecture

See ARCHITECTURE.md for how the components fit together — layers, interface hierarchy, data flow, and component navigation.

Contributing

See CONTRIBUTING.md for guidelines on reporting bugs, suggesting enhancements, and submitting pull requests. This project adheres to the Contributor Covenant Code of Conduct.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for more information.

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 (4)

Showing the top 4 NuGet packages that depend on Boutquin.Domain:

Package Downloads
Boutquin.Trading.Domain

Common abstractions (entities, enums, exceptions, interfaces, types and logic) specific to a Trading Domain layer.

Boutquin.Validation

FluentValidation integration for Boutquin.Domain — ValidationException with structured error details for RFC 7807 ProblemDetails responses.

Boutquin.AspNetCore

ASP.NET Core middleware and module registration — RFC 7807 exception handler, modular app startup with testable assembly discovery.

Boutquin.Storage.Domain

Domain abstractions for data-intensive storage engines — interfaces for key-value stores, storage indices, Bloom filters, serialization, and LSM-tree components.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.0 212 3/16/2026
0.6.0-beta.2 93 3/14/2026
0.5.3-beta5 313 8/11/2024
0.5.0.3-beta01 189 5/20/2024
0.5.0.2-beta01 153 5/20/2024
0.5.0.1-beta01 190 5/15/2024
0.4.0-beta01 207 4/20/2024
0.3.0-beta01 175 4/16/2024
0.2.1-beta09 179 4/5/2024
0.2.1-beta07 175 3/30/2024
0.2.1-beta05 204 3/16/2024
0.2.1-beta03 207 1/26/2024
0.2.1-beta02 218 1/5/2024
0.2.1-beta01 171 1/4/2024
0.2.0-beta01 181 1/4/2024
0.1.0-beta27 305 5/8/2023
0.1.0-beta26 246 5/8/2023
0.1.0-beta25 269 5/1/2023
0.1.0-beta24 263 5/1/2023
0.1.0-beta22 244 4/30/2023
Loading failed

See CHANGELOG.md for release notes.