Skip to content
CAI
Software that uses CAICheck a score

samanazadi1996/Sam.CleanArchitecture

56.8

Adequate · 20 September 2026

1.7k

lines of production code

C#

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a .NET 10-based Clean Architecture web API scaffold that provides a structured foundation for building applications with distinct domain, application, infrastructure, and presentation layers. It implements core features for user account management—including authentication, profile updates, and role-based access—and product inventory management with full CRUD operations and pagination. The platform supports internationalization through localized resource strings, enforces global error handling, and includes automated database seeding and migration tools to streamline development and testing workflows.

How it got here

2024 — Clean Architecture implementation and scaffolding

39 changes.

This period focused on implementing the core Clean Architecture layers, establishing domain entities, application interfaces, and infrastructure services for identity and persistence. It included scaffolding the Web API with middleware, localization, and global error handling, alongside upgrading the project to .NET 10 and adding comprehensive test coverage.

2025 — account management and API endpoints

4 changes.

This period focused on implementing core account management features, including user authentication, profile updates, and ghost account initialization. The work also introduced new API endpoints for product CRUD operations and error code retrieval, while refining the application's validation pipeline and solution structure.

Features

Add ca-entity template with short-name aliases

The ca-entity template now supports short command-line aliases (dn for domain-name, en for entity-name) via the dotnetcli.host.json configuration, allowing users to invoke the template more concisely. The template itself generates a basic C\# entity class inheriting from AuditableBaseEntity, with placeholders for domain and entity names that are replaced during instantiation.

Templates/ca-entity · high confidence

Add default admin user and role seeding

The application now automatically creates a default 'Admin' user and 'Admin' role during initialization if they do not already exist. The default user is configured with the email '[e-mail redacted]' and the password 'Sam@12345', ensuring immediate access to administrative features without manual setup.

Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Seeds · high confidence

Add infrastructure services for authenticated user context and Mediator dispatch

The application now includes two new infrastructure services: AuthenticatedUserService, which exposes the current user's ID and name via HttpContext, and MediatorService, which implements the IMediator interface to dispatch requests through registered pipeline behaviors and handlers.

Source/Src/Presentation/CleanArchitecture.WebApi/Infrastructure/Services · high confidence

Add product management commands

Introduces the Create, Update, and Delete command handlers, commands, 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 .slnx solution file for project organization

A new .slnx file has been added to the Source directory to define the solution structure. This file organizes the project's components into logical folders (Core, Infrastructure, Presentation, Tests) and explicitly marks the CleanArchitecture.WebApi project as the default startup project, providing a structured view for IDEs that support the .slnx format.

Source · high confidence

Added Clean Architecture Resource template

A new dotnet CLI template named 'ca-resource' (short name: ca-resource) has been added to generate Clean Architecture Resource items. This template creates a C\# project structure containing localized resource files (ResourceGeneral and ResourceMessages) with placeholders for culture-specific naming, allowing developers to quickly scaffold localized resource components within their Clean Architecture solutions.

Templates/ca-resource · high confidence

Added DTOs and helper classes for pagination, translation, and validation

This change introduces new application-layer components to support structured responses and internationalization. A new \PaginationResponseDto\<T\>\ provides a generic wrapper for paginated data, while \TranslatorMessageDto\ and the \TranslatorMessages\ helper class enable structured, parameterized error and status messages for account and product operations. Additionally, a \Regexs\ helper class centralizes validation patterns for passwords, emails, phone numbers, and usernames.

Source/Src/Core/CleanArchitecture.Application/DTOs · high confidence

Added account request DTOs for authentication and user management

New data transfer objects have been introduced in the application layer to support account-related operations. These include AuthenticationRequest for login credentials, ChangePasswordRequest and ChangeUserNameRequest for updating user profile details, and GetAllUsersRequest which extends PaginationRequestParameter to support paginated user listing with name filtering.

Source/Src/Core/CleanArchitecture.Application/DTOs/Account/Requests · high confidence

Added batch scripts for database configuration and migration management

The ca-tools template now includes Windows batch scripts to simplify database setup and migration workflows. ConfigureDatabase.bat allows users to select a database provider (SQL Server, PostgreSQL, Oracle, MySQL, or SQLite) and automatically adds the corresponding Entity Framework Core package while updating ServiceRegistration.cs. Additionally, AddMigration.Identity.bat and AddMigration.Persistence.bat provide interactive prompts to generate migrations for Identity and Persistence contexts respectively, handling path detection and user confirmation before execution.

Templates/ca-tools · high confidence

Added default product seed data for initial database setup

The application now includes a default data seeding mechanism that automatically populates the database with five sample products (Product 1 through Product 5) upon first run, ensuring immediate availability of reference data for testing and demonstration purposes.

Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Seeds · high confidence

Added global error handling middleware

A new ErrorHandlerMiddleware has been introduced to the web API infrastructure. This middleware intercepts unhandled exceptions during request processing and converts them into standardized JSON error responses. It specifically handles validation errors (returning 400 Bad Request), missing resource errors (returning 404 Not Found), and other unexpected exceptions (returning 500 Internal Server Error), ensuring consistent error formatting for API consumers.

Source/Src/Presentation/CleanArchitecture.WebApi/Infrastructure/Middlewares · high confidence

Added localized resource strings and translation service

The infrastructure layer now includes strongly-typed resource classes and Persian (Farsi) localization files for general UI labels and system error messages, alongside a new \Translator\ service that resolves these strings based on the current culture.

Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Resources · high confidence

Added pagination request parameter model

A new PaginationRequestParameter class has been introduced in the Application layer to standardize pagination inputs. This model defines default values for PageNumber (1) and PageSize (20), providing a structured way for users to request paginated data with sensible defaults.

Source/Src/Core/CleanArchitecture.Application/Parameters · high confidence

Added product list query and handler

Introduced a new query and handler for retrieving a paginated list of products. The GetPagedListProductQuery accepts pagination parameters and an optional name filter, while the corresponding handler delegates to the product repository to fetch the data and return it as a PagedResponse.

Source/Src/Core/CleanArchitecture.Application/Features/Products/Queries/GetPagedListProduct · high confidence

Added query handler for retrieving a product by ID

Users can now retrieve a specific product by its ID via the GetProductById query. The implementation uses the IRequestHandler interface with a Handle method (replacing the previous HandleAsync pattern) and returns a BaseResult\<ProductDto\>. If the product is not found, it returns a NotFound error with a translated message.

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 add specific functionality for products, including paginated retrieval with filtering by name. These interfaces define the contract for the product domain's data persistence layer.

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 infrastructure layers. The Identity migration establishes the 'Identity' schema containing tables for Users, Roles, and their associated claims, logins, and tokens, while the Persistence migration creates the 'Products' table to store product details such as name, price, and barcode. These changes ensure the database structure is ready to support user authentication and product management features.

Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Migrations, Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Migrations · high confidence

Introduce Product domain entity and DTO

Added the core Product entity and its corresponding Data Transfer Object (DTO) to the domain layer. The Product entity defines the structure for product data including name, price, and barcode, and includes an Update method for modifying these properties. The ProductDto provides a flattened view of the product data, mapping entity fields to DTO properties for external consumption.

Source/Src/Core/CleanArchitecture.Domain/Products · high confidence

Introduce centralized application layer service registration

A new ServiceRegistration class has been added to the Application layer, providing a dedicated entry point for configuring application services. This includes automatically registering FluentValidation validators from the assembly, allowing consumers to easily wire up the application layer's dependencies via a single AddApplicationLayer call.

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, while the ProductRepository extends this to provide paginated, filtered product retrieval.

Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Persistence/Repositories · high confidence

Introduces infrastructure extension helpers for CORS, endpoints, localization, MediatR, and Swagger

The application now includes dedicated extension methods in the infrastructure layer to configure core services. CORS is enabled with a permissive 'Any' policy allowing all origins, headers, and methods. Endpoint routing is automated via \MapEndpoints\, which scans for classes inheriting from \EndpointGroupBase\ and registers them under \/api/{GroupName}\ prefixes, while also providing convenience overloads for HTTP verbs that default to handler method names. Localization is configured via \AddCustomLocalization\ and \UseCustomLocalization\ to support cultures defined in \appsettings.json\. MediatR is set up to automatically register request handlers and apply a \ValidationBehavior\ pipeline. Finally, Swagger is configured with \AddCustomSwagger\ and \UseCustomSwagger\, including a Bearer JWT security scheme definition.

Source/Src/Presentation/CleanArchitecture.WebApi/Infrastructure/Extensions · high confidence

Introduces 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\<T\>\, \Error\, and \ErrorCode\. These types provide a structured way to represent success/failure states, including support for multiple errors and specific error codes (e.g., \ModelStateNotValid\, \NotFound\). Implicit operators allow seamless conversion between these result types and their underlying data or error collections, simplifying API responses and error handling in application services.

Source/Src/Core/CleanArchitecture.Application/Wrappers · high confidence

Introduction of core application interfaces for user context, messaging, translation, and persistence

The application layer now exposes a set of new interfaces to define its core contracts: IAuthenticatedUserService provides access to the current user's ID and name; IMediator, IRequest, IRequestHandler, and IPipelineBehavior establish a custom mediator pattern for handling requests with pipeline support; ITranslator adds string and DTO-based localization capabilities; and IUnitOfWork defines the asynchronous save operation for persistence. These interfaces standardize how the application layer interacts with authentication, command/query processing, internationalization, and data persistence.

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 such as Created, CreatedBy, LastModified, and LastModifiedBy, simplifying the implementation of common data patterns across domain entities.

Source/Src/Core/CleanArchitecture.Domain/Common · high confidence

New API endpoints for account management, product CRUD, and error code retrieval

This change introduces three new endpoint groups to the Web API: AccountEndpoint, ProductEndpoint, and DocEndpoint. The AccountEndpoint exposes routes for user authentication, account creation, and updating user details (username and password), with modification actions requiring authorization. The ProductEndpoint provides full CRUD capabilities for products, including listing, retrieving by ID, creating, updating, and deleting, where write operations are protected by authorization. Additionally, the DocEndpoint adds a GET route to retrieve a dictionary of error codes for documentation or debugging purposes.

Source/Src/Presentation/CleanArchitecture.WebApi/Endpoints · high confidence

New account management commands for authentication and profile updates

The application now supports user authentication, ghost account initialization, and profile updates (username and password changes) via new command handlers. Users can log in with credentials, start a session via a temporary ghost account, change their username, and update their password, all validated with specific rules for length and format.

Source/Src/Core/CleanArchitecture.Application/Features/Accounts · high confidence

New authentication and user profile response DTOs

Added two new Data Transfer Objects to the account responses layer: AuthenticationResponse, which carries user identity details (ID, username, email, roles, verification status) along with a JWT token, and UserDto, which exposes user profile information (ID, username, name, creation date, email, phone number). These classes provide structured data contracts for returning account-related information to clients.

Source/Src/Core/CleanArchitecture.Application/DTOs/Account/Responses · high confidence

New identity and JWT configuration settings classes

The application now exposes dedicated configuration classes for identity and authentication settings within the Identity infrastructure layer. Users can now configure password policies (such as requiring digits, length, non-alphanumeric characters, uppercase, and lowercase) via the new IdentitySettings class, and manage JWT token parameters (including the signing key, issuer, audience, and token duration) via the new JwtSettings class.

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 and user operations. AccountServices handles user authentication, password changes, username updates, and ghost account registration, returning standardized BaseResult responses. 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 user account and retrieval service interfaces

Added IAccountServices and IGetUserServices interfaces to define the contract for user account management and user data retrieval. IAccountServices exposes methods for registering ghost accounts, changing passwords and usernames, and authenticating users, while IGetUserServices provides a method to retrieve a paged list of users.

Source/Src/Core/CleanArchitecture.Application/Interfaces/UserInterfaces · 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

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 Web API project now initializes its application builder and service container in Program.cs, registering application, persistence, and identity infrastructure layers along with Swagger, CORS, authorization, localization, and health checks. The startup logic conditionally applies database migrations and seeds default roles, users, and data, using an in-memory database when the UseInMemoryDatabase configuration flag is true. Environment-specific settings are provided via appsettings.json (defaulting to SQL Server with Identity separation), appsettings.Development.json (empty), and appsettings.Test.json (enabling in-memory database for tests).

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 watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.

Score

  • CAI 60 → 57 (-3.3)
  • Rubric changed (rubric-2026.08.17 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 70 → 71 (+0.8)
  • Architecture 84 → 84 (+0.0)
  • Maturity 63 → 67 (+4.6)
  • Readiness 52 → 47 (-4.8)
  • Security 70 → 60 (-10.0)

Resolved (18)

  • BarePragmaDisable (Source/Src/Core/CleanArchitecture.Domain/Products/Entities/Product.cs)
  • BarePragmaDisable (Source/Src/Core/CleanArchitecture.Domain/Products/Entities/Product.cs)
  • BarePragmaDisable (Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Settings/JwtSettings.cs)
  • BarePragmaDisable (Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Settings/JwtSettings.cs)
  • Bounded contexts not declared
  • Duplicated block (11 lines × 2) (Source/Src/Core/CleanArchitecture.Application/Features/Products/Commands/CreateProduct/CreateProductCommandValidator.cs)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • LLM evaluation failed
  • No exposed public API
  • Small-team knowledge concentration
  • redundant comment (Source/Tests/CleanArchitecture.FunctionalTests/ApiEndpoints/AccountFunctionalTests.cs)

New (18)

  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)
  • Duplicated block (12 lines × 2) (Source/Src/Core/CleanArchitecture.Application/Features/Products/Commands/CreateProduct/CreateProductCommandValidator.cs)
  • FileScopedPragmaDisable (Source/Src/Core/CleanArchitecture.Domain/Products/Entities/Product.cs)
  • FileScopedPragmaDisable (Source/Src/Core/CleanArchitecture.Domain/Products/Entities/Product.cs)
  • FileScopedPragmaDisable (Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Settings/JwtSettings.cs)
  • FileScopedPragmaDisable (Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Settings/JwtSettings.cs)
  • High IaC: WD-COMPOSE-0002 (Deploy/docker-compose.yml)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Leaked secret: hardcoded-credential (Deploy/.env)
  • redundant comment (Source/Src/Infrastructure/CleanArchitecture.Infrastructure.Identity/Seeds/DefaultRoles.cs)

Written by watchdog.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 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 c23d88512a007f17ea834e128daf0d8dedacdf43 — 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.