samanazadi1996/Sam.CleanArchitecture
55.0
Adequate · 7 November 2026
1.7k
lines of production code
C#
primary language
7
measurements over time
What this system is
This system is a .NET 10-based Clean Architecture template that provides a foundational structure for building web APIs with built-in support for user authentication and product management. It implements a layered design featuring MediatR-based command/query handling, generic repository patterns for data persistence, and centralized error handling with localized resource support. The solution includes pre-configured identity services, database seeding, and functional tests to validate the core account and product CRUD operations.
How it got here
2024 — Initial Clean Architecture implementation
39 changes.
This period established the foundational structure of a .NET 10 Clean Architecture solution, defining core domain models, application interfaces, and infrastructure layers for identity and persistence. It introduced the initial Product and Account features with full CRUD capabilities, including database migrations, seeding, and localization support. The work also included comprehensive testing coverage and CLI templates to standardize future development within the architecture.
2025 — account management and API expansion
4 changes.
This period focused on implementing core account management features, including authentication, profile updates, and ghost account initialization, alongside product CRUD operations. The work involved exposing these capabilities through new Web API endpoints and updating the application layer's validation behavior to use synchronous handlers. Additionally, the project migrated its solution file to the new .slnx format to align with modern IDE standards.
Features
Add centralized error handling middleware
The API now includes an ErrorHandlerMiddleware that intercepts unhandled exceptions and returns structured JSON error responses. This middleware maps specific exception types to appropriate HTTP status codes and error details: ValidationException results in a 400 Bad Request with field-specific errors, KeyNotFoundException results in a 404 Not Found, and any other exception results in a 500 Internal Server Error.
Source/Src/Presentation/CleanArchitecture.WebApi/Infrastructure/Middlewares · high confidence
Add infrastructure services for authenticated user context and Mediator pipeline execution
The application now includes two new infrastructure services: AuthenticatedUserService, which retrieves the current user's ID and name from the HTTP context claims, and MediatorService, which implements the IMediator interface to dispatch requests through the pipeline behavior chain using the service provider.
Source/Src/Presentation/CleanArchitecture.WebApi/Infrastructure/Services · high confidence
Add product management commands
Introduces the Create, Update, and Delete command handlers and validators for the Products feature, enabling users to manage product records through the application's command layer.
Source/Src/Core/CleanArchitecture.Application/Features/Products/Commands · high confidence
Added Clean Architecture Resource template
A new \ca-resource\ template has been added to the project, allowing users to generate a new Resource component within a Clean Architecture solution. The template includes configuration for a required \culture\ parameter (short name \c\) to localize resource files, and generates placeholder \.resx\ files (\ResourceGeneral.Culture.resx\ and \ResourceMessages.Culture.resx\) with the culture name substituted into the filenames.
Templates/ca-resource · high confidence
Added application-layer DTOs and validation helpers
Introduced new data transfer objects and helper utilities to support application logic. Added \PaginationResponseDto\ to standardize paginated API responses and \TranslatorMessageDto\ to structure localized error messages. Included \Regexs\ for consistent input validation patterns (password, email, phone, username) and \TranslatorMessages\ to provide predefined message templates for account and product operations.
Source/Src/Core/CleanArchitecture.Application/DTOs · high confidence
Added database configuration and migration helper scripts
The ca-tools template now includes batch scripts to simplify database setup and migration management. Users can run ConfigureDatabase.bat to automatically add the appropriate Entity Framework Core provider package (for SQL Server, PostgreSQL, Oracle, MySQL, or SQLite) and update the ServiceRegistration.cs file. Additionally, dedicated scripts for Identity and Persistence migrations are provided to streamline the creation of database migrations for each context.
Templates/ca-tools · high confidence
Added default admin user and role seeding
The application now automatically creates a default 'Admin' user and 'Admin' role upon initialization. The new \DefaultBasicUser\ seed creates an admin account with the email '[e-mail redacted]' and password 'Sam@12345', while \DefaultRoles\ ensures the corresponding 'Admin' role exists in the identity system.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Seeds · high confidence
Added default product seed data for initial database setup
The application now automatically populates the database with five default products (Product 1 through Product 5) with specific prices and identifiers when the database is first initialized, ensuring immediate availability of sample data for users.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Seeds · high confidence
Added infrastructure for localized resource strings and translation
The application now includes a new resource infrastructure layer that provides strongly-typed access to localized strings. This change introduces a \Translator\ service, registered via dependency injection, which retrieves messages from \ResourceGeneral\ and \ResourceMessages\ resource files. It supports both simple string lookups and formatted message retrieval with arguments, enabling the system to display localized content (such as error messages and general UI labels) in different languages, with initial support for English and Persian (Farsi) provided in the new \.resx\ files.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Resources · high confidence
Added pagination request parameter model
A new PaginationRequestParameter class has been introduced to define the structure for pagination requests, providing default values for PageNumber (1) and PageSize (20).
Source/Src/Core/CleanArchitecture.Application/Parameters · high confidence
Added product list query with pagination support
Users can now retrieve a paginated list of products filtered by name. This change introduces the GetPagedListProductQuery and its handler, which leverage the existing PagedResponse wrapper and IProductRepository to return a list of ProductDto objects based on page number, page size, and an optional name filter.
Source/Src/Core/CleanArchitecture.Application/Features/Products/Queries/GetPagedListProduct · high confidence
Added query to retrieve a product by ID
Users can now fetch a specific product by its ID. This change introduces the GetProductByIdQuery and its handler, which uses the product repository to retrieve the entity and returns a ProductDto wrapped in a BaseResult, handling the case where the product is not found.
Source/Src/Core/CleanArchitecture.Application/Features/Products/Queries/GetProductById · high confidence
Added repository interfaces for generic and product data access
New interface definitions have been introduced in the application layer to standardize data access patterns. IGenericRepository\<T\> provides a common contract for basic CRUD operations (GetById, GetAll, Add, Update, Delete) across all entities. IProductRepository extends this generic interface to include specific functionality for products, such as retrieving paginated lists with filtering capabilities. These interfaces define the contract for the product domain's data persistence requirements.
Source/Src/Core/CleanArchitecture.Application/Interfaces/Repositories · high confidence
Initial database schema for Identity and Product domains
The application now includes the initial Entity Framework Core migrations for both the Identity and Persistence layers. The Identity migration creates the 'Identity' schema containing tables for Users, Roles, and their associated claims, logins, roles, and tokens, while the Persistence migration creates the 'Products' table to store product details such as name, price, and barcode. These changes establish the foundational database structure required for user authentication and product management.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Migrations, Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Migrations · high confidence
Initial domain model for Products
Added the core domain entities and data transfer objects for the Products feature. This includes the Product entity with properties for name, price, and barcode, along with an Update method, and a corresponding ProductDto for data representation.
Source/Src/Core/CleanArchitecture.Domain/Products · high confidence
Introduce centralized application layer service registration
The application layer now provides a dedicated \ServiceRegistration\ class that consolidates service setup. Users can register application-layer dependencies, such as FluentValidation validators, by calling the new \AddApplicationLayer\ extension method on the \IServiceCollection\.
Source/Src/Core/CleanArchitecture.Application · high confidence
Introduced generic and product repositories with read-optimized queries
Added GenericRepository and ProductRepository classes to the persistence layer. The GenericRepository implements standard CRUD operations and uses AsNoTracking for read-only queries (GetAllAsync, Paged) to improve performance. The ProductRepository extends GenericRepository to provide specific functionality for products, including paginated retrieval with optional name filtering.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Repositories · high confidence
Introduces infrastructure extension methods for CORS, endpoint mapping, localization, MediatR, and Swagger
The application now includes a new set of extension methods in the infrastructure layer to configure core services. CORS is enabled via a new CorsExtensions class that allows any origin, header, and method. Endpoint registration is handled by EndpointExtensions, which automatically discovers and maps endpoint groups based on a base class, and provides helper methods for HTTP verbs. Localization is configured through LocalizationExtensions, which reads supported cultures from configuration. MediatR is set up via MediatorExtensions to register handlers and behaviors from the Application assembly. Finally, Swagger is configured with SwaggerExtensions, including JWT Bearer token security definitions.
Source/Src/Presentation/CleanArchitecture.WebApi/Infrastructure/Extensions · high confidence
Introduction of core application interfaces
The application layer now exposes a set of foundational interfaces to support its internal architecture. This includes \IAuthenticatedUserService\ for retrieving current user identity, \IUnitOfWork\ for managing database transactions, and \ITranslator\ for handling localized strings. Additionally, a custom \IMediator\ interface is introduced, defining the contract for sending requests and handling them via \IRequestHandler\, along with support for pipeline behaviors through \IPipelineBehavior\.
Source/Src/Core/CleanArchitecture.Application/Interfaces · high confidence
Introduction of generic base entity classes for domain models
The domain layer now provides two new abstract base classes, BaseEntity and AuditableBaseEntity, to standardize entity structure. BaseEntity introduces a generic Id property, while AuditableBaseEntity extends this to include standard audit fields (CreatedBy, Created, LastModifiedBy, LastModified). This change establishes a foundational structure for domain entities to inherit from, ensuring consistent identification and auditing across the application.
Source/Src/Core/CleanArchitecture.Domain/Common · high confidence
New API endpoints for account management, product CRUD, and error code retrieval
The Web API now exposes dedicated endpoint groups for accounts, products, and documentation. Account operations include starting an account, authenticating, and (when authorized) changing the username or password. Product management endpoints allow listing products, retrieving a product by ID, and (when authorized) creating, updating, or deleting products. Additionally, a new endpoint retrieves error codes as a dictionary of integer-to-string mappings.
Source/Src/Presentation/CleanArchitecture.WebApi/Endpoints · high confidence
New Clean Architecture Entity template with short CLI aliases
Users can now generate a new domain entity using the 'ca-entity' template. The template creates a C\# class inheriting from AuditableBaseEntity, with placeholders for domain and entity names. The CLI now supports short aliases (-dn for domain-name, -en for entity-name) for easier invocation.
Templates/ca-entity · high confidence
New account management commands for authentication and profile updates
This change introduces a set of new application-layer commands within the Accounts feature area, enabling users to authenticate, change their password, update their username, and initialize a ghost account. Specifically, it adds the command handlers and validators for Authenticate, ChangePassword, ChangeUserName, and Start (ghost account registration), wired to the existing IAccountServices interface to perform the underlying business logic.
Source/Src/Core/CleanArchitecture.Application/Features/Accounts · high confidence
New account request DTOs for authentication and user management
Added four new Data Transfer Objects in the Account Requests folder to support user-facing operations: AuthenticationRequest for login credentials, ChangePasswordRequest for password updates, ChangeUserNameRequest for username modifications, and GetAllUsersRequest for paginated user listing with name filtering.
Source/Src/Core/CleanArchitecture.Application/DTOs/Account/Requests · high confidence
New application interfaces for account management and user retrieval
Added IAccountServices and IGetUserServices interfaces to define the contract for account-related operations (registration, password/username changes, authentication) and paginated user listing. These interfaces establish the application-layer API that implementing services must fulfill to support user account and profile features.
Source/Src/Core/CleanArchitecture.Application/Interfaces/UserInterfaces · high confidence
New authentication and user response DTOs added
Two new Data Transfer Objects have been introduced in the Account Responses namespace to support user data serialization. AuthenticationResponse now carries identity details including user ID, username, email, roles, verification status, and a JWT token. UserDto provides a structured view of user profile information, including a GUID identifier, name, email, phone number, and creation timestamp.
Source/Src/Core/CleanArchitecture.Application/DTOs/Account/Responses · high confidence
New identity and JWT configuration settings classes
The application now includes dedicated configuration classes for identity and authentication settings. IdentitySettings defines password policy requirements, including rules for digits, length, non-alphanumeric characters, and case sensitivity. JwtSettings provides configuration for JSON Web Token generation, specifying the signing key, issuer, audience, and token duration in minutes.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Settings · high confidence
New identity service implementations for account management and user retrieval
The identity infrastructure layer now includes concrete implementations for account operations and user queries. AccountServices handles user authentication, password and username changes, and ghost account registration, returning standardized results via BaseResult. GetUserServices provides paginated user retrieval with optional name filtering, querying the identity context directly to return UserDto objects.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Services · high confidence
New result and error wrapper types with implicit conversions
The application layer now includes new wrapper classes for handling operation results and errors: BaseResult, BaseResult\<TData\>, PagedResponse, Error, and ErrorCode. These types provide a structured way to represent success/failure states, aggregate errors, and handle paginated responses. Implicit conversion operators are defined to allow seamless assignment of Error, List\<Error\>, or data objects to these result types, simplifying error handling and response construction in application services.
Source/Src/Core/CleanArchitecture.Application/Wrappers · high confidence
Behavioural changes
Configurable Identity Infrastructure with In-Memory Database Support
The identity service registration now supports an in-memory database for development or testing scenarios via a new \useInMemoryDatabase\ parameter, while continuing to use SQL Server for production. This change consolidates the setup of \IdentityContext\, user/role services, JWT authentication, and identity settings into a single registration method, ensuring that security stamp validation and JWT event handling are consistently applied based on the configured settings.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity · high confidence
Configurable database persistence and automatic repository registration
The persistence infrastructure now supports switching between SQL Server and an in-memory database via a new boolean parameter in the service registration method, allowing for easier local development and testing. Additionally, the system automatically registers all repository implementations that implement the generic repository interface, removing the need for manual DI configuration of individual repositories.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence · high confidence
Introduce custom Identity models and database schema configuration
The application now defines custom \ApplicationUser\ and \ApplicationRole\ entities, with \ApplicationUser\ extending \IdentityUser\<Guid\>\ to include a \Name\ property and a \Created\ timestamp. An \IdentityContext\ has been added to configure the Entity Framework Core mapping, explicitly setting the database schema to "Identity" and mapping the user, role, and association tables (UserRoles, UserClaims, UserLogins, RoleClaims, UserTokens) to specific table names.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Models · high confidence
Migrated solution file to new .slnx format
The project solution has switched from the legacy .sln format to the new .slnx format. This change updates the underlying solution structure file (CleanArchitecture.slnx) while removing the old CleanArchitecture.sln, ensuring the workspace is recognized by IDEs supporting the new standard without altering the actual project references or build configurations.
Source · high confidence
Refactored persistence layer with primary constructors and explicit auditing
The persistence context has been refactored to use C\# primary constructors for dependency injection, simplifying the initialization of ApplicationDbContext, UnitOfWork, and related classes. A new EntityFrameworkExtensions class centralizes auditing logic, automatically populating Created/LastModified timestamps and user IDs on AuditableBaseEntity instances during SaveChangesAsync. Additionally, decimal properties are now explicitly configured to use a precision of 18 and scale of 6, and a dedicated ProductConfiguration ensures consistent entity mapping.
Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Contexts · high confidence
Updated C\# use-case template to use generic object return types
The C\# use-case template in the application layer has been updated to standardize return types. Command and query handlers now return \BaseResult\<object\>\ instead of specific types, and the paged list query handler returns \PagedResponse\<object\>\. Corresponding command and query classes now define their primary property as \object\, and the paged list query inherits from \PaginationRequestParameter\ to support pagination.
Templates/ca-use-case/Features/FeatureName · high confidence
Validation behavior now uses synchronous Handle method
The ValidationBehavior pipeline component has been updated to implement the synchronous Handle method instead of the previous HandleAsync method. This change aligns the behavior with the current interface contract for pipeline behaviors in the application layer, ensuring consistent method signatures across the system while maintaining the same validation logic for incoming requests.
Source/Src/Core/CleanArchitecture.Application/Behaviours · high confidence
Web API startup configuration and environment settings
The WebApi project now initializes its application lifecycle through a new Program.cs entry point, which configures dependency injection for application, persistence, and identity layers, enables Swagger, CORS, and Serilog logging, and handles database migrations and data seeding at startup. Configuration is managed via appsettings.json and environment-specific files (Development, Test), introducing a 'UseInMemoryDatabase' setting to toggle between persistent SQL Server databases and in-memory storage for testing.
Source/Src/Presentation/CleanArchitecture.WebApi · high confidence
Test coverage
Added functional test infrastructure and helpers; Added functional tests for Account, Product, and OpenAPI endpoints; Added integration tests for Entity Framework repository operations; Added unit tests for Products application features; Added unit tests for the Product domain entity.
Dependencies
Clean Architecture template upgraded to .NET 10 with updated dependencies
The Clean Architecture NuGet template (Sam.CleanArchitecture.Template v10.0.1) has been upgraded to target .NET 10.0 across all project layers, including the Web API, Application, Domain, Infrastructure, and test projects. Key dependency updates include Microsoft.EntityFrameworkCore and related packages to version 10.0.8, Swashbuckle.AspNetCore to 10.2.1, and Serilog components to 10.0.0. Test projects now utilize xUnit 2.9.3, xunit.runner.visualstudio 3.1.5, and Microsoft.NET.Test.Sdk 18.6.0.
(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 55 → 55 (-0.3)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 69 → 69 (-0.1)
- Architecture 84 → 84 (+0.0)
- Maturity 64 → 70 (+5.7)
- Readiness 46 → 46 (+0.0)
- Security 58 → 56 (-1.3)
- Domain Modelling 78 → 64 (-14.1)
- Performance 70 → 77 (+7.4)
Resolved (1)
- Coverage not measured — no coverage collector is wired up
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
samanazadi1996/Sam.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 7 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 c60263010f9f303aace5e135b2a79326f5e28090 — 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.