Skip to content
CAI
Software that uses CAICheck a score

threenine/api-template

51.2

Weak · 6 October 2026

667

lines of production code

C#

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This release modernizes the codebase by upgrading to .NET 8.0 and introducing a comprehensive Vertical Slice Architecture template pack, featuring new scaffolding for Commands, Queries, and CRUD operations. The solution now supports both SQL Server and PostgreSQL, with centralized validation, logging, and exception handling middleware. Additionally, the project structure has been standardized with improved build automation, Docker support, and enhanced Swagger documentation for JSON Patch operations.

Features

Add Model Configuration template for database projects

A new Model Configuration template has been introduced for generating model configurations in database projects. The template allows users to specify parameters such as root, model, MSSQL, Postgre, and list, and generates a C\# class that configures entity types using Entity Framework Core. This enables consistent and automated setup of database configurations for API projects.

src/ModelConfiguration · high confidence

Added API exception handling middleware and exception types

The API now includes a new exception handling middleware that catches unhandled exceptions and returns a structured JSON response containing the title, status code, and error details. This is supported by new exception classes, specifically a base ApiException and a NotFoundException, which allow the middleware to map specific error types to appropriate HTTP status codes (404 for not found, 500 for other errors) and titles.

src/Solution/src/Api/Exceptions, src/Solution/src/Api/Middleware · medium confidence

Added Domain1 class to the domain layer

A new file, Domain1.cs, has been added to the Domain layer, introducing a new Domain1 class. This change establishes a new domain component within the application's core logic.

src/Solution/src/Domain · high confidence

Added GetAll and GetbyId query endpoints

New query endpoints for retrieving all resources and a single resource by ID have been added to the CRUD system. Each endpoint includes a MediatR handler, a FluentValidation validator, an AutoMapper profile, and an API endpoint class that delegates to the handler. This provides the foundational read operations for the resource.

src/Crud/Queries · high confidence

Added Post and Patch command templates for resource creation and partial updates

The codebase now includes new command templates for handling resource creation (Post) and partial updates (Patch). The Post command accepts a domain object to create a new resource, returning the generated ID, while the Patch command accepts a JsonPatchDocument to partially update an existing resource by ID. Both commands include corresponding MediatR handlers, AutoMapper profiles for model mapping, and FluentValidation validators to ensure data integrity before processing.

src/Crud/Commands/Post · high confidence

Added Put command and endpoint for resource updates

Introduced a new Put command and associated endpoint to handle resource update requests. The change adds a command class with route and body parameters, a MediatR handler that invokes the data service's update method, a mapping profile for domain-to-model and model-to-response conversion, a FluentValidation validator, and an ASP.NET Core endpoint that routes HTTP PUT requests to the command handler, returning appropriate HTTP status codes and error responses.

src/Crud/Commands/Put · high confidence

Added database entity template for generating C\# entity classes

Introduced a new project template that scaffolds C\# entity classes, allowing users to generate either a standard entity inheriting from BaseEntity or a list entity inheriting from ValueListEntity based on a boolean parameter. The template configuration defines the structure, including a 'list' option to switch inheritance, and replaces placeholders for the entity name and root namespace.

src/Entity · high confidence

Added logging and validation pipeline behaviors

New LoggingBehaviour and ValidationBehaviour classes have been added to the project. The LoggingBehaviour uses Serilog to record request and response details for every MediatR pipeline execution. The ValidationBehaviour integrates with FluentValidation to automatically validate incoming requests, returning a structured failure response if validation errors are detected.

src/Project/Behaviours, src/Solution/src/Api/Behaviours · high confidence

Database project template now supports PostgreSQL in addition to SQL Server

The Database project template has been updated to allow users to choose between SQL Server and PostgreSQL as their database provider. This is controlled by a new 'postgre' boolean parameter in the template configuration. When PostgreSQL is selected, the generated project includes the necessary Entity Framework Core packages (Npgsql, Npgsql.EntityFrameworkCore.PostgreSQL) and configures the DbContext to use the PostgreSQL provider and extensions. The template also includes scaffolding for migrations and validation.

src/Database · high confidence

Initial project structure and configuration

The project has been initialized with a new directory structure, including a root-level build configuration (Directory.Build.props) that sets the target framework to .NET 8. A new Program.cs entry point was added, configuring the ASP.NET Core pipeline with Serilog, MediatR behaviors, and Swagger. Exception handling was refactored into a dedicated ApiProjectException base class and a specific NotFoundException. Additionally, appsettings.json was split into environment-specific files (appsettings.Development.json) to support different configurations.

src/Project · high confidence

Introduce .NET 8.0-based solution template with Docker and build automation

The ApiSolution template now targets .NET 8.0, providing a modernized base for new projects. This update includes a new .env configuration file to manage environment-specific settings for both SQL Server and PostgreSQL databases, alongside a Dockerfile that utilizes the .NET 8.0 runtime image. Additionally, the template now features a Cake build script that automates the build, test, and Docker container push processes, while a local Docker Compose file is provided to simplify local development setup.

src/Solution · high confidence

Introduce database project scaffolding and EF Core configuration

The Database area now includes a new Entity Framework Core setup, including the ApiSolutionContext, a design-time factory for migrations, and a DependencyInjection helper that registers the DbContext and unit-of-work services. The project references Microsoft.EntityFrameworkCore, the appropriate database provider (SQL Server or PostgreSQL via conditional compilation), and Threenine packages, with a default LocalDb connection string for local development.

src/Solution/src/Database · medium confidence

Introduce new API project template with configurable database support

The Api project has been initialized with a new template, including a Program.cs entry point that configures Serilog, Swagger, MediatR behaviors, and database initialization. Configuration is managed via appsettings.json and appsettings.Development.json, which include conditional logic to support either SQL Server or PostgreSQL via the 'Default' connection string key. The project also includes a Directory.Build.props file to manage shared MSBuild properties and a README.md with setup instructions.

src/Solution/src/Api · high confidence

Introduced Command and Query template scaffolding for Vertical Slice Architecture

Added new template configurations and code structures for generating Command and Query endpoints. The Command template now includes a controller, handler, response, and validator, while the Query template provides a similar structure for read operations. Both templates have been updated to remove the unnecessary 'rootnamespace' parameter and now generate files in the 'Api.Activities.Resource' namespace, aligning with the Vertical Slice Architecture pattern.

src/Command, src/Query · high confidence

New shared constants for connection strings and validation patterns

The Common project now includes two new static classes: ConnectionStringNames, which defines connection string identifiers such as Default and LocalBuild, and RegularExpressions, which provides pre-defined regex patterns for validating names, organization names, domain names, and relative URL paths. These constants are now available for use across the application to standardize connection string references and input validation logic.

src/Solution/src/Common · medium confidence

Standardized project structure and build configuration

The repository has been restructured to support a template pack workflow. A new solution file (ApiTemplatePack.sln) and Directory.Build.props (targeting .NET 8.0) establish a unified build environment. Build automation is now handled by Cake scripts (build.cake, pull-request.cake) that integrate GitVersion for versioning and support publishing to NuGet and GitHub packages. Additionally, an .editorconfig file enforces consistent code style and formatting across the project.

(repo-wide) · high confidence

Removals

Removed sample API endpoint template

The sample API endpoint template (Get.cs) has been removed from the project. This eliminates the placeholder implementation for retrieving articles by ID, which previously relied on the Ardalis.ApiEndpoints framework and Swagger annotations.

Activities · high confidence

Behavioural changes

Added exception handling middleware for API error responses

A new ExceptionHandlingMiddleware has been introduced to the application's request pipeline. This middleware intercepts unhandled exceptions and returns structured JSON error responses containing the title, status code, and message, ensuring consistent error formatting for API consumers.

src/Project/Middleware · high confidence

Centralized validator registration for API solutions

A new static class, ValidatorsRegistration, has been added to the Api/Installers directory. This class provides a RegisterValidators method that configures FluentValidation by scanning the Program and ApiSolutionContext assemblies for validators. This change introduces a centralized mechanism for registering validation logic within the API solution.

src/Solution/src/Api/Installers · medium confidence

Custom Swagger schema for JSON Patch operations

The API now exposes a simplified, custom OpenAPI schema for JSON Patch requests. This filter removes the default complex schema definitions and replaces them with a streamlined 'Operation' and 'JsonPatchDocument' schema, ensuring that Patch endpoints in the Swagger UI display a cleaner, more user-friendly representation of the JSON Patch format.

src/Solution/src/Api/Helpers · high confidence

Swagger UI updated to support JSON Patch operations

A new filter has been added to the Swagger/OpenAPI documentation to properly define the structure for JSON Patch requests. This ensures that API clients can correctly identify and utilize the JSON Patch format for patch operations, with the schema explicitly defining the 'op', 'value', and 'path' properties required for these requests.

src/Project/Helpers · high confidence

Updated domain generation template to target .NET 6.0

The domain generation template has been updated to target .NET 6.0, replacing the previous .NET 5.0 target. Additionally, the template configuration has been renamed from 'API Endpoints starter project' to 'Domain generation template' with the short name 'domain', and the source name has been changed from 'ApiEndpoint' to 'Domx' to align with the new vertical slice architecture approach.

src/Domain · high confidence

Fixes

Fixes CRUD endpoint generation by adding missing route definition

The application now correctly generates CRUD endpoints. A new file, Routes.cs, has been added to define the 'Resource' route constant, ensuring the API routes are properly configured for resource management.

src/Crud · high confidence

Test coverage

Added integration and unit test scaffolding for the solution

Added new test files to the solution's test suite, including integration test assertions for HTTP status codes (200, 201, 400, 404, 500, 409) and a sample HTTP request template for MSSQL-based solution testing. These changes provide a structured foundation for verifying API responses and unit test coverage in the src/Solution/tests directory.

src/Solution/tests · high confidence

Dependencies

Upgrade to .NET 8 and update NuGet dependencies

The project has been upgraded to .NET 8.0, with corresponding updates to all NuGet package references. This includes upgrading Entity Framework Core to version 8.0.1, updating AutoMapper to 12.0.1, and refreshing other dependencies such as FluentValidation, MediatR, and Swashbuckle. The legacy ApiEndpoint.csproj file targeting .NET 5.0 has been removed.

(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 60 → 51 (-8.9)
  • Rubric changed (rubric-2026.09.15 → rubric-2026.10.1) — scores are not directly comparable.

Lenses

  • Code Health 52 → 66 (+13.4)
  • Architecture 65 → 88 (+23.5)
  • Maturity 65 → 66 (+0.9)
  • Readiness 69 → 38 (-30.7)
  • Security 84 → 60 (-24.8)
  • Performance 60 (new)

Resolved (6)

  • Documentation: no installation or build instructions (docs/docs/start/api-project.md)
  • Documentation: no installation or build instructions (docs/docs/start/api-solution.md)
  • Documentation: no installation or build instructions (docs/index.md)
  • Test reliability not included
  • Tests outside the analyzed solution
  • Tests outside the analyzed solution

New (51)

  • Dead code: ApiSolutionContextFactory (src/Solution/src/Database/Database/ApiSolutionContextFactory.cs)
  • Dead code: DatabaseProjectContextFactory (src/Database/DatabaseProject/DatabaseProjectContextFactory.cs)
  • Deprecated: AutoMapper.Extensions.Microsoft.DependencyInjection
  • Deprecated: FluentValidation.AspNetCore
  • Deprecated: xunit
  • Duplicated block (10 lines × 2) (src/Project/Behaviours/LoggingBehaviour.cs)
  • Duplicated block (15 lines × 2) (src/Project/Behaviours/ValidationBehaviour.cs)
  • Duplicated block (16 lines × 2) (src/Project/Middleware/ExceptionHandlingMiddleware.cs)
  • Inconsistent naming for configuration/constant strings. JsonPatchApplication and Operation are generic nouns, whereas the Common.RegularExpressions fields use descriptive names that include the validator/regex purpose (e.g., OrganisationNameValidator, RelativeUrlPath). This mixes generic identifiers with descriptive identifiers for similar constant strings.
  • Inconsistent naming for the exception message property. Both ApiException and ApiProjectException use Title for what is typically a Message or ErrorMessage property. While consistent within themselves, Title is semantically distinct from standard exception properties (Message, StackTrace). If these represent the same concept (the human-readable error text), Title is a non-standard name that should be unified with a more conventional term like Message across both API layers.
  • No tests found
  • Off the main sequence: Common
  • Off the main sequence: Entities (Database/Entities)
  • Outdated: AutoMapper
  • Outdated: FluentValidation
  • Outdated: FluentValidation.AspNetCore
  • Outdated: FluentValidation.DependencyInjectionExtensions
  • Outdated: MediatR
  • Outdated: Microsoft.AspNetCore.JsonPatch
  • Outdated: Microsoft.AspNetCore.Mvc.NewtonsoftJson
  • …and 31 more

Architecture

  • 3 containers · 0 bounded contexts · 0 dependency edges (baseline)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

threenine/api-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 6 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit cff343e658c77d8c8394c1d7e153252e8e5cd8b3 — the exact code this score is about.
  • Scored under rubric-2026.10.1 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-8d8088103122.