Skip to content
CAI
Software that uses CAICheck a score

mt89vein/BookLibrary

63.9

Weak · 21 September 2026

5.6k

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 9-based library management service built on Clean Architecture and Domain-Driven Design principles. It provides core capabilities for managing book inventories and library members, including registering users, adding books, and handling the borrowing and returning workflows with strict limit enforcement. The application exposes these features through a RESTful API with standardized error handling, pagination, and mock authentication, while maintaining data consistency through domain events and background job infrastructure.

How it got here

2024 — Initial project scaffolding and core domain implementation

23 changes.

The project was initialized with a .NET 9 Clean Architecture solution, establishing the foundational domain model for books and library members. Core application features were implemented to support user registration, book management, and borrowing workflows, alongside infrastructure for persistence and observability. The API layer was configured with standardized error handling, authentication, and comprehensive documentation.

2025–2026 — modular architecture and test infrastructure

4 changes.

The project established a modular architecture by introducing dedicated modules for API registration, background jobs, and Kafka consumers, alongside a centralized host entry point. This structural reorganization was supported by the addition of comprehensive integration and architecture tests to enforce layering rules and verify endpoint behavior.

Features

Ability to return borrowed books

Users can now return books that were previously borrowed. This change introduces the ReturnBook use case, which validates the book and borrower, updates the book's status to returned with the current timestamp, and persists the change to the database. The operation includes structured logging for tracking and handles errors by returning specific failure results if the book is not found or if the return process fails.

BookLibrary.Application/Features/Books/ReturnBook · high confidence

Abonent registration capability introduced

Users can now register new library members (abonents) via a dedicated use case. This change adds the RegisterAbonentUseCase to handle the registration logic, including validation of the email address using a new Email value object and persistence of the new abonent record. The feature is wired into the application's dependency injection container via ServiceCollectionExtensions, making the registration command available for execution.

BookLibrary.Application/Features/Abonents, BookLibrary.Domain/ValueObjects · high confidence

Add API for querying books with pagination

Users can now retrieve a paginated list of books, filtering by title or ISBN. The response includes book details such as title, ISBN, publication date, authors, and availability status, along with pagination metadata like page number, page size, and whether a next page exists.

BookLibrary.Application/Features/Books/GetPagedBooks · high confidence

Add ability to retrieve book details with borrowing status

Introduces a new use case for fetching a specific book by its ID, which now includes borrowing information relevant to the requesting user. The response exposes the book's core metadata (title, ISBN, publication date, authors) alongside a new BorrowInfo field, allowing users to see current lending status when querying individual book details.

BookLibrary.Application/Features/Books/GetBook · high confidence

Add book borrowing and borrowed-books retrieval capabilities

Users can now borrow books by providing an abonent ID and either a specific book ID or an ISBN with publication date, with the system enforcing borrowing limits and tracking return dates. Additionally, users can retrieve a list of their currently borrowed books, including details such as title, ISBN, publication date, and the deadline for return.

BookLibrary.Application/Features/Books/BorrowBook · high confidence

Add helper to extract authenticated user ID from HTTP context

A new extension method, GetUserId, is now available on HttpContext to simplify retrieving the current user's identifier. This method validates that the request is authenticated and extracts the user ID from the 'sub' claim, throwing a specific exception if the user is undefined or unauthenticated.

BookLibrary.Api/Extensions · high confidence

Add new book use case with structured logging and error handling

Users can now add new books to the library via a dedicated use case that accepts ISBN, title, publication date, authors, and quantity. The implementation includes structured logging for auditability and uses a Result pattern to handle failures, returning a specific error code if the operation fails.

BookLibrary.Application/Features/Books/AddNewBook · high confidence

Added automatic query tagging for debugging

A new extension method, TagWithFileMember, is now available for Entity Framework Core queries. This method automatically appends a tag to the generated SQL containing the source file name and method name where the query was called, aiding in the identification and debugging of database queries without requiring manual tagging.

BookLibrary.Application/Extensions · high confidence

Added mock email-based authentication for the account API

The BookLibrary.Api/Auth module now includes an AccountController that supports logging in via email and logging out. This implementation uses a simple mock authentication scheme ('Mock') that issues a session cookie ('sid') containing user claims, allowing users to authenticate for API access. This is explicitly noted as a non-production, showcase variant.

BookLibrary.Api/Auth · high confidence

Added pagination support for book queries

Users can now query books with pagination. This change introduces a generic PageDto to wrap paginated results and a PagedExtensions helper that efficiently fetches a specific page of items while indicating whether additional pages are available.

BookLibrary.Application/Dto · high confidence

Book borrowing and statistics tracking infrastructure

The BookLibrary.Infrastructure module now supports the ability to borrow books and tracks related statistics. This includes new domain events (BookBorrowCreated, BookBorrowDeleted) that trigger updates to a BookStat table, managed by a BookStatChangeWatcher and an outbox-based applier to ensure consistency. The database schema has been extended with migrations to add a 'created\_at' timestamp to books and abonents, change the borrow return date type to DateOnly, and introduce the BookStat and BookStatChange tables with GIN trigram indexes for efficient text search.

BookLibrary.Infrastructure · high confidence

Enhanced Swagger documentation with multi-response support and error examples

The API documentation now provides richer detail for consumers by supporting multiple responses for the same HTTP status code and including concrete examples for error scenarios. A new \MultipleProducesOperationFilter\ allows endpoints to define several response bodies for a single status code, while \SwaggerErrorCodeResponse\ attributes automatically generate example payloads for specific error codes using \ErrorCodeProblemDetails\. The Swagger UI is also configured to display request duration and enable deep linking, and the generator is set up to include XML comments and handle conflicting route actions.

BookLibrary.Api/Swagger · high confidence

Initial application layer setup with service registration and feature flags

The BookLibrary.Application project has been initialized with core infrastructure components. A new FeatureFlags class provides a constant for controlling automatic database migrations on startup. Additionally, ServiceCollectionExtensions introduces the AddApplication method, which registers the DomainEventsReducer as a singleton and wires up the Abonents and Books feature modules into the dependency injection container.

BookLibrary.Application · high confidence

Initial domain model for library books and abonents

This change introduces the core domain entities for the library system, including the Book aggregate root and the Abonent (member) entity. Users can now register as abonents, and the system supports the full lifecycle of borrowing and returning books, including validation for borrowing limits (max 3 books) and return dates. The domain also defines value objects for book details (title, ISBN, publication date, authors) and tracks borrowing information, emitting domain events for registration, creation, borrowing, and returning actions.

BookLibrary.Domain/Aggregates · high confidence

Initial infrastructure interfaces for application context, metrics, and logging

This change introduces the foundational infrastructure contracts for the Book Library application. It defines the \IApplicationContext\ interface to manage database sets for Abonents, Books, and BookStats, enabling data persistence operations. Additionally, it adds \IMetricCollector\ to track key business events such as book creation, borrowing, returning, and abonent registration, supporting observability. The \IUuidGenerator\ interface provides a standardized way to generate unique identifiers, while the \LoggingScope\ class establishes consistent naming conventions for logging contexts related to users, abonents, and books.

BookLibrary.Application/Infrastructure · high confidence

Initial project scaffolding with .NET 9 and Clean Architecture

The repository is initialized with a .NET 9 solution structured around Clean Architecture and DDD principles, including distinct projects for Domain, Application, Infrastructure, API, and background jobs. The build environment is configured with strict code analysis, nullable reference types, and a ban on \DateTime.Now\ to enforce UTC usage. The setup also includes tooling for development such as Husky for git hooks, Docker for local PostgreSQL, and comprehensive test suites for unit, integration, and architecture validation.

(repo-wide) · high confidence

Introduction of core domain primitives for event handling and value equality

The SeedWork library now provides foundational building blocks for domain-driven design, including an \IEntity\ interface and abstract \Entity\ base class that manage domain events (adding, clearing, and moving them between entities), an \IDomainEvent\ interface extending MediatR's \INotification\, and a \ValueObject\ abstract class that implements value-based equality and hashing.

SeedWork · high confidence

New book library management endpoints and standardized error handling

The API now exposes a complete set of book management operations: adding new books, borrowing and returning them, retrieving individual book details, and searching the catalog with pagination. Additionally, a new endpoint allows users to register as library members (abonents) and view their currently borrowed books. To support these features, a base ApiController was introduced to standardize how domain errors and success results are returned to clients via ProblemDetails.

BookLibrary.Api/Features/Books · high confidence

Architecture

Extracted modular registration scaffolds for background jobs, consumers, and Kafka

The application structure now includes dedicated module classes to organize dependency registration for specific subsystems. A new \BackgroundJobsModule\ provides a registration point for background processing tasks (such as Hangfire or Quartz), a \ConsumersModule\ serves as the entry point for registering Kafka consumers, and a \ServiceCollectionExtensions\ class in the Kafka assembly is prepared for common Kafka types and DTOs. These changes establish a modular pattern for wiring up these components within the WebApplication builder.

BookLibrary.BackgroundJobs, BookLibrary.Consumers, BookLibrary.Kafka · high confidence

Behavioural changes

Domain event handlers now collect metrics and reduce duplicate book creation events

The application now automatically tracks key library activities—such as abonent registration, book creation, borrowing, and returning—by invoking the metric collector within new domain event handlers. Additionally, when multiple books with identical metadata (title, ISBN, publication date) are created in a single transaction, the system consolidates them into a single aggregated event to reduce noise and improve efficiency.

BookLibrary.Application/Features/DomainEventHandlers · high confidence

Enforce commit message conventions and pre-commit checks

The repository now enforces Conventional Commits for commit messages, requiring a valid type (such as feat, fix, or chore) and a descriptive subject, while allowing task-scoped commits (e.g., feat(BKL-123): subject) to bypass the strict format. Additionally, a pre-commit hook is configured to automatically format C\# files, build the project, and run unit and architecture tests before changes are committed.

.husky · high confidence

Introduce modular API registration and dedicated host entry point

The application now uses a structured \ApiModule\ in \BookLibrary.Api\ to centralize service configuration, including Swagger, FluentValidation, and a mock authentication scheme, while \BookLibrary.Host\ serves as the new single-process entry point that wires together the API, infrastructure, background jobs, and consumers. This change also adds development configuration files (launch settings, app settings) and an HTTP client file for easier local testing of endpoints like login, book search, and borrowing.

BookLibrary.Api, BookLibrary.Host · high confidence

Registration of book management use cases

The application now registers the core book management use cases—adding new books, retrieving individual or paged book lists, borrowing books, returning books, and fetching borrowed books—into the dependency injection container via the new ServiceCollectionExtensions.

BookLibrary.Application/Features/Books · high confidence

Structured domain error handling with specific error codes

The BookLibrary.Domain layer now uses a centralized ErrorCodes enum and a Result pattern to handle domain failures. This introduces specific, identifiable error states for book and abonent operations (such as borrowing, returning, and registration), replacing generic exceptions with structured error results that include error codes, criticality levels, and unique identifiers for better debugging and user feedback.

BookLibrary.Domain · high confidence

Structured error responses with domain error codes and trace IDs

The API now returns standardized ProblemDetails responses that include domain-specific error codes and HTTP status mappings (e.g., mapping invalid data errors to 400 Bad Request or book conflicts to 409 Conflict). Error responses automatically include a trace ID for debugging, and detailed error information is exposed in non-production environments. Validation failures are also handled consistently with these structured error details.

BookLibrary.Api/ProblemDetails · high confidence

Test coverage

Added integration and architecture tests for the Book Library

Added a comprehensive test suite including architecture validation tests (using ArchUnitNET) to enforce layering rules for Domain, Application, and Infrastructure layers, and integration tests (using NUnit and WebApplicationFactory) to verify Book API endpoints such as borrowing and retrieving books. The integration tests utilize a pooled PostgreSQL test container strategy with database cloning for parallel execution, custom NUnit constraints for verifying HTTP ProblemDetails responses, and snapshot verification for API interactions.

tests, tests/BookLibrary.IntegrationTests.NUnit/Features/Books · high confidence

Dependencies

Initial project structure and dependency configuration

This change introduces the foundational project structure for the Book Library application, defining the solution's modular architecture (Api, Application, Domain, Infrastructure, Host, BackgroundJobs, Consumers, Kafka, SeedWork) and establishing the documentation site with Docusaurus. It configures a comprehensive set of dependencies via central package management, including .NET 9.0 targeting, PostgreSQL data access with Entity Framework Core, OpenTelemetry for observability, Serilog for logging, and Swagger for API documentation, alongside a full suite of testing tools (NUnit, Testcontainers, Verify).

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

Lenses

  • Code Health 90 → 60 (-29.5)
  • Architecture 84 → 84 (+0.1)
  • Maturity 82 → 82 (+0.0)
  • Readiness 60 → 58 (-2.2)
  • Security 69 → 71 (+1.9)
  • Domain Modelling 100 (new)
  • Performance 75 → 75 (-0.3)

Resolved (18)

  • BarePragmaDisable (BookLibrary.Domain/Aggregates/Abonents/Abonent.cs)
  • BarePragmaDisable (BookLibrary.Domain/Aggregates/Abonents/ValueObjects/AbonentName.cs)
  • BarePragmaDisable (BookLibrary.Domain/Aggregates/Books/Book.cs)
  • BarePragmaDisable (BookLibrary.Domain/Aggregates/Books/ValueObjects/Author.cs)
  • BarePragmaDisable (BookLibrary.Domain/Aggregates/Books/ValueObjects/BorrowInfo.cs)
  • Bounded contexts not declared
  • Build status unknown
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Inconsistency in the term for 'Abonent'/'Abonnement'. The domain aggregate is 'Abonent', but a related concept is 'Abonement'. This suggests a potential confusion between the person (Abonent) and the subscription/contract (Abonnement/Abonement).
  • No exposed public API
  • Off the main sequence: BookLibrary.Infrastructure
  • The method 'GetAbonenementAsync' contains a typo ('Abonenement' instead of 'Abonent' or 'Abonnement').
  • The term 'Abonent' is used for the entity, but the event is misspelled as 'AbonentRegistredEvent' (missing 'e' in Registered). Additionally, the namespace uses 'Abonents' (plural) while the type is 'Abonent' (singular).
  • early-stage repository — too few commits for a meaningful bus factor
  • early-stage repository — too little history to judge knowledge freshness

New (63)

  • AnalyzerSeverityNone (.editorconfig)
  • AnalyzerSeverityNone (BookLibrary.Infrastructure/EntityFramework/Migrations/.editorconfig)
  • AnalyzerSeverityNone (BookLibrary.Infrastructure/EntityFramework/Migrations/.editorconfig)
  • AnalyzerSeverityNone (BookLibrary.Infrastructure/EntityFramework/Migrations/.editorconfig)
  • AnalyzerSeverityNone (BookLibrary.Infrastructure/EntityFramework/Migrations/.editorconfig)
  • AnalyzerSeverityNone (BookLibrary.Infrastructure/EntityFramework/Migrations/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • AnalyzerSeverityNone (tests/.editorconfig)
  • CoverageExclusion (BookLibrary.Api/Features/Abonents/RegisterAbonent.cs)
  • CoverageExclusion (BookLibrary.Api/Features/Books/AddNewBook.cs)
  • CoverageExclusion (BookLibrary.Api/Features/Books/GetBook.cs)
  • CoverageExclusion (BookLibrary.Api/Features/Books/GetBorrowedBooks.cs)
  • …and 43 more

API surface

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

mt89vein/BookLibrary 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 ffc25889fbb7b2400b9aa888b3c0047656c3873d — 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.