SSWConsulting/SSW.CleanArchitecture
62.0
Adequate · 8 November 2026
2k
lines of production code
C#
primary language
7
measurements over time
What this system is
This system is a .NET 10 web API that manages superheroes and teams, allowing users to create heroes, assign them to teams, and track mission statuses. It implements a Clean Architecture with Domain-Driven Design patterns, utilizing CQRS via MediatR for command and query handling, and persists data using Entity Framework Core with SQL Server. The application includes robust infrastructure for validation, error handling, and eventual consistency, supported by automated database migrations and comprehensive integration tests.
How it got here
2023 — Clean Architecture v2026.03.10 template
14 changes.
The project released version 2026.03.10 of the SSW Clean Architecture template, upgrading the target framework to .NET 10 and integrating .NET Aspire for service defaults and observability. The solution was restructured to demonstrate a Superhero and Team domain using Clean Architecture principles, featuring CQRS with MediatR, FluentValidation, and automated audit tracking via EF Core interceptors. Additionally, developer productivity was enhanced through new CLI templates for scaffolding commands and queries, alongside centralized package management.
2024–2025 — Domain modeling and API implementation
23 changes.
This period focused on implementing the core domain logic for Heroes and Teams using Domain-Driven Design patterns, including aggregates, value objects, and event handling. The work extended to the application and infrastructure layers, establishing API endpoints, database persistence with Entity Framework Core, and a migration service for local development. Comprehensive testing was added to validate architecture rules, domain behavior, and integration flows.
Features
Add CurrentUserService implementation
A new CurrentUserService class has been added to the WebApi project to implement the ICurrentUserService interface. This service extracts the current user's identifier from the HTTP context claims, enabling other parts of the application to reliably access the authenticated user's ID.
src/WebApi/Services · high confidence
Add Entity Framework DbContext health check
The application now includes a dedicated health check for Entity Framework DbContexts, verifying both database connectivity and the execution of a custom test query (defaulting to a sample query against the Heroes table). This is registered alongside the existing SQL Server connectivity check, providing a more comprehensive view of database health by validating that the DbContext, DI, and configurations are functioning correctly.
src/WebApi/HealthChecks · high confidence
Added CQRS command and query item templates
Developers can now scaffold new CQRS command and query handlers directly into their projects using the new \ssw-ca-command\ and \ssw-ca-query\ dotnet CLI short names. These templates generate the command/query record, a handler pre-configured with \IApplicationDbContext\ injection, and an associated validator, providing a structured starting point for implementing Clean Architecture use cases.
templates · high confidence
Added MediatR pipeline behaviors for logging, performance monitoring, error handling, and validation
The application now includes four new MediatR pipeline behaviors in the Common/Behaviours directory to enhance request processing. LoggingBehaviour logs incoming requests and user context before processing. PerformanceBehaviour monitors request duration and logs warnings for operations exceeding 500ms. UnhandledExceptionBehaviour catches and logs exceptions during request handling while re-throwing them. ValidationErrorOrResultBehavior integrates validation logic, converting validation failures into error results for requests expecting IErrorOr responses.
src/Application/Common/Behaviours · high confidence
Added middleware for eventual consistency domain event processing
A new \EventualConsistencyMiddleware\ has been introduced to handle domain events after an HTTP response is completed. This middleware ensures that domain events, which are queued during request processing, are published asynchronously via the MediatR \IPublisher\ within a database transaction strategy, supporting eventual consistency patterns in the application.
src/Infrastructure/Middleware · high confidence
Added on-demand database drop command for Azure SQL resources
The AppHost now includes a new 'drop-database' command available for Azure SQL database resources. This feature allows users to manually trigger the deletion of the associated database directly from the Aspire dashboard or CLI, providing a convenient way to clean up resources on demand without needing external tools.
tools/AppHost/Commands · high confidence
Adds Entity Framework Core configuration for domain entities
This change introduces persistence configuration classes for the Hero, Mission, and Team domain entities, enabling their storage in the database. It defines column constraints such as primary keys, required fields, and maximum string lengths for properties like Name, Alias, and Description. Additionally, it configures the Hero entity to serialize its Powers collection as JSON rather than using a separate table, and registers Vogen strong-typed ID converters to ensure proper handling of TeamId, HeroId, and MissionId in Entity Framework Core.
src/Infrastructure/Persistence/Configuration · high confidence
Application layer bootstrapping with MediatR and FluentValidation
The Application layer now initializes its core infrastructure via a new DependencyInjection class, registering FluentValidation validators, MediatR handlers, and specific behaviors including ValidationErrorOrResultBehavior, UnhandledExceptionBehaviour, and PerformanceBehaviour. GlobalUsings have been added to streamline references to FluentValidation, MediatR, Ardalis.Specification.EntityFrameworkCore, ErrorOr, and Microsoft.EntityFrameworkCore.
src/Application · high confidence
Automated audit tracking and configurable domain event dispatching
The persistence layer now includes two new interceptors to handle cross-cutting concerns automatically. EntitySaveChangesInterceptor automatically populates Created/Updated timestamps and user IDs on auditable entities before database saves. DispatchDomainEventsInterceptor handles domain event publishing after saves, supporting both immediate publishing for synchronous requests and queuing for eventual consistency in asynchronous scenarios.
src/Infrastructure/Persistence/Interceptors · high confidence
Initial WebApi project structure with .NET Aspire and Scalar API documentation
The WebApi project has been initialized with a new entry point (Program.cs) and dependency injection setup. It integrates .NET Aspire service defaults, configures Scalar for OpenAPI documentation, and registers health checks. The API exposes endpoints for Heroes and Teams, including operations to create heroes, manage teams, and complete missions. Configuration defaults to a SQL server on port 1500.
src/WebApi · high confidence
Initial database schema for Heroes, Teams, and Missions
The persistence layer now includes an initial migration that establishes the database schema for the new domain entities. This creates the 'Teams', 'Heroes', and 'Mission' tables, defining relationships such as Heroes belonging to Teams and Missions belonging to Teams with cascade deletion. The schema also includes audit fields (CreatedAt, CreatedBy, UpdatedAt, UpdatedBy) and stores Hero powers as JSON within the Heroes table.
src/Infrastructure/Persistence/Migrations · high confidence
Introduce .NET Aspire AppHost for local development and Azure deployment
Added a new AppHost project that uses .NET Aspire to orchestrate the application's services. This enables developers to run the API, database (SQL Server 2022 container), and migration services locally with integrated observability via the Aspire Dashboard. For production, the AppHost configures deployment to Azure App Service, including a Basic tier plan, persistent SQL Server container for local dev, and conditional setup of Application Insights and Log Analytics when publishing.
tools/AppHost · high confidence
Introduce .NET Aspire service defaults and infrastructure dependency injection
The Infrastructure layer now bootstraps the application using .NET Aspire conventions. A new \DependencyInjection.cs\ registers the \ApplicationDbContext\ with SQL Server, enabling strongly typed exception processing and domain event dispatching via interceptors, while also registering the system \TimeProvider\. Additionally, \ServiceDefaults/Extensions.cs\ adds standard Aspire capabilities, including OpenTelemetry instrumentation for logging, metrics, and tracing, service discovery, default HTTP resilience handlers, and health check endpoints (\/health\, \/alive\) that are exposed in development environments.
src/Infrastructure · high confidence
Introduce Heroes and Teams domain aggregates with DDD patterns
The Domain layer now includes core aggregates for Heroes and Teams, implementing Domain-Driven Design patterns such as Aggregate Roots, Value Objects, and Strongly Typed IDs (using Vogen). Heroes can be created with name and alias, manage a list of Powers with validation, and raise domain events when their power level changes. Teams can be created, have heroes added or removed (automatically recalculating total power level), and manage missions with status transitions (Available, OnMission, Complete). The implementation uses built-in .NET guard clauses for validation instead of external libraries and leverages Guid.CreateVersion7() for ID generation.
Domain · high confidence
Introduce application interfaces for database context and current user service
The application layer now exposes two new interfaces to decouple core concerns: \IApplicationDbContext\ defines the data access contract by exposing \DbSet\ collections for \Hero\ and \Team\ entities along with \SaveChangesAsync\, and \ICurrentUserService\ provides access to the authenticated user's ID via a \UserId\ property. These interfaces establish the foundational abstractions for data persistence and user context within the application layer.
src/Application/Common/Interfaces · high confidence
Introduces domain models and error handling for Teams and Heroes
This change adds the core domain structures for the Teams and Heroes aggregates, including status enums (TeamStatus, MissionStatus) and specific error definitions (TeamErrors, HeroErrors, MissionErrors) to support robust validation. It also introduces Specification pattern implementations (TeamSpec, HeroSpec) to standardize how teams and heroes are queried, including eager loading of related missions and heroes for team lookups.
src/Domain/Teams · high confidence
Introduces foundational domain base classes and interfaces
Adds core infrastructure classes to the domain layer, including \Auditable\ and \Entity\<TId\>\ base classes that provide creation/modification tracking and identity management, alongside interfaces for aggregate roots (\IAggregateRoot\), auditable entities (\IAuditable\), and value objects (\IValueObject\). Also introduces support for eventual consistency error handling via \EventualConsistencyError\ and \EventualConsistencyException\ types.
src/Domain/Common · high confidence
New Hero and Team API endpoints
The API now exposes dedicated endpoints for managing heroes and teams. Users can create, update, and retrieve heroes via the /heroes route, and manage teams (create, list, get details, add heroes, execute missions, and complete missions) via the /teams route. These endpoints are implemented using the MediatR pattern to dispatch commands and queries to the application layer.
src/WebApi/Endpoints · high confidence
New MigrationService for automated database initialization
A new standalone MigrationService has been introduced to handle database schema creation and data seeding via a hosted background worker. This service registers an \ApplicationDbContextInitializer\ and a \MigrationUserService\ (implementing \ICurrentUserService\ with a static ID) to ensure proper context during migration operations. The worker executes \EnsureDatabaseAsync\ and \CreateSchemaAsync\ on startup, and conditionally runs \SeedDataAsync\ in the Development environment, providing a dedicated mechanism for infrastructure setup separate from the main application lifecycle.
tools/MigrationService · high confidence
New database initialization and seeding logic for the Migration Service
The Migration Service now includes a new \ApplicationDbContextInitializer\ and a base \DbContextInitializerBase\ class to handle database setup and data population. The base class provides methods to ensure the database exists and to create the schema, supporting both migration-based and direct table creation strategies. The specific initializer adds logic to seed the database with sample Hero and Team data using the Bogus library if the tables are empty, enabling immediate usability of the application with test data upon first run.
tools/MigrationService/Initializers · high confidence
SSW Clean Architecture Template v2026.03.10 for .NET 10
The template has been updated to version 2026.03.10 and now targets .NET 10.0, requiring the .NET 10 SDK to build. It introduces a new solution structure using the .slnx format and includes a comprehensive .editorconfig to enforce consistent code style and formatting. The template also provides a new AGENTS.md file to document the architecture and usage patterns, alongside standard repository governance files like a Code of Conduct and Security Policy.
(repo-wide) · high confidence
Behavioural changes
Enhanced API conventions and error handling
The API layer now provides standardized conventions for minimal endpoints, including helper methods to automatically document HTTP response codes for GET, POST, PUT, and DELETE operations. Error handling has been improved with custom problem details that attach request IDs and trace identifiers to error responses, and a new result pattern that maps domain errors to appropriate HTTP status codes (such as 409 Conflict or 400 Bad Request). Additionally, the API groupings now automatically apply an 'api' prefix and OpenAPI tags, and Scalar API Reference documentation is configured with default C\# HttpClient settings.
src/WebApi/Extensions · high confidence
Heroes use cases migrated to manual mapping and Vogen strong IDs
The Heroes application layer now uses manual property mapping instead of AutoMapper, and strongly typed IDs via Vogen. CreateHero and UpdateHero commands return ErrorOr\<Guid\> and validate inputs inline, while GetAllHeroes queries project directly into DTOs without an intermediate mapping library.
src/Application/UseCases/Heroes · high confidence
Introduce new ApplicationDbContext for Superhero and Team domains
The persistence layer now features a new ApplicationDbContext that replaces the previous Todo-centric model. This context exposes DbSets for Hero and Team entities, applies configuration from the current assembly, and registers Vogen EF Core converters to support strongly typed IDs within the domain model.
src/Infrastructure/Persistence · high confidence
Standardized global imports for domain layer
The domain layer now uses a centralized GlobalUsings file to automatically import common namespaces, including Ardalis.Specification, ErrorOr, Vogen, and specific static extension methods for argument validation (ArgumentException, ArgumentNullException, ArgumentOutOfRangeException). This simplifies individual source files by removing the need for explicit using statements for these frequently used types.
src/Domain · high confidence
Teams use cases migrated to ErrorOr return types and manual mappers
The Teams application layer has been refactored to replace AutoMapper with manual mapping and to adopt the ErrorOr pattern for command and query results. Commands such as CreateTeam, AddHeroToTeam, ExecuteMission, and CompleteMission now return ErrorOr\<Success\> instead of void or simple success indicators, allowing callers to handle specific domain errors like team or hero not found. Queries like GetTeam now return ErrorOr\<TeamDto\> to propagate these errors, while GetAllTeams returns a list of TeamDto. Additionally, a new event handler (PowerLevelUpdatedEventHandler) ensures team power levels are recalculated when a hero's power level changes, and validators have been encapsulated within each command file.
src/Application/UseCases/Teams · high confidence
Test coverage
Added architecture unit tests for clean architecture rules; Added integration test for team power level updates; Added integration tests for Hero creation and update commands; Added integration tests for Teams API endpoints; Added integration tests for the GetAllHeroes query endpoint; Added test factories for Hero and Team entities; Added unit tests for Hero and Power domain entities; Added unit tests for Team and Mission domain entities; New test infrastructure for SQL Server integration tests; Refactored integration test base and database fixture.
Dependencies
Adopt centralized package management with .NET 10 and Aspire 13.1.2
The project now uses centralized package management via Directory.Packages.props to define versions for all dependencies, simplifying version updates across the solution. This change upgrades the target framework to .NET 10 and .NET Aspire to version 13.1.2, while also updating key libraries such as Entity Framework Core, FluentValidation, and xUnit v3 to their latest compatible versions.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 65 → 62 (-3.4)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 83 → 83 (+0.0)
- Architecture 93 → 92 (-1.3)
- Maturity 76 → 82 (+6.0)
- Readiness 69 → 58 (-11.1)
- Security 55 → 52 (-2.6)
- Domain Modelling 78 → 78 (+0.0)
- Event-Driven 100 → 100 (+0.0)
- Performance 85 → 85 (+0.0)
Resolved (12)
- ADR has no Consequences section (docs/adr/20240415-replace-string-length-constraints-with-better-business-rules.md)
- ADR has no Consequences section (docs/adr/20241023-use-net-openapi-and-scalar-over-nswag-and-swagger.md)
- ADR has no Consequences section (docs/adr/20241118-use-vogen-to-simplify-strongly-typed-ids.md)
- ADR has no Consequences section (docs/adr/20250326-migrate-to-awesome-assertions.md)
- Documentation: no project overview (docs/adr/index.md)
- Off-boarding risk: anonymized user #1
- XML-doc coverage: AppHost (tools/AppHost/AppHost.csproj)
- XML-doc coverage: Application (src/Application/Application.csproj)
- XML-doc coverage: Domain (src/Domain/Domain.csproj)
- XML-doc coverage: Infrastructure (src/Infrastructure/Infrastructure.csproj)
- XML-doc coverage: MigrationService (tools/MigrationService/MigrationService.csproj)
- XML-doc coverage: WebApi (src/WebApi/WebApi.csproj)
New (21)
- Classify ADR enforcement: Migrate to Awesome Assertions (docs/adr/20250326-migrate-to-awesome-assertions.md)
- Classify ADR enforcement: Move Specifications to the Domain Layer (docs/adr/20230810-move-specifications-to-the-domain.md)
- Classify ADR enforcement: Produce useful SQL Server exceptions (docs/adr/20241118-produce-useful-sql-server-exceptions.md)
- Classify ADR enforcement: Replace AutoMapper with manual mapping (docs/adr/20241118-replace-automapper-with-manual-mapping.md)
- Classify ADR enforcement: Replace database string length constraints with better business rules (docs/adr/20240415-replace-string-length-constraints-with-better-business-rules.md)
- Classify ADR enforcement: Revisit OpenAPI document generation (docs/adr/20240219-revisit-openapi-document-generation.md)
- Classify ADR enforcement: Subcutaneous Tests Should Target WebApi Layer (docs/adr/20231212-subcutaneous-tests-should-target-webapi-layer.md)
- Classify ADR enforcement: Use .NET OpenAPI and Scalar over NSwag and Swagger (docs/adr/20241023-use-net-openapi-and-scalar-over-nswag-and-swagger.md)
- Classify ADR enforcement: Use Aggregate Specification Classes with Factory Methods (docs/adr/20260221-use-aggregate-specification-classes-with-factory-methods.md)
- Classify ADR enforcement: Use Domain-Driven Design Tactical Patterns (docs/adr/20240404-use-domain-driven-design-tactical-patterns.md)
- Classify ADR enforcement: Use EF Core and Specifications in Commands and Queries (docs/adr/20230612-use-ef-core-and-specifications-in-commands-and-queries.md)
- Classify ADR enforcement: Use Log4brains to manage the ADRs (docs/adr/20230612-use-log4brains-to-manage-the-adrs.md)
- Classify ADR enforcement: Use Markdown Architectural Decision Records (docs/adr/20230612-use-markdown-architectural-decision-records.md)
- Classify ADR enforcement: Use Minimal API Typed Results (docs/adr/20240605-use-minimal-api-typed-results.md)
- Classify ADR enforcement: Use Results Pattern Over Exceptions (docs/adr/20240605-use-results-pattern-over-exceptions.md)
- Classify ADR enforcement: Use Vogen to simplify strongly typed IDs (docs/adr/20241118-use-vogen-to-simplify-strongly-typed-ids.md)
- Classify ADR enforcement: Use the Factory Pattern to Create Aggregates (docs/adr/20230604-use-the-factory-pattern-to-create-aggregates.md)
- Off-boarding risk: anonymized user #1
- doc comments repeat the names (tests/WebApi.IntegrationTests/Common/TestingDatabaseFixture.cs)
- redundant comment (src/WebApi/Program.cs)
- …and 1 more
Architecture
- Unchanged — 2 containers · 1 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
SSWConsulting/SSW.CleanArchitecture 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 8 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit c5f7d4c500f593ea36fae9e20c456a2439b671b1 — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-45ab2cab63de.