mikolaj-jankowski/Clean-Architecture-And-Domain-Driven-Design-Solution-Template
54.3
Adequate · 20 September 2026
3k
lines of production code
C#
primary language
4
measurements over time
What this system is
This system is a .NET 10-based template implementing Clean Architecture and Domain-Driven Design for managing customers and orders. It provides core capabilities for user authentication via Keycloak, customer lifecycle management including email verification, and order processing with domain-driven discount calculations. The architecture supports asynchronous event handling through MassTransit and RabbitMQ, utilizes PostgreSQL for persistence, and employs Redis for caching to ensure data consistency and performance.
Features
Added application exception types for customer and email verification scenarios
The application layer now includes specific exception classes to handle distinct error conditions: \CustomerNotFoundApplicationException\ is thrown when a customer ID is not found, and \EmailAlreadyVerifiedApplicationException\ is thrown when an email address has already been verified. Both inherit from the new base \ApplicationException\ class, providing structured error handling for these common application-level failures.
content/src/CA.And.DDD.Template.Application/Exceptions · high confidence
Added core domain infrastructure classes
The domain layer now includes foundational classes to support domain-driven design patterns: a DomainException for error handling, an abstract Entity base class that manages domain events, an IDomainEvent marker interface, and an IDateTimeProvider interface to abstract time-dependent logic.
content/src/CA.And.DDD.Template.Domain · high confidence
Added customer creation and email change capabilities
The application now supports creating new customers and changing their email addresses. The CreateCustomer command handler accepts full name, birth date, and address details, persists the customer via the repository, and responds with the new customer ID. The ChangeEmail command handler validates the request and updates the customer's email. Both features include input validation rules for field lengths and non-empty values, and the creation flow integrates with the event bus to publish a CustomerCreatedIntegrationEvent for cross-module notification.
content/src/CA.And.DDD.Template.Application/Customer/CreateCustomer · high confidence
Added customer email verification capability
Users can now verify their email addresses through a new command-based workflow. This change introduces the VerifyEmailCommand and its handler, which locates the customer, validates that the email is not already verified, and marks the address as verified. Input validation ensures the customer ID is present, and appropriate exceptions are thrown if the customer is not found or the email is already verified. Additionally, a domain event handler is provided to allow for follow-up actions, such as sending a confirmation notification, once the verification is complete.
content/src/CA.And.DDD.Template.Application/Customer/VerifyEmail · high confidence
Added shared infrastructure for caching, email delivery, and time abstraction
The Shared layer now includes a distributed cache service (CacheService) with configurable expiration and a key builder for customer-specific keys, an email service (EmailService) that sends welcome emails using templated HTML content via SMTP, and a DateTimeProvider for abstracting time to support testing. These components enable reliable caching, customizable email notifications, and testable time-dependent logic within the application.
content/src/CA.And.DDD.Template.Infrastructure/Shared · high confidence
Added welcome email template and type enumeration
The system now includes a new email template type enumeration (WelcomeEmail, OrderConfirmation) and a corresponding HTML template for the welcome email. This enables the application to send a styled welcome message to new users, featuring a containerized layout with a call-to-action button and footer, using placeholders like {{FullName}} for personalization.
content/src/CA.And.DDD.Template.Domain/Enums, content/src/CA.And.DDD.Template.Infrastructure/EmailTemplates · high confidence
Automatic welcome email sent on customer creation
A new domain event handler now automatically sends a welcome email to a customer immediately after they are created. This handler listens for the CustomerCreatedDomainEvent, uses the injected email service and template factory to personalize the message with the customer's full name, and dispatches it via the messaging infrastructure (configured to use Mailhog for local development).
content/src/CA.And.DDD.Template.Application/Customer/CreateCustomer/DomainEventHandlers · high confidence
Background services for domain and integration event processing added
The template now includes two new background services, DomainEventsProcessor and IntegrationEventsProcessor, which run as hosted services to handle eventual consistency. These services poll a PostgreSQL database (using Npgsql) to retrieve pending domain and integration events respectively, dispatch them via the domain event dispatcher or MassTransit's publish endpoint, and mark them as processed. This shifts event handling from synchronous in-transaction dispatch to an asynchronous background pattern.
content/src/CA.And.DDD.Template.Infrastructure/BackgroundTasks · high confidence
Initial EF Core configuration and repository for Customer persistence
The Customer entity is now persisted using Entity Framework Core with specific mappings for value objects (CustomerId, FullName, Age, Email) and a complex Address type, including a unique index on Email and row-versioning for concurrency. A new CustomerRepository implements ICustomerRepository, providing methods to add customers and retrieve them by ID, throwing a NotFoundException if the customer does not exist.
content/src/CA.And.DDD.Template.Infrastructure/Persistance/Configuration/Domain/Customers · high confidence
Initial Web API scaffolding with authentication, caching, and API documentation
The WebApi project is now configured as a complete ASP.NET Core application featuring Keycloak-based authentication, Redis-backed caching, and Scalar API documentation. It exposes endpoints for customer and order management, including a paginated browse-orders query, and supports email verification workflows. The service is containerized via a new Dockerfile and connects to PostgreSQL (configured in appsettings.json) with MassTransit for messaging and OpenTelemetry for telemetry.
content/src/CA.And.DDD.Template.WebApi · high confidence
Initial persistence configuration and repository for Orders
This change introduces the Entity Framework Core configuration and repository implementation for the Order aggregate. It defines the database schema mapping for Order, OrderItem, and related value objects (such as TotalAmount, Discount, and ShippingAddress), including specific column types like 'timestamp with time zone' for order dates. The new OrderRepository implements IOrderRepository, providing methods to add orders, retrieve them by ID with associated items, and calculate the total amount spent by a customer in the last 31 days.
content/src/CA.And.DDD.Template.Infrastructure/Persistance/Configuration/Domain/Orders · high confidence
Initial project scaffolding with Keycloak authentication and Docker support
The content area now provides a complete, runnable template structure for a Clean Architecture DDD application. It introduces Keycloak-based authentication via a new \KeycloakAuthenticationService\ that handles password and refresh token grants, alongside a \docker-compose.yml\ file that orchestrates the required infrastructure (Keycloak, PostgreSQL, Redis, RabbitMQ, MailHog, and the Aspire dashboard). The solution is configured for .NET 10 (SDK 10.0.101) and includes the \.dockerignore\ and solution file to support this containerized development environment.
content · high confidence
Introduce order discount policies and domain service
The Orders domain now supports two distinct discount mechanisms: an order-based discount applied automatically when the cart total exceeds $600 or $800, and a loyalty discount based on a customer's spending in the last 31 days, calculated via the new OrderDomainService. This change introduces specific discount policies (AmountBasedDiscountPolicy and TotalSpentMoneyInLast31DaysDiscountPolicy), a Discount record, and enforces a maximum item quantity of 5 per order.
content/src/CA.And.DDD.Template.Domain/Orders · high confidence
Introduced Customer domain model with value objects and domain events
Added the core Customer aggregate to the domain layer, including the Customer entity and value objects for Address, Age, Email, FullName, and CustomerId. These value objects enforce business rules such as minimum age (18), email format validation, and field length limits. The Customer entity now supports creation, email changes, and email verification, emitting corresponding domain events (CustomerCreated, CustomerEmailChanged, CustomerEmailVerified) to facilitate event-driven workflows. A basic repository interface (ICustomerRepository) for adding and retrieving customers was also defined.
content/src/CA.And.DDD.Template.Domain/Customers · high confidence
Introduces Keycloak authentication, pagination, and caching infrastructure
This update adds the application-layer support for Keycloak-based authentication, allowing users to log in and refresh access tokens via password grant. It also introduces pagination capabilities for browsing customers and orders, ensuring consistent handling of page size and sorting limits. Additionally, shared interfaces for caching, email services, and read models are added to support these new features and improve performance.
content/src/CA.And.DDD.Template.Application/Shared · high confidence
Introduction of Entity Framework Core database context for SQL Server
The infrastructure layer now includes a new AppDbContext class that configures Entity Framework Core for Microsoft SQL Server. This context exposes DbSet properties for Order and Customer entities and automatically applies model configurations from the assembly, establishing the persistence mechanism for these domain entities.
content/src/CA.And.DDD.Template.Infrastructure/Persistance/MsSql · high confidence
New API controllers for user authentication, customer management, and order operations
The API surface now includes dedicated controllers to handle core domain operations. The UserController exposes endpoints for user login and token refresh. The CustomersController provides APIs to create customers, retrieve customer details, and manage email changes and verification. The OrdersController allows users to create orders, retrieve specific order details, and browse orders. Additionally, an AdminController has been introduced to allow administrators to browse customers, secured by an AdminPolicy.
content/src/CA.And.DDD.Template.WebApi/Controllers · high confidence
New Create Order command with domain-service discount calculation
The application now includes a new CreateOrder command handler that processes order creation requests. The handler validates input (customer ID, shipping address, and product list) and delegates discount calculation to the OrderDomainService based on the customer's spending in the last 31 days, rather than calculating it within the order entity itself. The command returns the created order ID and triggers an OrderCreated domain event, which is currently handled by a stubbed email notification consumer.
content/src/CA.And.DDD.Template.Application/Order/CreateOrder · high confidence
New infrastructure configuration settings
The application now includes a structured configuration model in the infrastructure layer, introducing settings for Redis, caching, RabbitMQ, SQL Server, SMTP email, Keycloak authentication, CORS, and telemetry. This allows these external services and security policies to be configured via standard configuration sources.
content/src/CA.And.DDD.Template.Infrastructure/Settings · high confidence
New read services for admin, customer, and order queries
The infrastructure layer now includes dedicated read services (AdminReadService, CustomerReadService, OrderReadService) that implement the application's read interfaces. These services provide paginated browsing for customers and orders, single-entity retrieval for customers and orders, and raw SQL query execution capabilities, all utilizing Entity Framework Core with cancellation token support and optimized query patterns like AsNoTracking and AsSplitQuery.
content/src/CA.And.DDD.Template.Infrastructure/ReadServices · high confidence
Behavioural changes
Cache invalidation on customer email change
A new domain event handler has been added to automatically invalidate the cached customer profile when a customer's email address is updated. This ensures that subsequent requests for the customer's data retrieve the latest information rather than a stale cached version, maintaining data consistency across the application.
content/src/CA.And.DDD.Template.Application/Customer/ChangeEmail/DomainEventHandlers · high confidence
Infrastructure wiring for Keycloak auth, PostgreSQL, and OpenTelemetry
The Installers directory now registers the full infrastructure stack: Keycloak-based JWT authentication with role extraction, a PostgreSQL database context (configured via Npgsql), OpenTelemetry tracing/metrics/logs sent via OTLP, and Redis caching. It also sets up MassTransit with RabbitMQ, Swagger with annotations, and CORS, providing the concrete DI registrations that enable these capabilities.
content/src/CA.And.DDD.Template.Infrastructure/Installers · high confidence
Initial database schema for PostgreSQL
The application now includes an initial Entity Framework Core migration targeting PostgreSQL, replacing the previous SQL Server setup. This migration creates the foundational tables for the domain model: Customers (with unique email indexing and address details), Orders (linked to customers, including shipping address and discount/total amount fields), OrderItems, and infrastructure tables for tracking DomainEvents and IntegrationEvents. Users deploying this version will have their database initialized with this schema structure upon running the migration.
content/src/CA.And.DDD.Template.Infrastructure/Migrations · high confidence
MassTransit message processing pipeline with validation, sanitization, and event mapping
The infrastructure layer now includes a set of MassTransit filters that process incoming messages through a standardized pipeline. The ValidationFilter uses FluentValidation to reject messages that fail schema checks, while the HtmlSanitizerFilter ensures message content is safe by throwing an exception if dangerous scripts are detected. The EventsFilter handles domain-to-integration event mapping, persisting domain events to the database and converting them into integration events via the new EventMapperFactory and CustomerCreatedEventMapper. Additionally, the LoggingFilter tracks operation duration for observability, and the RedisFilter increments a daily request counter in Redis for monitoring purposes.
content/src/CA.And.DDD.Template.Infrastructure/Filters · high confidence
Order retrieval now uses caching and a dedicated read service
The GetOrder capability has been refactored to improve performance and separation of concerns. The query handler now implements the Cache Aside Pattern, checking Redis via ICacheService before falling back to the new IOrderReadService for database access. This change introduces a dedicated read-model path for order data, decoupling the retrieval logic from the domain model, and includes validation for the order ID to ensure requests are well-formed.
content/src/CA.And.DDD.Template.Application/Customer/GetCustomer, content/src/CA.And.DDD.Template.Application/Order/GetOrder · high confidence
Paginated order browsing with cancellation support
The Browse Orders endpoint now supports pagination, allowing users to retrieve orders in manageable chunks rather than loading the entire collection at once. This change introduces a new query structure that accepts pagination parameters and returns a total count alongside the requested page of orders. Additionally, the underlying read service integration now supports cancellation tokens, enabling requests to be aborted if they take too long or are no longer needed, improving responsiveness and resource management.
content/src/CA.And.DDD.Template.Application/Order/BrowseOrders · high confidence
PostgreSQL-specific configuration for domain and integration events
The persistence layer now includes explicit Entity Framework Core configurations for \DomainEvent\ and \IntegrationEvent\ entities tailored for PostgreSQL. These configurations define primary keys and enforce specific column types, notably using \timestamp with time zone\ for date fields and setting default values via \CURRENT\_TIMESTAMP AT TIME ZONE 'UTC'\, ensuring correct time handling in the PostgreSQL database.
content/src/CA.And.DDD.Template.Infrastructure/Persistance/Configuration/Infrastructure · high confidence
Structured exception handling for validation and not-found errors
The application now includes specific exception types and a dedicated handler to improve error responses. When a validation error occurs, the system throws a CommandValidationException, which the new handler catches to return a standardized 400 Bad Request response containing the specific field-level validation errors in the response body. Additionally, a NotFoundException is introduced to handle cases where a requested resource is missing, ensuring consistent error reporting for these common scenarios.
content/src/CA.And.DDD.Template.Infrastructure/Exceptions · high confidence
Test coverage
Added unit tests for Customer and Order domain entities; Added unit tests for customer creation and email change workflows; Added unit tests for the GetOrder query handler.
Dependencies
Upgrade to .NET 10 and update dependencies
The template project and its sub-projects (Application, Domain, Infrastructure, WebApi, and test projects) have been migrated to the .NET 10.0 target framework. This update includes upgrading core dependencies such as MassTransit to version 9.0.0-develop.37, Microsoft.AspNetCore packages to 10.0.1, Npgsql.EntityFrameworkCore.PostgreSQL to 10.0.0, and OpenTelemetry components to version 1.14.0. The nuget-package.csproj manifest has also been updated to version 10.0.0 to reflect this major platform shift.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 51 → 54 (+3.0)
- Rubric changed (rubric-2026.08.18 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 79 → 77 (-2.1)
- Architecture 76 → 76 (-0.7)
- Maturity 63 → 65 (+1.5)
- Readiness 41 → 42 (+1.3)
- Security 64 → 64 (-0.1)
- Domain Modelling 55 → 79 (+24.3)
- Event-Driven 100 → 100 (+0.0)
- Performance 60 → 60 (+0.0)
Resolved (7)
- Bounded contexts not declared
- Coverage not measured
- LLM evaluation failed
- Medium CVE: OpenTelemetry.Exporter.OpenTelemetryProtocol 1.14.0
- Medium CVE: OpenTelemetry.Exporter.OpenTelemetryProtocol 1.14.0
- Medium CVE: OpenTelemetry.Exporter.OpenTelemetryProtocol 1.14.0
- Off-boarding risk: anonymized user #1
New (31)
- CommentedOutCode (content/tests/CA.And.DDD.Template.Infrastructure.UnitTests/Queries/GetCustomer/GetCustomerQueryHandlerTests.cs)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Duplicated block (12 lines × 2) (content/src/CA.And.DDD.Template.Infrastructure/BackgroundTasks/DomainEventsProcessor.cs)
- Duplicated block (12 lines × 2) (content/src/CA.And.DDD.Template.Infrastructure/BackgroundTasks/DomainEventsProcessor.cs)
- Duplicated block (21–23 lines × 2) (content/src/CA.And.DDD.Template.Infrastructure/Authentication/KeycloakAuthenticationService.cs)
- Duplicated block (6 lines × 2) (content/src/CA.And.DDD.Template.Infrastructure/Persistance/Configuration/Infrastructure/DomainEventConfiguration.cs)
- High IaC: DS-0009 (content/src/CA.And.DDD.Template.WebApi/Dockerfile)
- High IaC: WD-COMPOSE-0002 (content/docker-compose.yml)
- High IaC: WD-COMPOSE-0002 (content/docker-compose.yml)
- High IaC: WD-COMPOSE-0002 (content/docker-compose.yml)
- IL efficiency: 3 authored method(s) exceed the IL budget (content/src/CA.And.DDD.Template.Infrastructure/Persistance/Configuration/Domain/Customers/CustomerConfiguration.cs)
- Inconsistent namespace spelling: 'Persistance' is used instead of the standard 'Persistence'. While this is a consistent typo across the codebase, it is a spelling error that should be corrected for professional consistency.
- Low IaC: DS-0026 (content/src/CA.And.DDD.Template.WebApi/Dockerfile)
- Medium CVE: OpenTelemetry.Exporter.OpenTelemetryProtocol 1.14.0
- Medium IaC: WD-COMPOSE-0002 (content/docker-compose.yml)
- Medium IaC: WD-COMPOSE-0002 (content/docker-compose.yml)
- Medium IaC: WD-COMPOSE-0002 (content/docker-compose.yml)
- Medium IaC: WD-DOCKER-0003 (content/src/CA.And.DDD.Template.WebApi/Dockerfile)
- Medium IaC: WD-DOCKER-0003 (content/src/CA.And.DDD.Template.WebApi/Dockerfile)
- …and 11 more
API surface
- Unchanged — 8 HTTP endpoints
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
mikolaj-jankowski/Clean-Architecture-And-Domain-Driven-Design-Solution-Template was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit c3bebd2a7d39c7e46291073075df0fd4f585cec8 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-28e75b8e3254.