Skip to content
CAI
Software that uses CAICheck a score

SaraRasoulian/DotNet-WebAPI-Sample

61.2

Adequate · 21 September 2026

587

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 customer loyalty service built on .NET 8.0, designed to manage user accounts and track point balances. It implements a clean architecture with a CQRS pattern to handle user authentication, profile retrieval, and point accumulation. The backend leverages PostgreSQL for persistence and Redis for caching, exposing these capabilities through a secure WebAPI with JWT-based authorization.

Features

Added Docker support and Redis caching infrastructure

Developers can now run the application and its dependencies (PostgreSQL, PgAdmin, and Redis) locally using Docker Compose. The project includes a Dockerfile, docker-compose.yml, and .dockerignore to streamline local development and testing environments.

(repo-wide) · high confidence

Added user retrieval and login handlers

Introduced new query handlers for user operations. The GetUserHandler enables retrieving user data via a cache-based lookup, while the LoginHandler manages authentication by validating credentials and generating JWT tokens. These handlers implement the MediatR pattern, with the login process including logging and token generation using configured JWT settings.

src/Application/Users/Handlers/QueryHandlers · medium confidence

Global exception handling middleware added

A new GlobalExceptionHandler middleware has been introduced to centralize error handling across the API. This ensures that unhandled exceptions are caught and returned as consistent JSON error responses, with specific status codes for bad requests versus internal server errors.

src/WebAPI/Middleware · high confidence

Initial WebAPI setup with authentication, logging, and caching

The WebAPI project is initialized with a complete request pipeline, including JWT-based authentication and authorization, Serilog-based structured logging, and Redis caching support. The application also includes a global exception handler and Swagger documentation for development.

src/WebAPI · medium confidence

Initial database migration for the Customer Loyalty system

The application now includes an initial database migration that creates a 'Users' table to support the Customer Loyalty feature. This migration, generated from the new \CustomerLoyaltyDBContext\, establishes the schema for user data (including email, name, and point balance) and seeds a default test user ('Sara Rasoulian') into the database.

src/Infrastructure/Migrations · high confidence

Introduce domain model and repository interfaces for user management

Added foundational domain classes including base entity and auditable entity records, a User entity with properties for name, username, email, and point balance, and an Email value object that validates email format. Also introduced the IUserRepository interface defining methods for retrieving users by ID or credentials, updating user data, and saving changes, laying the groundwork for user data access and persistence.

src/Domain · high confidence

Introduce user repository with Redis caching

Added a new UserRepository implementation that provides methods to retrieve and update user data. The GetAsync and Update methods interact with the database context, while GetFromCacheAsync introduces a new caching layer using Redis (via IDistributedCache) to store and retrieve user entities, improving read performance for frequently accessed user data.

src/Infrastructure/Repositories · high confidence

Behavioural changes

Added EarnPoints command handler

A new EarnPointsHandler has been introduced to process the EarnPointsCommand, implementing the CQRS pattern via MediatR. This handler retrieves the user, updates their point balance, persists the change, and logs the action using Serilog.

src/Application/Users/Handlers/CommandHandlers · medium confidence

Configure User entity mapping for code-first database setup

A new Entity Framework Core configuration class, UserConfiguration, has been added to define the mapping for the User entity. This includes setting primary keys, required fields, maximum lengths for names, username, and email, as well as unique indexes for username and email. This change supports the shift to a code-first database approach, ensuring the database schema aligns with the domain model.

src/Infrastructure/Configurations · high confidence

Configure database, Redis cache, and repository services

The infrastructure layer now registers services for a PostgreSQL database using Entity Framework Core with NodaTime support, a StackExchange Redis cache, and the UserRepository implementation via the repository pattern. These registrations are added to the dependency injection container, enabling database connectivity, caching, and data access abstractions for the application.

src/Infrastructure · high confidence

Introduce CQRS-based user operations with automatic validation

The application layer now implements the CQRS pattern using MediatR, introducing new commands and queries for earning points, retrieving user details, and logging in. A global validation pipeline automatically enforces rules defined by FluentValidation validators on all requests. Request and response models (EarnPointsRequest, UserResponse, ErrorResponse) and user-related constants have been added to support these operations.

src/Application · high confidence

New identity and user management endpoints

Added new API controllers for identity and user management. The IdentityController provides a login endpoint at /api/identity/login. The UsersController exposes a GET endpoint at /api/users/{userId} to retrieve user details and a POST endpoint at /api/users/{userId}/earn to award points, with the latter requiring authorization.

src/WebAPI/Controllers · high confidence

Test coverage

Add integration tests for user and points handlers; Added integration tests for user and earn point endpoints; Added unit tests for EarnPoints and GetUser handlers; Added unit tests for the Email value object.

Dependencies

Added .NET 8.0 project structure with new dependencies

The project has been restructured into a clean architecture with separate Application, Domain, Infrastructure, and WebAPI layers, all targeting .NET 8.0. This update introduces a comprehensive set of dependencies including MediatR for CQRS, FluentValidation, Mapster, and Serilog for logging. The Infrastructure layer adds Entity Framework Core with PostgreSQL and Redis caching, while the WebAPI layer integrates JWT authentication and Swagger. Test projects for unit and integration testing have also been established with xUnit, Moq, and Testcontainers.

(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 68 → 61 (-7.0)
  • Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 75 → 65 (-9.9)
  • Architecture 90 → 90 (-0.3)
  • Maturity 78 → 78 (+0.0)
  • Readiness 55 → 46 (-9.2)
  • Security 91 → 90 (-0.7)

Resolved (7)

  • Build status unknown
  • Medium IaC: CKV_DOCKER_3 (Dockerfile)
  • Medium IaC: CKV_SECRET_6 (docker-compose.yml)
  • No exposed public API
  • no production source files with tracked history to analyse
  • redundant comment (src/Infrastructure/DbContexts/CustomerLoyaltyDBContext.cs)
  • single-maintainer — knowledge-concentration (bus factor) risk

New (7)

  • Documentation: no usage examples (README.md)
  • Duplicate test method declaration with identical signature and attribute in the same class. This is a compilation error rather than a naming inconsistency, but indicates a structural issue in the test file.
  • High IaC: WD-COMPOSE-0002 (docker-compose.yml)
  • High IaC: WD-COMPOSE-0002 (docker-compose.yml)
  • High IaC: WD-COMPOSE-0002 (docker-compose.yml)
  • Medium IaC: WD-DOCKER-0003 (Dockerfile)
  • Medium IaC: WD-DOCKER-0003 (Dockerfile)

API surface

  • Unchanged — 3 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

SaraRasoulian/DotNet-WebAPI-Sample 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 21 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 f5a81cb4ce92016eb998a304be2db70162c565b4 — 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-fa71c66cabd8.