evolutionary-architecture/evolutionary-architecture-by-example
48.3
Weak · 8 November 2026
6.3k
lines of production code
C#
primary language
4
measurements over time
What this system is
Fitnet is a gym management system that handles the end-to-end lifecycle of customer contracts, membership passes, and promotional offers. It exposes REST APIs to prepare and sign contracts, register and expire passes, and generate monthly registration reports, while automatically triggering downstream actions like pass registration and offer creation via an event bus. The system evolved from a modular monolith to a hybrid architecture, extracting the Contracts domain into a separate microservice while retaining Passes, Offers, and Reports in the main application, all supported by PostgreSQL and RabbitMQ.
How it got here
2023 — modularization and microservice extraction
116 changes.
The project evolved from a monolithic .NET 9 application into a modular architecture, extracting shared infrastructure into a standalone Fitnet.Common solution and isolating the Contracts domain as a separate microservice. This period focused on decoupling modules like Passes, Offers, and Reports, implementing configuration-driven enablement, and standardizing event-driven communication via MassTransit and the outbox pattern. Comprehensive integration and architecture tests were added to enforce module boundaries and validate the new distributed workflows.
2024 — Chapter 4 tactical DDD and microservice extraction
62 changes.
This period focused on implementing Chapter 4 by extracting the Contracts domain into a dedicated microservice and applying tactical Domain-Driven Design patterns across the Fitnet solution. The work established a robust infrastructure using .NET 10, Entity Framework Core with PostgreSQL, and MassTransit for event-driven communication, while introducing ErrorOr result types and a business rule validation framework to handle domain logic and errors consistently. Comprehensive integration and unit tests were added to verify the new contract lifecycle, annex management, and the underlying test infrastructure.
2025–2026 — Aspire orchestration and infrastructure setup
4 changes.
This period focused on establishing a robust local development environment using .NET Aspire to orchestrate the Fitnet modular monolith and the Fitnet.Contracts microservice. The work involved configuring dedicated AppHost projects for each service, provisioning PostgreSQL and RabbitMQ dependencies, and organizing infrastructure code within dedicated source directories to streamline development workflows.
Features
Add API endpoint for preparing new contracts
The Fitnet.Contracts.Api layer now exposes a POST endpoint at the prepare contract path, allowing users to initiate the preparation of a contract for new or existing customers. This endpoint accepts a request containing the customer ID, age, height, and preparation date, validates these inputs (ensuring IDs and dates are present and age/height are positive), and returns the prepared contract ID upon success or appropriate error codes for conflicts or internal issues.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Api/PrepareContract · high confidence
Add ContractSignedEvent integration event
A new integration event, ContractSignedEvent, has been added to the Fitnet.Contracts module. This event captures key details when a contract is signed, including the contract ID, customer ID, signing and expiration dates, and the timestamp of the event occurrence. It includes a factory method to simplify event creation.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.IntegrationEvents · high confidence
Add EventBus configuration and outbox support to Passes API
The Passes API now includes dedicated infrastructure for event bus integration via a new \EventBusModule\ and \EventBusOptions\. This change wires up MassTransit with RabbitMQ, allowing configuration of the broker URI, username, and password through application settings. Additionally, an Entity Framework Core outbox is configured using PostgreSQL with a 30-second duplicate detection window to ensure reliable message delivery.
Chapter-3-microservice-extraction/Fitnet/Src/Passes/Fitnet.Passes.Api/Common · high confidence
Add PassExpiredEvent integration event
The Passes integration events library now includes a PassExpiredEvent record to signal when a customer's pass expires. This event carries the pass and customer identifiers along with the timestamp of the expiration, enabling downstream services to react to pass expiry.
Chapter-3-microservice-extraction/Fitnet/Src/Passes/Fitnet.Passes.IntegrationEvents · high confidence
Add Terminate Binding Contract API endpoint
The Fitnet.Contracts.Api now exposes a new PATCH endpoint for terminating an existing binding contract. The endpoint accepts a binding contract ID via the route, executes the termination command through the contracts module, and returns a 204 No Content on success or appropriate error responses (404, 409, 500) via the standard problem details format.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Api/TerminateBindingContract · high confidence
Add configurable fake time provider for integration tests
The integration test toolbox now includes a \FakeTimeProvider\ that allows tests to simulate specific dates and skip forward in time, along with an extension method to register this provider with the test web application factory, enabling deterministic testing of time-dependent logic.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine/Time · high confidence
Add database entity configurations for contracts, binding contracts, and annexes
The application now includes Entity Framework Core configuration classes for the Contract, BindingContract, and Annex entities. This enables persistent storage of binding contracts with their associated annexes (stored in a separate 'Annexes' table) and ensures that contract signatures are persisted as value objects within the 'Contracts' table.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/Database/Configurations · high confidence
Add database test container and configuration interface for integration tests
The integration test toolbox now includes a \DatabaseContainer\ class that manages a PostgreSQL 15.15 test instance using Testcontainers, providing a connection string for test execution, alongside an \IDatabaseConfiguration\ interface to expose database settings.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine/Database · high confidence
Add endpoint for monthly new pass registrations report
The Fitnet Reports module now exposes a new GET endpoint that returns a report of all passes registered in a given month. The endpoint retrieves data using Dapper against the database, grouping pass registrations by month and year, and returns the results as a collection containing the month order, month name, and count of registered passes.
Chapter-3-microservice-extraction/Fitnet/Src/Reports/Fitnet.Reports/GenerateNewPassesRegistrationsPerMonthReport · high confidence
Add endpoint to mark a pass as expired
A new PATCH endpoint has been added to allow marking a specific pass as expired. When invoked, the system retrieves the pass, marks it as expired using the current UTC time, persists the change, and publishes a PassExpired event to notify other parts of the system. The endpoint returns a 204 No Content on success, 404 if the pass is not found, and 500 for internal errors.
Chapter-1-initial-architecture/Src/Fitnet/Passes/MarkPassAsExpired · high confidence
Add endpoint to retrieve all passes
A new API endpoint has been added to retrieve all existing passes in the system. This feature exposes a GET route that queries the database for all pass records, maps them to a simplified DTO containing only the pass ID and customer ID, and returns the collection in a standardized response object. The endpoint includes Swagger documentation to describe its purpose and return types.
Chapter-1-initial-architecture/Src/Fitnet/Passes/GetAllPasses · high confidence
Added API documentation redirect endpoint
The application now includes a root endpoint that automatically redirects users to the API documentation at /docs/v1, providing a convenient entry point for exploring the API reference.
Chapter-1-initial-architecture/Src/Fitnet/Common/Documentation · high confidence
Added ContractSignedEvent integration event
The Fitnet.Contracts.IntegrationEvents module now includes a new ContractSignedEvent record to signal when a contract is signed. This event carries essential details such as the contract ID, customer ID, signing date, expiration date, and the timestamp of when the event occurred, enabling downstream systems to react to contract signings.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.IntegrationEvents · high confidence
Added database migration for the Offers table
A new Entity Framework Core migration has been added to create the 'Offers' table within the 'Offers' schema. This migration introduces columns for the offer's unique identifier, customer ID, discount amount, validity period (start and end dates), and the timestamp when the offer was prepared, establishing the persistent storage structure for the offer preparation feature.
Chapter-1-initial-architecture/Src/Fitnet/Offers/Data/Database/Migrations · high confidence
Added reusable fake time provider for integration tests
The integration test toolbox now includes a \FakeTimeProvider\ and corresponding extension methods, allowing tests to inject a controllable time source into the application's dependency injection container. This enables deterministic testing of time-dependent logic by overriding the system's current UTC time.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine/Time · high confidence
Adds centralized API error handling and request validation infrastructure
The Fitnet.Common.Api library now provides foundational middleware and filters for the application's HTTP layer. It introduces an ExceptionMiddleware that catches unhandled exceptions and returns structured JSON error responses, distinguishing between 404 Not Found and 500 Internal Server Error. Additionally, it includes a RequestValidationApiFilter that integrates with FluentValidation to automatically validate incoming requests and return 400 Bad Request responses with validation details, along with helper extensions to wire these components into the ASP.NET Core pipeline.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Api · high confidence
Attach annex to binding contract capability
Users can now attach an annex to a binding contract by providing the binding contract ID and a valid-from date. The system processes this request, updates the binding contract with the new annex, persists the change, and returns the unique identifier of the newly attached annex.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/AttachAnnexToBindingContract · high confidence
Automated offer preparation upon pass expiration
A new event handler has been introduced to automatically prepare standard pass extension offers when a customer's pass expires. This component listens for the PassExpiredEvent, creates a new offer record in the database using the current UTC time, and subsequently publishes an OfferPrepareEvent to notify other parts of the system.
Chapter-1-initial-architecture/Src/Fitnet/Offers/Prepare · high confidence
Automated pass registration upon contract signing
The system now automatically registers a new pass for a customer when a contract is signed, eliminating the need for manual registration. This is implemented via a new event handler that listens for the ContractSignedEvent, creates the pass with the appropriate validity dates, persists it, and publishes a PassRegisteredEvent to notify other parts of the system.
Chapter-1-initial-architecture/Src/Fitnet/Passes/RegisterPass · high confidence
Chapter 4 solution scaffolding with .NET 10 and centralized configuration
The Chapter 4 Fitnet solution is initialized with a new project structure and centralized build configuration. The solution now targets .NET 10 (net10.0) via Directory.Build.props, which also enforces strict code analysis, nullable references, and implicit usings. A new .editorconfig standardizes coding conventions, formatting, and naming rules across the solution. The project layout is defined in Fitnet.slnx, organizing Offers, Passes, and Reports into folders with their respective APIs, data access layers, and integration tests. Additionally, a Dockerfile is provided for containerization, and a nuget.config is added to configure package sources, including a private GitHub feed for EvolutionaryArchitecture packages.
Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src · high confidence
Configurable RabbitMQ event bus integration via MassTransit
The Fitnet.Contracts service now supports an external event bus infrastructure using MassTransit and RabbitMQ. This change introduces configuration options for the RabbitMQ connection URI, username, and password, allowing the application to connect to a remote message broker. If these external credentials are not provided, the event bus registration is skipped, maintaining the previous behavior of not configuring an external bus.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/EventBus · high confidence
Contract domain logic and mediation infrastructure extracted
The Contracts module now includes its core domain model, defining how a contract is prepared (validating age, height, and previous contract status) and signed (enforcing a 30-day window). This change also introduces the MediatR infrastructure setup within the Contracts module to handle command mediation, decoupling the application logic from the infrastructure layer.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Core, Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/Mediation · high confidence
Contracts application module introduces command handlers and event publishing
The Contracts application layer now implements the Prepare and Sign contract workflows using the MediatR library. The PrepareContractCommandHandler creates new contracts by retrieving previous history and persisting them via the repository. The SignContractCommandHandler validates the contract, updates its status using a TimeProvider for current UTC time, and publishes a ContractSignedEvent to the event bus upon successful signing. These changes establish the core application logic for contract lifecycle management within this module.
Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Application · high confidence
Contracts module infrastructure initialization
The Contracts module's infrastructure layer has been established, introducing a dedicated database persistence setup using Entity Framework Core with PostgreSQL. This includes automatic database migrations, a configuration-based connection string pattern (Modules:Contracts:ConnectionStrings), and the registration of the Contracts repository. Additionally, the module now integrates MediatR for command handling and exposes an InfrastructureModule for dependency injection and application builder extensions.
Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Infrastructure · high confidence
Contracts service database infrastructure and migrations
The Contracts service now includes its own database persistence layer using Entity Framework Core with PostgreSQL. This adds automatic migration execution at startup, configures the 'Contracts' schema, and defines the database model for contracts including columns for Id, CustomerId, PreparedAt, SignedAt (nullable), Duration, and ExpiringAt. The implementation provides a repository pattern for contract data access and registers the necessary dependency injection services.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/Database · high confidence
Extracted common API and core utilities into a shared library
The Fitnet.Common.Api and Fitnet.Common.Core packages have been introduced to centralize shared infrastructure. This includes a reusable error-handling middleware that standardizes exception responses (mapping business rule violations to 409 and not-found errors to 404), automatic request validation via FluentValidation filters, a business rule validation framework, and a system clock abstraction for time-based operations. These components are now available as a single NuGet package for other services to consume.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.Api · high confidence
Fitnet service initialization with modular architecture and Scalar API docs
The Fitnet application has been initialized with a new structure that registers distinct modules (Passes, Offers, Reports) via a central Module definition, enabling feature toggles through the Modules configuration section. The startup pipeline now includes a centralized clock provider and utilizes Scalar for API documentation in development environments instead of Swagger. Configuration is managed via appsettings files that define database connection strings, event bus settings, and module enablement states, while the Program class orchestrates the registration of these modules and applies error handling middleware.
Chapter-3-microservice-extraction/Fitnet/Src/Fitnet · high confidence
Implement database persistence for contracts and binding contracts
The application now supports saving and retrieving contracts and binding contracts via a database. This change introduces Entity Framework Core-based repositories (ContractsRepository and BindingContractsRepository) that handle CRUD operations, including finding entities by ID with error handling for not-found cases. The repository implementations are registered in the dependency injection container via RepositoriesModule, enabling the application layer to persist and query contract data.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/Database/Repositories · high confidence
Initial Fitnet application structure with .NET 9 and Scalar API documentation
The Fitnet application has been established with an initial architecture targeting .NET 9, featuring a modular setup for Passes, Contracts, Offers, and Reports. The API documentation interface has been upgraded from Swagger UI to Scalar, accessible at /docs/v1 in development environments. The application includes a business rules engine for validation, a centralized clock module using TimeProvider, and configurable database connection strings for local development.
Chapter-1-initial-architecture/Src/Fitnet · high confidence
Initial Passes module scaffolding with API paths and endpoint mapping
The Passes module is introduced with a new namespace and foundational structure. It defines API path constants for retrieving all passes and marking a pass as expired, maps these endpoints via the endpoint router, and registers the module's database dependencies and middleware in the application builder.
Chapter-1-initial-architecture/Src/Fitnet/Passes · high confidence
Initial Reports module scaffolding
The application now includes a dedicated Reports module that provides the infrastructure for generating reports. This change introduces the API path definitions for report endpoints, registers the necessary services and data access components via the module's dependency injection setup, and maps the initial endpoint for generating a 'New Passes Registrations Per Month' report.
Chapter-1-initial-architecture/Src/Fitnet/Reports · high confidence
Initial database persistence layer for contracts
The Contracts module now includes its own database persistence infrastructure, introducing a dedicated EF Core DbContext (ContractsPersistence) that operates under the 'Contracts' schema. This setup utilizes the Options pattern to read the connection string from configuration, registers the necessary services via a DatabaseModule, and applies automatic migrations at application startup to ensure the database schema is up to date.
Chapter-1-initial-architecture/Src/Fitnet/Contracts/Data/Database · high confidence
Initial implementation of new pass registrations per month report data retriever
Added the interface and implementation for retrieving new pass registrations grouped by month. The data retriever queries the database using Dapper to extract the month order, month name, and count of new passes for the current year, returning the results as a collection of DTOs.
Chapter-1-initial-architecture/Src/Fitnet/Reports/GenerateNewPassesRegistrationsPerMonthReport/DataRetriever · high confidence
Initial setup of integration test engine and MediatR mediation module
This change introduces the foundational infrastructure for Chapter 4, adding a custom WebApplicationFactory to load specific integration test settings and registering the MediatR library to handle command and query mediation within the Contracts module.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine, Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/Mediation · high confidence
Initial setup of the Fitnet.Contracts microservice
The Fitnet.Contracts microservice has been introduced as a new standalone component within the system. This entry establishes the foundational structure for the service, including its entry point (Program.cs), configuration files (appsettings.json), and Docker ignore rules. It configures the service to use Scalar for API documentation in development environments, integrates a clock provider for time management, and sets up connections to PostgreSQL and RabbitMQ for database and event bus operations respectively.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts · high confidence
Initial setup of the Fitnet.Contracts microservice with Scalar API docs
The Fitnet.Contracts microservice is introduced in Chapter 4, providing the foundational structure for managing contracts. This includes the registration of a system clock for time-dependent operations and the configuration of Scalar as the API documentation interface in development environments, accessible at /docs/v1. The service is configured with default database and event bus connection settings in its appsettings files.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts · high confidence
Initialize Chapter 4 Fitnet monolith with Scalar API docs and module configuration
The Fitnet application entry point is established for Chapter 4, wiring up the Passes, Offers, and Reports modules via dependency injection and registering a global clock service. In development environments, the API documentation interface has been switched to Scalar (accessible at /docs/v1) instead of Swagger, and the application defaults to launching this documentation page. Configuration is structured to manage module enablement and distinct database connection strings for each module, alongside an event bus setup for local RabbitMQ connectivity.
Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Fitnet · high confidence
Introduce .NET Aspire orchestration for local development
The Fitnet.AppHost project now uses .NET Aspire to orchestrate the application's modules. This change introduces a new AppHost entry point that provisions a PostgreSQL 14.3 database with PgAdmin and configures the 'fitnet' project to connect to it via specific environment variables for the Passes, Contracts, Reports, and Offers modules. Additionally, launch settings and logging configurations have been added to support the Aspire dashboard and resource service endpoints, streamlining the local development experience.
Chapter-2-modules-separation/Src/Fitnet.AppHost · high confidence
Introduce API layer for contract preparation and signing
The Fitnet.Contracts.Api project now exposes HTTP endpoints for the contract domain, allowing customers to prepare a new contract (POST /contracts) and sign an existing one (PATCH /contracts/{id}). This entry point wires up the necessary infrastructure and registers the Prepare and Sign endpoints, which include request validation rules (e.g., non-empty IDs, positive age/height, non-empty dates) to ensure data integrity before processing.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Api · high confidence
Introduce Contracts module with API endpoints and business rules
The Contracts module is now available as a separate component, exposing two new API endpoints: POST /contracts to prepare a new contract and PATCH /contracts/{id} to sign a prepared one. Request validation is enforced via FluentValidation, ensuring customer age is at least 18, height does not exceed 210 cm, and the previous contract is signed. Business logic enforces that a contract can only be signed within 30 days of preparation, and the module can be enabled or disabled via configuration rather than feature flags.
Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Api · high confidence
Introduce Offer data model with standard pass extension logic
Added the Offer entity in the Offers.Data layer, defining properties for customer association, validity period, and discount. The model includes a factory method, PrepareStandardPassExtension, which creates an offer with a hardcoded 10% discount for a one-year standard pass extension, establishing the foundational data structure for the offer preparation feature.
Chapter-1-initial-architecture/Src/Fitnet/Offers/Data · high confidence
Introduce Offers API module with time-provider-based event handling
The Offers API module is initialized, registering its data access and mediator infrastructure. A new event consumer handles pass expiration by creating offer extensions using an injected TimeProvider instead of direct system clock calls, ensuring deterministic time handling in business logic and integration events.
Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Offers/Fitnet.Offers.Api · high confidence
Introduce Passes API with event-driven pass management
The Passes API module is introduced, providing endpoints to retrieve all passes and mark them as expired. It integrates with MassTransit and RabbitMQ for asynchronous communication, utilizing an Entity Framework outbox pattern to ensure reliable event delivery. The service listens for contract signing events to register new passes and publishes pass registration and expiration events, with time handling delegated to the built-in TimeProvider.
Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.Api · high confidence
Introduce Passes data access module with entity and DI registration
The Passes module now includes a dedicated data access layer containing the \Pass\ entity (with registration and expiration logic) and a \DataAccessModule\ class that registers the database services and middleware via extension methods. This separates the persistence concerns for passes from the rest of the application, providing a clear entry point for configuring database access within the passes domain.
Chapter-2-modules-separation/Src/Passes/Fitnet.Passes.DataAccess · high confidence
Introduce binding contracts with annex support and domain events
The contracts module now models a BindingContract aggregate that can have Annexes attached to it, enforcing business rules such as requiring the contract to be active and the annex to start within the binding period. This change introduces specific domain events (ContractPrepared, BindingContractStarted, AnnexAttachedToBindingContractEvent, BindingContractTerminated) and an integration event (ContractSigned) to expose these lifecycle transitions, while also making the termination date nullable to support the new binding contract lifecycle.
Fitnet.Contracts · high confidence
Introduce centralized infrastructure module for dependency injection and middleware
The Contracts.Infrastructure layer now exposes a unified entry point via InfrastructureModule, which consolidates the registration of database, mediation, and event bus services, as well as the ContractsModule, into a single AddInfrastructure extension method. This simplifies the application startup configuration by allowing consumers to wire up all infrastructure concerns with one call, while UseInfrastructure handles the corresponding middleware pipeline setup.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure · high confidence
Introduce common infrastructure modules for event bus, clock, and mediator
The Fitnet.Common.Infrastructure library now provides a unified entry point, CommonInfrastructureModule, which registers the core infrastructure services. This includes an in-memory event bus implementation (IEventBus) backed by MediatR for publishing integration events, a singleton TimeProvider for clock abstraction, and a centralized Mediator registration method. Additionally, a ModuleAvailabilityChecker is introduced to determine if specific modules are enabled via configuration sections (e.g., Modules:{module}:Enabled), replacing previous feature flag mechanisms.
Chapter-2-modules-separation/Src/Common/Fitnet.Common.Infrastructure · high confidence
Introduce contract preparation endpoint with validation and previous contract handling
The Prepare Contract endpoint now supports creating new contracts for both new and existing customers. For existing customers, the system retrieves their previous contract to pass its signed status to the new contract preparation logic. Input validation is enforced via FluentValidation, ensuring CustomerId, CustomerAge, CustomerHeight, and PreparedAt are provided and meet basic constraints (e.g., age and height must be greater than zero). The endpoint returns a 201 Created status with the new contract ID upon success, or a 409 Conflict if a previous contract exists and is already signed (implied by the domain logic passed to Contract.Prepare), or a 500 Internal Server Error on failure.
Chapter-1-initial-architecture/Src/Fitnet/Contracts/PrepareContract · high confidence
Introduce in-memory event bus infrastructure
The application now includes a foundational in-memory event bus system within the Common/Events module. This change introduces the IIntegrationEvent interface for defining domain events and IIntegrationEventHandler for processing them, leveraging MediatR for notification handling. An IEventBus abstraction and its InMemoryEventBus implementation are provided, along with DI registration modules (EventBusModule and InMemoryEventBusModule) that configure the service collection to use the in-memory transport by default.
Chapter-1-initial-architecture/Src/Fitnet/Common/Events · high confidence
Introduce monthly new passes registration report endpoint
The Reports module now exposes a new GET endpoint at /reports/generate that returns a count of new passes registered per month for the current year. This capability is implemented via a dedicated data retriever using Dapper against the PostgreSQL database, with database connection configuration applied through the Options pattern (Reports:Database section) and dependency injection wired up in the ReportsModule.
Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Reports/Fitnet.Reports · high confidence
Introduce persistent storage for contracts using Entity Framework Core and PostgreSQL
The Contracts module now supports real database persistence instead of in-memory storage. This change introduces an Entity Framework Core setup using Npgsql for PostgreSQL, configured via the Options pattern to read connection strings from the application configuration. It includes the \ContractsPersistence\ DbContext with entity configurations for \Contract\ and \BindingContract\, automatic database migrations applied at startup, and repository registration to enable durable data storage for contract operations.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/Database · high confidence
Introduce reports database access layer with connection factory and options pattern
The Reports module now includes a dedicated data access layer that configures database connectivity via the Options pattern, binding connection strings to ReportsPersistenceOptions with validation on start. It provides an IDatabaseConnectionFactory (implemented by DatabaseConnectionFactory) to manage Npgsql connections, ensuring connections are reused when open and properly disposed to prevent resource leaks.
Chapter-1-initial-architecture/Src/Fitnet/Reports/DataAccess · high confidence
Introduction of a common integration event interface
A new \IIntegrationEvent\ interface has been added to the \Fitnet.Common.Infrastructure\ module. This interface extends MediatR's \INotification\ and defines a standard contract for integration events, requiring a unique identifier (\Id\) and a timestamp (\OccurredDateTime\). This change establishes a foundational type for cross-service communication within the common infrastructure layer.
Fitnet.Common · high confidence
Introduction of a new business rule validation framework
The Fitnet application now includes a dedicated infrastructure for validating business rules within the core library. This change introduces the IBusinessRule interface, allowing domain logic to define validation conditions and associated errors, alongside a BusinessRuleValidator utility that aggregates these checks. A new BusinessRuleError class provides a standardized way to create custom error types with a specific type code (100), enabling consistent error handling when business rules are not met.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/BussinessRules · high confidence
Introduction of core domain modeling abstractions
The Fitnet.Common.Core library now provides foundational building blocks for the domain model, including an abstract Entity base class that manages a collection of domain events, an IDomainEvent interface defining event identity and timestamp, and a ValueObject abstract class implementing structural equality and hash code generation. These additions establish the core infrastructure for implementing domain-driven design patterns within the application.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core · high confidence
Introduction of the Contracts API module with RESTful endpoints
The Fitnet.Contracts.Api project now exposes a dedicated API module for managing contracts and binding contracts. This includes endpoints to prepare, sign, and terminate binding contracts, as well as attach annexes to binding contracts. The API follows RESTful conventions with kebab-case paths (e.g., /contracts, /binding-contracts/{id}/annexes) and returns 201 Created for resource creation operations. The module is registered via standard ASP.NET Core DI and middleware patterns.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Api · high confidence
New API endpoint for monthly pass registration reports
A new API endpoint has been added to retrieve a report of all passes registered in a specific month. This feature introduces a dedicated data retriever that queries the database for pass counts grouped by month and year, exposing the results via a new GET endpoint that returns a structured response containing the month order, name, and total registered passes.
Chapter-2-modules-separation/Src/Reports/Fitnet.Reports/GenerateNewPassesRegistrationsPerMonthReport · high confidence
New API endpoint to attach an annex to a binding contract
The Fitnet Contracts API now exposes a new POST endpoint that allows users to attach an annex to an existing binding contract. This feature includes a request model requiring a 'ValidFrom' date, which is validated to ensure it is not empty, and returns the newly created annex ID in the response location header upon success.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Api/AttachAnnexToBindingContract · high confidence
New API endpoint to mark a pass as expired
A new PATCH endpoint has been added to the Passes API to allow marking a specific pass as expired. When invoked, the endpoint retrieves the pass by ID, updates its status using the current UTC time, persists the change, and publishes a PassExpired integration event via MassTransit to notify other services. The endpoint returns a 204 No Content on success, 404 if the pass is not found, or 500 on internal errors.
Chapter-3-microservice-extraction/Fitnet/Src/Passes/Fitnet.Passes.Api/MarkPassAsExpired · high confidence
New database test container and configuration interface in integration test toolbox
The integration test toolbox now includes a new DatabaseContainer class that manages a PostgreSQL 15.15 test container for integration tests, along with an IDatabaseConfiguration interface to provide database connection settings. This allows integration tests to spin up a consistent database environment automatically during test execution.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine/Database · high confidence
New endpoint to retrieve all passes
A new API endpoint has been added to retrieve all existing passes in the system. This change introduces the GetAllPassesEndpoint which maps to the configured path and returns a collection of PassDto objects (containing Id and CustomerId) via a GetAllPassesResponse. The endpoint uses Entity Framework Core with AsNoTracking for read-only performance and includes OpenAPI documentation for summary, description, and response types.
Chapter-2-modules-separation/Src/Passes/Fitnet.Passes.Api/GetAllPasses · high confidence
New endpoint to retrieve monthly pass registration reports
This change introduces a new API endpoint that allows users to retrieve a report of all passes registered within a specific month. The endpoint is mapped at the route defined by \ReportsApiPaths.GenerateNewReport\ and returns a \NewPassesRegistrationsPerMonthResponse\. It relies on the \INewPassesRegistrationPerMonthReportDataRetriever\ service, which is registered in the \GenerateNewPassesPerMonthReportModule\ along with the \IDatabaseConnectionFactory\. The endpoint includes Swagger documentation summarizing its purpose and indicating it may return a 500 Internal Server Error.
Chapter-1-initial-architecture/Src/Fitnet/Reports/GenerateNewPassesRegistrationsPerMonthReport · high confidence
New endpoint to sign contracts and return the binding contract ID
A new PATCH endpoint has been added to sign a prepared contract. The endpoint accepts a signature and a signed date, validates the input, and upon success returns a 201 Created response containing the ID of the newly created binding contract. It also handles standard error responses for not found, conflict, and internal server errors.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Api/SignContract · high confidence
New infrastructure services for clock, events, and module configuration
The Fitnet.Common.Infrastructure library now provides foundational services including a registered TimeProvider for consistent time handling, MediatR integration for handling integration events via new IIntegrationEvent and IIntegrationEventHandler interfaces, and a configuration-based ModuleAvailabilityChecker that determines if specific modules are enabled via app settings.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Infrastructure · high confidence
New integration test helpers for MassTransit event bus verification
The integration test toolbox now includes specific utilities for verifying event bus behavior in MassTransit-based services. Developers can use the new \EventBusAssertions\ to easily assert that specific events were consumed, and \EventBusExtensions\ to configure a test harness with custom consumers and wait for message consumption with configurable timeouts. This simplifies writing integration tests that depend on asynchronous event processing.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine/EventBus · high confidence
New integration test toolbox with shared global usings
A new integration test toolbox project has been introduced, providing a centralized set of global usings for test utilities. This includes references to xUnit, Microsoft.AspNetCore.Mvc.Testing, Microsoft.AspNetCore.Hosting, Microsoft.Extensions.Configuration, Bogus, JetBrains.Annotations, and System.Reflection, streamlining the setup for integration tests that rely on these common libraries.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox · high confidence
New shared infrastructure components for clock, events, and module configuration
The Fitnet.Common.Infrastructure library now provides reusable infrastructure services, including a clock module that registers the system TimeProvider, MediatR integration via a dedicated module for assembly scanning, and interfaces for integration events and their handlers. Additionally, a module availability checker has been added to allow applications to determine if specific modules are enabled via configuration.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.Infrastructure · high confidence
New test helper extensions for integration test configuration
The integration test toolbox now includes a new \ConfigurationExtensions\ class that provides helper methods for configuring the test environment. This allows tests to easily apply custom database settings, register fake message consumers, and set up the MassTransit test harness within the \WebApplicationFactory\.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine/Configuration · high confidence
Offers module now automatically extends expired passes
The Offers API now includes a new event-driven capability: when a customer's pass expires, the system automatically prepares a standard pass extension. This is implemented via a new \PassExpiredEventConsumer\ that listens for \PassExpiredEvent\ messages, creates the extension offer, persists it, and publishes an \OfferPrepareEvent\. The module registration logic in \OffersModule.cs\ ensures this functionality is only active when the module is enabled, and the new \OfferPrepareEvent\ record captures the details of the prepared offer.
Chapter-3-microservice-extraction/Fitnet/Src/Offers/Fitnet.Offers.Api · high confidence
Pass registration now reacts to contract signing via MassTransit
The Passes API now automatically creates a new pass when a contract is signed. This is implemented by a new ContractSignedEventConsumer that listens for ContractSignedEvent messages via MassTransit, persists the pass, and publishes a PassRegisteredEvent. The consumer is configured with retry and redelivery policies and uses an Entity Framework outbox to ensure reliable event publishing.
Chapter-3-microservice-extraction/Fitnet/Src/Passes/Fitnet.Passes.Api/RegisterPass · high confidence
Passes microservice data access layer and database schema
The Fitnet.Passes.DataAccess module now provides the complete persistence infrastructure for the Passes microservice. It registers the database context and automatic migrations via the DataAccessModule, configuring a PostgreSQL connection through the DatabaseOptions pattern. The schema includes the core Passes table and, crucially, the MassTransit InboxState, OutboxMessage, and OutboxState tables required for reliable distributed messaging. A new migration (20250927) adds foreign key constraints linking the outbox to the inbox and outbox state tables, ensuring referential integrity for the outbox pattern.
Chapter-3-microservice-extraction/Fitnet/Src/Passes/Fitnet.Passes.DataAccess · high confidence
Passes module API registration and endpoint mapping
The Passes microservice now exposes REST endpoints for retrieving all passes and marking a pass as expired. This is implemented via a new module registration pattern that conditionally enables the API based on configuration, wiring up data access, the mediator, and the event bus before mapping the specific route handlers.
Chapter-3-microservice-extraction/Fitnet/Src/Passes/Fitnet.Passes.Api · high confidence
Reports module initialization with configuration-based enablement
The Reports module is now a distinct, self-contained component that can be selectively enabled or disabled via application configuration rather than feature flags. This change introduces the module registration logic (ReportsModule.cs) which checks if the module is enabled before wiring up dependencies and endpoints, defines API path constants (ReportsApiPaths.cs), and maps the initial endpoint for generating new passes registrations per month reports (ReportsEndpoints.cs).
Chapter-2-modules-separation/Src/Reports/Fitnet.Reports · high confidence
Terminate binding contract by ID
Users can now terminate a binding contract using its specific ID. The application introduces a new command and handler that retrieve the contract by ID and apply the termination logic, returning a result that indicates success or failure.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/TerminateBindingContract · high confidence
Test engine configuration extensions for integration testing
The integration test toolbox now provides extension methods to configure the test environment, allowing tests to easily set up database connections via settings, register fake message consumers, and integrate the MassTransit test harness for verifying message handling.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine/Configuration · high confidence
Behavioural changes
AppHost projects moved to dedicated Src/AppHost directories
The Aspire AppHost configuration files for both the Fitnet and Fitnet.Contracts services have been relocated into their respective Src/AppHost folders. This change organizes the hosting infrastructure (Program.cs, launchSettings.json, and appsettings files) closer to the service source code, ensuring that local development environments correctly spin up the required Postgres 14.3 and RabbitMQ dependencies alongside the applications.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/AppHost, Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/AppHost · high confidence
Application layer for contracts extracted with MediatR commands and MassTransit integration
The Fitnet.Contracts.Application project now exposes the core contract workflows via a clean command-based API using MediatR. It defines ICommand interfaces and specific commands like PrepareContractCommand and SignContractCommand, along with their handlers. The SignContractCommandHandler orchestrates the signing logic, persists the contract via IContractsRepository, and publishes a ContractSignedEvent using MassTransit's IPublishEndpoint, replacing the previous EventBus mechanism. This change centralizes the application logic for preparing and signing contracts within this specific module.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Application · high confidence
Application layer interfaces adopt ErrorOr for command results and repository lookups
The Fitnet.Contracts.Application project now defines its core abstractions to support robust error handling. Command interfaces (ICommand) and the module executor (IContractsModule) have been updated to return ErrorOr types, allowing commands to explicitly represent success or failure states rather than throwing exceptions. Additionally, repository interfaces (IContractsRepository and IBindingContractsRepository) have been moved into this project and updated to return ErrorOr\<Contract\> and ErrorOr\<BindingContract\> for retrieval operations, ensuring that missing or invalid data is handled consistently within the application layer.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application · high confidence
Business rules for contract signing now return structured errors
The business rules governing contract signing (specifically the 30-day signing window and the check against already-signed contracts) have been refactored to implement the IBusinessRule interface. Instead of throwing exceptions, these rules now expose a structured Error object via the Error property, allowing the application to handle validation failures through a consistent error-handling mechanism rather than control-flow exceptions.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/SignContract/BusinessRules · high confidence
Centralized module registration and configuration-driven availability
The application now uses a dedicated \ModulesRegistry\ to centrally register and initialize all modules (Contracts, Offers, Passes, Reports) during startup. This change introduces a \Module\ record to strongly type module identifiers and shifts module availability from feature flags to configuration settings, allowing users to enable or disable specific modules via the application's configuration file.
Chapter-2-modules-separation/Src/Fitnet/Modules · high confidence
Chapter 3 solution upgraded to .NET 10 with modernized build and code quality infrastructure
The Fitnet source solution has been upgraded to target .NET 10, as defined in the new Directory.Build.props. This change introduces a standardized build environment featuring a new .editorconfig for consistent code formatting and naming conventions, a centralized nuget.config to manage package sources including a private GitHub feed, and a Qodana configuration for code quality analysis. The solution structure is now managed via the new .slnx format, and the Dockerfile has been updated to use .NET 9 SDK images for the build stage, ensuring the application is built and packaged correctly for the new runtime target.
Chapter-3-microservice-extraction/Fitnet/Src · high confidence
Chapter 4 solution initialized with .NET 10, central package management, and Docker support
The Fitnet.Contracts solution has been initialized for Chapter 4, migrating the target framework to .NET 10 and introducing central package management via Directory.Build.props and a new .slnx solution format. This update includes a Dockerfile and .dockerignore to containerize the application, an .editorconfig to enforce consistent coding standards, and a nuget.config that adds a private GitHub package source for EvolutionaryArchitecture packages.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src · medium confidence
Contract domain model enforces business rules for preparation and signing
The Contract entity in the data layer now encapsulates validation logic for contract lifecycle events. When preparing a contract, it validates that the customer is an adult, meets height limits, and has a signed previous contract (if applicable). When signing, it ensures the action occurs within 30 days of preparation and automatically calculates the expiration date based on the standard one-year duration.
Chapter-1-initial-architecture/Src/Fitnet/Contracts/Data · high confidence
Contract signing endpoint with validation and event publishing
The Sign Contract endpoint now enforces a business rule that a contract can only be signed within 30 days of its preparation date. The endpoint validates the request using FluentValidation to ensure the signed date is provided, and upon successful signing, it publishes a ContractSignedEvent to the event bus.
Chapter-1-initial-architecture/Src/Fitnet/Contracts/SignContract · high confidence
Contract signing now returns the binding contract ID
The SignContract command handler has been updated to return the identifier of the newly created binding contract upon successful signature, rather than a generic success result. This change allows clients to immediately identify the specific binding contract associated with the signed agreement, facilitating subsequent interactions with that binding.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/SignContract · high confidence
Contracts table schema expanded with customer, timing, and expiration fields
The database schema for the Contracts table has been updated to support a more complete contract lifecycle. The table now includes a CustomerId to link contracts to specific customers, and SignedAt and PreparedAt timestamps to track when a contract was created and executed. Additionally, SignedAt is now optional to accommodate unsigned drafts, and new Duration and ExpiringAt columns have been added to define the contract's length and expiration date.
Chapter-1-initial-architecture/Src/Fitnet/Contracts/Data/Database/Migrations · high confidence
Database schema evolution for contracts, binding contracts, and annexes
The database schema for the Contracts domain has been updated to support a more complex contract lifecycle. The initial Contracts table now includes CustomerId, Duration, ExpiringAt, and a Signature value object (renamed from SignedAt to include a signature value). A new BindingContracts table has been added to track active contracts with fields like BindingFrom, ExpiringAt, and a nullable TerminatedAt. Additionally, an Annexes table has been introduced to store attached annexes as part of the binding contract aggregate, allowing for multiple annexes per binding contract.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/Database/Migrations · high confidence
Enforce annex attachment constraints via dedicated business rules
The system now validates that an annex can only be attached to a binding contract that is currently active (not terminated and not expired) and that the annex's validity period falls within the existing binding contract's duration. These constraints are enforced by new business rules, ensuring that invalid annex attachments are rejected with specific error messages before they are processed.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/AttachAnnexToBindingContract · high confidence
Enforce business rules for contract preparation
The contract preparation process now validates specific customer criteria before a contract can be created. New business rules ensure that customers are at least 18 years old, do not exceed the maximum height limit of 210 cm for gym instruments, and have a signed previous contract (if one exists). These validations replace previous exception-based handling with structured business errors.
Chapter-1-initial-architecture/Src/Fitnet/Contracts/PrepareContract/BusinessRules, Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/PrepareContract · high confidence
Fitnet.Common extracted to standalone solution targeting .NET 10
The Fitnet.Common module has been extracted into its own solution (Fitnet.Common.slnx), separating it from the main project structure. This new solution targets .NET 10.0 and includes a centralized Directory.Build.props file that enforces strict code analysis, nullable reference types, implicit usings, and documentation generation. The solution comprises the core library, API layer, infrastructure, and associated unit and integration test projects.
Chapter-3-microservice-extraction/Fitnet.Common · high confidence
Fitnet.Contracts project upgraded to .NET 10 with new build infrastructure
The Fitnet.Contracts service has been upgraded to target .NET 10 (net10.0), as defined in the new Directory.Build.props. This change introduces a standardized build environment via a new .editorconfig for consistent code formatting and style analysis, alongside a .dockerignore file to optimize container builds. The project now uses the new .slnx solution format and includes a nuget.config that maps packages prefixed with 'EvolutionaryArchitecture.\*' to a private GitHub NuGet feed, while the Dockerfile currently references .NET 9.0 SDK/base images.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src · high confidence
Initialize Chapter 2 application structure with module-based configuration
The Fitnet application entry point is established with a new Program.cs that configures the web host, registers common infrastructure, and dynamically loads modules. The app now uses a structured 'Modules' configuration section in appsettings.json to enable or disable specific modules (Passes, Contracts, Reports, Offers) and define their database connection strings, replacing previous hardcoded or feature-flag approaches. Additionally, the API documentation UI is swapped to Scalar for the development environment.
Chapter-2-modules-separation/Src/Fitnet · high confidence
Integration tests now load a dedicated settings file
The integration test engine has been updated to explicitly load configuration from an 'appsettings.IntegrationTests.json' file during test execution. This ensures that integration tests use the correct, isolated settings rather than relying on default or development configurations, improving test reliability and isolation.
Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox/TestEngine · high confidence
Introduce .NET 8 global exception handling with ProblemDetails
The application now uses .NET 8's built-in exception handling middleware to standardize error responses. A new global exception handler intercepts errors, logging them and returning structured ProblemDetails JSON responses; specifically, business rule validation failures now return a 409 Conflict status, while other unhandled exceptions return a 500 Internal Server Error.
Chapter-1-initial-architecture/Src/Fitnet/Common/ErrorHandling · high confidence
Introduce Contracts infrastructure module with ErrorOr command results
The Contracts infrastructure layer now includes a new ContractsModule that executes commands via MediatR, returning ErrorOr results to better handle success and failure states. This module is registered in the InfrastructureModule's service collection and activation pipeline, providing a centralized entry point for contract-related command execution within the application.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure · high confidence
Introduce Offers persistence layer with required field validation
The Offers module now includes its own database persistence setup, registering the \OffersPersistence\ DbContext via the Options pattern to read the connection string from configuration. This setup automatically applies EF Core migrations on startup. Additionally, the database schema for the \Offer\ entity is strictly defined, marking the \CustomerId\, \Discount\, \PreparedAt\, and \OfferedFromDate\/\OfferedFromTo\ properties as required, ensuring data integrity at the database level.
Chapter-1-initial-architecture/Src/Fitnet/Offers/Data/Database · high confidence
Introduce Options pattern for database configuration
The Offers data-access layer now configures the database connection string using the .NET Options pattern (via \DatabaseOptions\ and \IOptions\<DatabaseOptions\>\) instead of accessing configuration directly. This change improves testability and decouples the \OffersPersistence\ setup from the raw configuration source, while retaining automatic EF Core migrations on startup.
Chapter-3-microservice-extraction/Fitnet/Src/Offers/Fitnet.Offers.DataAccess · high confidence
Introduce Options pattern for database configuration and automatic migrations
The Passes data module now configures the PostgreSQL connection string via the Options pattern (PassesPersistenceOptions) rather than reading it directly, and automatically ensures the database schema is created on startup through a new UseAutomaticMigrations extension. This change also establishes the initial EF Core migration for the Passes table within the Passes schema and updates the DbContext to use primary constructors.
Chapter-1-initial-architecture/Src/Fitnet/Passes/Data · high confidence
Introduce Prepare Contract command with error-handling result type
The Prepare Contract application feature now uses a command handler that returns an ErrorOr result instead of throwing exceptions, allowing callers to handle validation or business errors explicitly. The handler retrieves any previous contract for the customer and passes its signed status to the domain logic, then persists the new contract and returns the generated contract ID.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/PrepareContract · high confidence
Introduce configuration-driven database persistence for the Offers module
The Offers module now uses a dedicated data access layer that configures Entity Framework Core with Npgsql against a PostgreSQL database. Database connectivity is controlled via the 'Modules:Offers:ConnectionStrings' configuration section (using the Options pattern) rather than feature flags, allowing the module to be enabled or disabled through configuration. The setup includes automatic database migrations on startup and defines the 'Offers' schema with an 'Offers' table containing Id, CustomerId, PreparedAt, Discount, OfferedFromDate, and OfferedFromTo fields.
Chapter-2-modules-separation/Src/Offers/Fitnet.Offers.DataAccess · high confidence
Introduce contract lifecycle with strong typing and business rule validation
The Contract entity now enforces a structured lifecycle: preparation is validated against business rules (age, height, previous contract status) using the ErrorOr pattern, and signing transforms the contract into a BindingContract while validating signature format and timing. The Signature is implemented as a value object with strict character validation, and termination rules ensure contracts cannot be terminated until three months have passed.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core · high confidence
Introduce dedicated data access layers with automatic migrations for Offers and Passes
The Offers and Passes modules now include their own data access infrastructure, registering separate Entity Framework Core DbContexts (OffersPersistence and PassesPersistence) that connect to PostgreSQL via the Options pattern. Each module applies its own database schema (Offers and Passes) and runs automatic migrations on startup to ensure the database is up to date. The Passes data access layer also integrates MassTransit inbox/outbox tables to support reliable message handling, while the Offers layer provides a basic migration for the Offers table.
Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Offers/Fitnet.Offers.DataAccess, Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.DataAccess · high confidence
Introduces dedicated EventBus configuration and MassTransit setup for the Contracts infrastructure
The Contracts infrastructure now includes its own EventBusModule and EventBusOptions to configure MassTransit with RabbitMQ. This change allows the service to bind to specific connection details (URI, username, password) via the 'EventBus' configuration section, enabling independent orchestration of the event bus rather than relying on a shared common infrastructure setup.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/EventBus · high confidence
Module registration now respects configuration-based enablement
The Offers module's registration logic has been updated to check a configuration setting (via \IsModuleEnabled\) before initializing services and middleware. This allows the module to be enabled or disabled dynamically through configuration rather than relying on static feature flags, giving operators more control over which modules are active at runtime.
Chapter-2-modules-separation/Src/Offers/Fitnet.Offers.Api · high confidence
Pass expiration and registration endpoints now use TimeProvider for deterministic timestamps
The MarkPassAsExpired endpoint and the ContractSignedEventHandler have been updated to inject and use TimeProvider instead of relying on static system clock calls. This ensures that the current UTC time used to mark a pass as expired and to timestamp integration events is explicitly provided, improving testability and consistency in how pass lifecycle events are recorded.
Chapter-2-modules-separation/Src/Passes/Fitnet.Passes.Api/MarkPassAsExpired · high confidence
Passes module database access configured via options pattern with automatic migrations
The Passes module now uses the .NET Options pattern to read its database connection string from the configuration section Modules:Passes:ConnectionStrings:Primary, replacing previous mechanisms. The database context (PassesPersistence) is registered to use Npgsql with this connection string, and the application pipeline now automatically applies Entity Framework Core migrations at startup via the UseAutomaticMigrations extension, ensuring the schema is up-to-date without manual intervention.
Chapter-2-modules-separation/Src/Passes/Fitnet.Passes.DataAccess/Database · high confidence
Passes module registration now uses configuration-based enablement
The Passes module in the API layer now checks a configuration setting to determine whether it should be registered, replacing the previous feature-flag approach. The new PassesModule extension methods (RegisterPasses, AddPasses) and supporting files (PassesApiPaths, PassesEndpoints) gate the module's HTTP endpoints and service registration behind this configuration check, allowing the module to be enabled or disabled dynamically via configuration rather than compile-time or hardcoded feature flags.
Chapter-2-modules-separation/Src/Passes/Fitnet.Passes.Api · high confidence
Reports module adopts configuration-based options pattern for database connections
The Reports module's data access layer has been restructured to use the .NET Options pattern for managing database connectivity. Instead of hard-coded or feature-flag-driven logic, the module now reads connection string settings from the configuration section 'Modules:Reports:ConnectionStrings' via the new ReportsPersistenceOptions class. This change introduces a dedicated DatabaseAccessModule for dependency registration, an IDatabaseConnectionFactory interface, and a concrete DatabaseConnectionFactory that validates and retrieves the primary connection string, ensuring that the reports feature is enabled and configured via standard application configuration rather than internal feature flags.
Chapter-2-modules-separation/Src/Reports/Fitnet.Reports/DataAccess · high confidence
Reports module now supports runtime enable/disable via configuration
The Reports service now respects a module availability setting, allowing the feature to be toggled on or off at runtime. The new \ReportsModule\ registration logic checks a configuration flag before adding dependencies or mapping endpoints, meaning the report generation capability is no longer always active but can be controlled via the application's configuration.
Chapter-3-microservice-extraction/Fitnet/Src/Reports/Fitnet.Reports · high confidence
Reports service adopts Options pattern and Npgsql for database access
The Reports service now configures database settings using the .NET Options pattern via a new DatabaseOptions class and a dedicated DatabaseAccessModule for dependency injection. The underlying database driver has been switched to Npgsql, with a new DatabaseConnectionFactory managing NpgsqlConnection instances to replace the previous generic IDbConnection approach.
Chapter-3-microservice-extraction/Fitnet/Src/Reports/Fitnet.Reports/DataAccess · high confidence
Request validation now uses FluentValidation with automatic assembly scanning
The validation layer has been refactored to use the FluentValidation library instead of a custom implementation. This change introduces an \IEndpointFilter\ that intercepts incoming requests, resolves the appropriate validator via dependency injection, and returns a 400 Bad Request with validation errors if the input is invalid. Validators are now automatically registered by scanning the assembly containing the \Program\ class, simplifying the setup process for developers.
Chapter-1-initial-architecture/Src/Fitnet/Common/Validation · high confidence
Separate .NET Aspire orchestration for Fitnet and Fitnet.Contracts
The Fitnet and Fitnet.Contracts applications now each have their own dedicated .NET Aspire AppHost project, replacing any previous shared or implicit orchestration. The Fitnet.AppHost orchestrates the Fitnet modular monolith with a PostgreSQL 14.3 database (including PgAdmin), while the Fitnet.Contracts.AppHost orchestrates the Fitnet.Contracts microservice with the same PostgreSQL instance and an additional RabbitMQ broker (with management plugin). Both AppHosts configure development environment settings, establish connection references for the database and event bus, and enforce startup dependencies (WaitFor) to ensure infrastructure readiness before the services start.
Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.AppHost, Chapter-3-microservice-extraction/Fitnet/Src/Fitnet.AppHost · high confidence
Standardized API error handling, request validation, and business rule enforcement
The Common.Api module now provides a unified approach to API reliability. It introduces a global exception handler that converts specific exceptions (such as business rule violations and resource not found errors) into standardized ProblemDetails responses. Additionally, it adds a FluentValidation-based endpoint filter for automatic request validation and a business rule validator infrastructure in the Common.Core module, allowing modules to enforce domain constraints consistently.
Chapter-2-modules-separation/Src/Common/Fitnet.Common.Api · high confidence
Standardized HTTP error response mapping for business rules
The API now uses a centralized helper to convert domain errors into standardized HTTP ProblemDetails responses. This change ensures that business rule violations are consistently returned as 409 Conflict responses, while other error types (validation, not found, unauthorized, etc.) map to their appropriate HTTP status codes. Users will see more consistent and predictable error responses when interacting with the API.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Api/Common · high confidence
Standardized integration event contracts and migrated event definitions to modular structure
The Fitnet module now enforces a consistent contract for integration events via the new \IIntegrationEvent\ interface (inheriting from MediatR's \INotification\) which requires a unique identifier and an occurrence timestamp. Specific domain events—\ContractSignedEvent\, \OfferPrepareEvent\, \PassExpiredEvent\, and \PassRegisteredEvent\—have been formalized as records implementing this interface. Additionally, the codebase has been reorganized into a modular structure (Chapter 2), where event definitions previously located in the monolithic \Fitnet\ project have been moved to dedicated API and integration event assemblies (e.g., \Fitnet.Offers.Api\, \Fitnet.Passes.Api\, \Fitnet.Passes.IntegrationEvents\), ensuring that each module owns its specific event contracts while sharing the common event infrastructure.
Fitnet · high confidence
Upgrade to .NET 10 and adopt .slnx solution format
The Chapter 2 source code has been upgraded to target .NET 10.0, as defined in the new Directory.Build.props file. The solution structure has migrated from the traditional .sln format to the new .slnx format (Fitnet.slnx), which organizes projects into folders for Common, Contracts, Offers, Passes, and Reports. Additionally, a new .editorconfig file has been introduced to enforce consistent coding conventions, including specific indentation, using directive placement, and naming rules across all C\# and XML files in the solution.
Chapter-2-modules-separation/Src · high confidence
Upgrade to .NET 10 and adopt Aspire for local development
The project has been upgraded to target .NET 10.0, with build properties centralized in Directory.Build.props to enforce strict code analysis and nullable reference types. Local development orchestration has shifted from Docker Compose to .NET Aspire, introducing a new Fitnet.AppHost project that manages the application and its PostgreSQL dependency via the Aspire DistributedApplication API. Additionally, the solution structure has been modernized by migrating to the new .slnx format and applying a comprehensive set of C\# coding conventions and naming rules via a new .editorconfig file.
Chapter-1-initial-architecture/Src · high confidence
Use TimeProvider for date-time handling in pass expiration logic
The PassExpiredEventHandler now relies on the injected TimeProvider to retrieve the current UTC time instead of making direct static calls. This change ensures that date-time operations are consistent and testable within the offer preparation flow triggered by a pass expiration event.
Chapter-2-modules-separation/Src/Offers/Fitnet.Offers.Api/Prepare · high confidence
Test coverage
Added architecture contract tests for module dependencies; Added architecture convention tests for interface naming and endpoint staticness; Added architecture test infrastructure for module dependency checking; Added custom FluentAssertions for ErrorOr types; Added custom Shouldly assertions for ErrorOr types; Added fake time provider for integration tests; Added global using directives for integration test dependencies; Added integration test helper for consuming events; Added integration test infrastructure and configuration; Added integration test infrastructure for PostgreSQL container management; Added integration test infrastructure for database, time, and event handling; Added integration tests for contract preparation; Added integration tests for contract preparation and signing workflows; Added integration tests for marking a pass as expired; Added integration tests for offer preparation triggered by expired passes; Added integration tests for pass registration via contract signed event; Added integration tests for the Attach Annex endpoint; Added integration tests for the Contracts module; Added integration tests for the Generate New Passes Per Month report; Added integration tests for the GenerateNewPassesPerMonthReport; Added integration tests for the GenerateNewPassesPerMonthReport; Added integration tests for the Mark Pass as Expired feature; Added integration tests for the Offers module; Added integration tests for the Register Pass feature; Added integration tests for the RegisterPass feature; Added integration tests for the binding contract termination endpoint; Added integration tests for the contract preparation endpoint; Added integration tests for the contract signing endpoint; Added integration tests for the contract signing workflow; Added integration tests for the in-memory event bus; Added integration tests for the in-memory event bus; Added integration tests for the new passes per month report; Added test builders for contract preparation and signing; Added test data for monthly pass registration reports; Added test helper utilities for contract domain testing; Added test infrastructure for configuring database connections and mocking event buses; Added unit test infrastructure for Fitnet.Contracts.Core and Api; Added unit tests for ExceptionMiddleware and configured Shouldly assertions; Added unit tests for Fitnet.Contracts.Core business rules; Added unit tests for SignContractRequestValidator; Added unit tests for ValueObject equality and hashing behavior; Added unit tests for annex attachment business rules; Added unit tests for binding contract termination; Added unit tests for contract business rules and request validation; Added unit tests for contract preparation business rules; Added unit tests for contract preparation logic; Added unit tests for contract request validators; Added unit tests for contract signing business rules; Added unit tests for contract signing date logic; Added unit tests for contract signing date validation; Added unit tests for contract signing validation and signature value object; Added unit tests for the Business Rules Engine; Added unit tests for the Business Rules Engine validation logic; Added unit tests for the Business Rules Engine validator; Added unit tests for the ExceptionMiddleware; Added unit tests for the GlobalExceptionHandler; Added unit tests for the contract signing flow; Added unit tests for the three-month binding contract termination rule; Initialize integration test infrastructure for the Contracts module; Integration test infrastructure for Reports module; New test helpers for verifying MassTransit event consumption.
Dependencies
Adopts .NET 10 and Aspire 13 with centralized package management
The solution has been upgraded to .NET 10 and Aspire 13, introducing .NET Aspire orchestration for application hosting and service coordination. To manage this across the evolving architecture, central package management has been implemented via Directory.Packages.props, allowing individual projects to reference packages without specifying versions. This update also modernizes the testing stack by migrating from FluentAssertions to Shouldly and upgrading the test framework to xUnit v3.
(dependencies) · high confidence
Migrate to .NET 10 and introduce central package management
The Fitnet.Common solution has been upgraded to target .NET 10.0, as defined in the new Directory.Build.props file. This change introduces central package management by setting a global version of 4.2.0 for all projects within the solution. Additionally, the solution now includes a new .editorconfig file that enforces specific C\# coding conventions, formatting rules, and naming styles, alongside a .dockerignore file to optimize Docker builds.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common · high confidence
Housekeeping
Add global usings for integration test infrastructure
The integration test toolbox now includes a GlobalUsings file that automatically imports common namespaces for reflection, JetBrains annotations, ASP.NET Core MVC testing, hosting, and configuration, reducing the need for explicit using statements in test files.
Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.IntegrationTestsToolbox · 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 47 → 48 (+0.9)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 82 → 82 (+0.0)
- Architecture 64 → 64 (+0.0)
- Maturity 66 → 69 (+3.2)
- Readiness 49 → 49 (+0.0)
- Security 34 → 34 (+0.0)
- Event-Driven 77 → 100 (+22.7)
- Performance 70 → 77 (+6.8)
Resolved (62)
- Change coupling: Contract.cs ↔ TerminationIsPossibleOnlyAfterThreeMonthsHavePassedRule.cs (Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/Contract.cs)
- Checkable ADR rule enforced only by prose: 0003-use-modules (Chapter-1-initial-architecture/Docs/ArchitectureDecisionLog/0003-use-modules.adoc)
- Decision is generic ('We decided to use Docker') with no context (why not a different container platform) or trade-offs beyond the listed consequences (Chapter-1-initial-architecture/Docs/ArchitectureDecisionLog/0006-use-docker.adoc)
- Duplicate command definitions. The PrepareContractCommand appears twice with identical signatures in the provided list (likely from different namespaces or versions in the dump). While not a runtime conflict, it pollutes the API surface.
- Duplicate domain method signatures with different parameters. One takes raw DateTimeOffset values, the other takes a Signature value object. This suggests the domain model has evolved or has two different ways to sign a contract.
- Duplicate interface definitions with conflicting return types for the same method signature. One version of IContractsModule returns Task (void-like), while the other returns Task<ErrorOr<Unit>>. This indicates two different versions of the interface or a copy-paste error in the API surface.
- Duplicate registration methods with inconsistent signatures. One takes a 'module' string parameter, the other does not. It is unclear if these are for different layers (API vs Internal) or if one is legacy.
- Duplicate service registration methods. AddContracts includes a module string parameter which is absent in AddContractsApi. This suggests confusion between registering the core application logic versus just the API endpoints.
- Inconsistent return types for equivalent operations. IContractsRepository.GetByIdAsync returns Task<Contract?> (nullable reference), while IBindingContractsRepository.GetByIdAsync returns Task<ErrorOr<BindingContract>> (Result pattern). This forces consumers to handle null checks in one case and error unwrapping in the other.
- No context/problem and no consequences for not recording decisions (e.g. lost change drift or lack of audit trail) are mentioned (Chapter-1-initial-architecture/Docs/ArchitectureDecisionLog/0001-record-architecture-decisions.adoc)
- The namespace for the IBusinessRule interface is spelled 'BussinessRules' (missing 'i') in one location and 'BusinessRulesEngine' in another. While the interface name is consistent, the namespace spelling inconsistency suggests a copy-paste error or lack of standardization in the namespace structure for business rules.
- XML-doc coverage: Fitnet (Chapter-1-initial-architecture/Src/Fitnet/Fitnet.csproj)
- XML-doc coverage: Fitnet (Chapter-2-modules-separation/Src/Fitnet/Fitnet.csproj)
- XML-doc coverage: Fitnet (Chapter-3-microservice-extraction/Fitnet/Src/Fitnet/Fitnet.csproj)
- XML-doc coverage: Fitnet (Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Fitnet/Fitnet.csproj)
- XML-doc coverage: Fitnet.Common.Api (Chapter-2-modules-separation/Src/Common/Fitnet.Common.Api/Fitnet.Common.Api.csproj)
- XML-doc coverage: Fitnet.Common.Api (Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.Api/Fitnet.Common.Api.csproj)
- XML-doc coverage: Fitnet.Common.Api (Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Api/Fitnet.Common.Api.csproj)
- XML-doc coverage: Fitnet.Common.Core (Chapter-2-modules-separation/Src/Common/Fitnet.Common.Core/Fitnet.Common.Core.csproj)
- XML-doc coverage: Fitnet.Common.Core (Chapter-3-microservice-extraction/Fitnet.Common/Fitnet.Common.Core/Fitnet.Common.Core.csproj)
- …and 42 more
API surface
- Unchanged — 1 HTTP endpoints
Architecture
- Unchanged — 9 containers · 3 contexts · 3 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
evolutionary-architecture/evolutionary-architecture-by-example 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 8 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 441a7cd94d3acfbac7d210a95ea8e78429fc9f47 — 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.