# bhaktarout038/evolutionary-architecture-by-example architecture

> Architecture diagram of the GitHub repository bhaktarout038/evolutionary-architecture-by-example, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhaktarout038/evolutionary-architecture-by-example
- Repository: https://github.com/bhaktarout038/evolutionary-architecture-by-example

## Overview

##### Major System Layers and Components
- Separate the system into logical components (or modules) such as:
– Contracts Module (designed as a rich Domain Model)
– Passes Module (designed as an Active Record, with mostly CRUD style logic)
– Offers Module (with minimal business logic; candidate for Active Record)
– Reports Module (implemented as a Transaction Script)
- In addition, you need to show the infrastructure pieces such as the in-memory event bus (in earlier chapters) and the external messaging (e.g. RabbitMQ) that emerges in the microservices extraction phase (Chapter 3).

##### Evolutionary Chapters
– Chapter 2: Modules Separation – show multiple projects (e.g. Fitnet.Contracts.Api, Fitnet.Contracts.Core, Fitnet.Passes.Api, Fitnet.Reports) with the modules now isolated in distinct deployable units (or code bases). Emphasize maintainability through separation of concerns.
– Chapter 4: Tactical Domain-Driven Design – zoom in on a complex module (for example, Contracts) and display its internal DDD layers. Show aggregates, entities, value objects, and domain events. Emphasize that while the system remains evolutionarily built, this domain is now modeled using tactical DDD.

##### Architectural Patterns and Technologies
– “Active Record” next to Passes and Offers modules (indicating CRUD centric design)
– “Domain Model” inside the Contracts module (alongside tactical DDD elements)
– “Transaction Script” near the Reports module
- Technology references where it makes sense:
– .NET 8, Docker, Fluent Validation, MediatR, EF Core and Dapper for instance.
- Optionally, mention that the solutions use static code analysis and integration tests (e.g. Tools like SonarAnalyzer) to enforce design quality.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Chapter 1: Modular Monolith
    subgraph "Chapter 1: Modular Monolith"
        C1["Contracts (Domain Model)"]:::module
        P1["Passes (Active Record)"]:::module
        O1["Offers (Active Record?)"]:::module
        R1["Reports (Transaction Script)"]:::module
        EV1["In‑Memory Event Bus"]:::infra
    end

    %% Arrows for Chapter 1 communication (publishing to event bus)
    C1 -->|"publishes"| EV1
    P1 -->|"publishes"| EV1
    O1 -->|"publishes"| EV1
    R1 -->|"publishes"| EV1
    EV1 -->|"notifies"| C1
    EV1 -->|"notifies"| P1
    EV1 -->|"notifies"| O1
    EV1 -->|"notifies"| R1

    %% Evolution arrow from Chapter 1 to Chapter 2
    EV1 ---|"evolution"| C2_API

    %% Chapter 2: Modules Separation
    subgraph "Chapter 2: Modules Separation"
        C2_API["Contracts API"]:::module
        C2_Core["Contracts Core"]:::module
        P2_API["Passes API"]:::module
        O2["Offers Service"]:::module
        R2["Reports Service"]:::module
        EV2["In‑Memory Event Bus"]:::infra
    end

    %% Arrows for Chapter 2 communication
    C2_API -->|"calls"| EV2
    C2_Core -->|"calls"| EV2
    P2_API -->|"calls"| EV2
    O2 -->|"calls"| EV2
    R2 -->|"calls"| EV2
    EV2 -->|"notifies"| C2_API

    %% Evolution arrow from Chapter 2 to Chapter 3
    EV2 ---|"evolution"| CM

    %% Chapter 3: Microservice Extraction
    subgraph "Chapter 3: Microservice Extraction"
        CM["Contracts Microservice"]:::module
        PM["Passes Microservice"]:::module
        OM["Offers Microservice"]:::module
        RM["Reports Microservice"]:::module
        MQ["RabbitMQ / Out-of‑process Bus"]:::infra
    end

    %% Arrows representing messaging via external bus
    CM -->|"sends"| MQ
    PM -->|"sends"| MQ
    OM -->|"sends"| MQ
    RM -->|"sends"| MQ
    MQ -->|"delivers"| CM
    MQ -->|"delivers"| PM
    MQ -->|"delivers"| OM
    MQ -->|"delivers"| RM

    %% Domain events between microservices
    CM -->|"ContractSigned"| PM
    CM -->|"ContractSigned"| OM
    PM -->|"PassExpired"| OM

    %% Evolution arrow from Chapter 3 to Chapter 4 (detailed DDD view)
    CM ---|"detailed domain model"| Agg

    %% Chapter 4: Tactical DDD (Contracts Details)
    subgraph "Chapter 4: Tactical DDD (Contracts Details)"
        Agg["Aggregates"]:::ddd
        Ent["Entities"]:::ddd
        VO["Value Objects"]:::ddd
        DE["Domain Events"]:::ddd
    end

    %% Internal DDD relationships
    Agg -->|"comprises"| Ent
    Agg -->|"comprises"| VO
    Agg -->|"emits"| DE

    %% CLICK EVENTS
    click C1 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑1‑initial‑architecture/Src/Fitnet/Contracts"
    click P1 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑1‑initial‑architecture/Src/Fitnet/Passes"
    click O1 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑1‑initial‑architecture/Src/Fitnet/Offers"
    click R1 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑1‑initial‑architecture/Src/Fitnet/Reports"
    click EV1 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑1‑initial‑architecture/Src/Fitnet/Common/Events/EventBus/InMemory"

    click C2_API "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑2‑modules‑separation/Src/Contracts"
    click C2_Core "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑2‑modules‑separation/Src/Contracts"
    click P2_API "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑2‑modules‑separation/Src/Passes"
    click O2 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑2‑modules‑separation/Src/Offers"
    click R2 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑2‑modules‑separation/Src/Reports"
    click EV2 "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑1‑initial‑architecture/Src/Fitnet/Common/Events/EventBus/InMemory"

    click CM "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑3‑microservice‑extraction/Fitnet.Contracts/"
    click PM "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑3‑microservice‑extraction/Fitnet.Passes.Api/"
    click OM "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑3‑microservice‑extraction/Src/Offers"
    click RM "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑3‑microservice‑extraction/Src/Reports"
    click MQ "https://github.com/bhaktarout038/evolutionary-architecture-by-example/tree/main/Chapter‑3‑microservice‑extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/EventBus"

    %% Styles
    classDef module fill:#a3d5d3,stroke:#2b7a78,stroke-width:2px;
    classDef infra fill:#ffb3b3,stroke:#c70039,stroke-width:2px;
    classDef ddd fill:#ffd700,stroke:#d4ac0d,stroke-width:2px;
```
