# bobx5/2024_.net_conf_cleanarchitecture architecture

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

- Interactive diagram: https://gitdiagram.com/bobx5/2024_.net_conf_cleanarchitecture
- Repository: https://github.com/bobx5/2024_.net_conf_cleanarchitecture

## Overview

##### Project Type Analysis
This is a .NET-based application that demonstrates the migration from a traditional architecture to Clean Architecture. The project is specifically a Library Management System with clear domain boundaries.

##### Main Architectural Components

A. Layered Structure (Outside-In):
- Presentation Layer (05. Presentation)
- Infrastructure Layer (04. Infrastructure)
- Application Layer (03. Application)
- Domain Layer (02. Domain)
- Shared Layer (01. Shared)

B. Core Components:
1. Domain Aggregates:
- Books
- Users
- Rents

2. Infrastructure Services:
- DateTimeProvider
- EmailService
- Persistence Layer with Caching
- Outbox Pattern Implementation

**Outer Layer (Presentation):**
- API Controllers (Books, Rents, Users)
- Middleware Components

**Infrastructure Layer:**
- Persistence (Database)
- Email Service
- DateTime Provider
- Cached Repositories

**Application Layer:**
- Use Cases (Commands/Queries)
- Behaviors
- Interfaces

**Domain Layer (Core):**
- Aggregates (Books, Users, Rents)
- Domain Events
- Value Objects
- Entities

##### Key Elements to Highlight

a. Dependencies:
- How outer layers depend on inner layers
- How infrastructure implements interfaces defined in application layer

b. Cross-Cutting Concerns:
- How logging and validation behaviors are implemented
- Outbox pattern for event handling
- Caching mechanism in repositories

c. Data Flow:
- API endpoints → Use Cases → Domain Logic
- Domain Events → Event Handlers → Infrastructure Services

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Presentation
        API[API Controllers]:::presentation
        MW[Middleware]:::presentation
    end

    subgraph Infrastructure
        PS[Persistence Service]:::infrastructure
        ES[Email Service]:::infrastructure
        DTP[DateTime Provider]:::infrastructure
        CR[Cached Repositories]:::infrastructure
        OP[Outbox Pattern]:::infrastructure
    end

    subgraph Application
        UC[Use Cases]:::application
        BH[Behaviors]:::application
        CQ[Commands/Queries]:::application
    end

    subgraph Domain
        BA[Books Aggregate]:::domain
        UA[Users Aggregate]:::domain
        RA[Rents Aggregate]:::domain
        DE[Domain Events]:::domain
    end

    subgraph Shared
        SH[Shared Components]:::shared
    end

    %% Relationships
    API --> UC
    API --> CQ
    MW --> UC

    UC --> BA
    UC --> UA
    UC --> RA
    UC --> DE

    BH --> UC
    CQ --> UC

    PS --> BA
    PS --> UA
    PS --> RA
    PS --> OP

    CR --> PS
    ES --> DE
    DTP --> UC

    %% Click Events
    click API "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/05. Presentation/LibrarySolution.Controller.Api/"
    click MW "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/05. Presentation/LibrarySolution.Controller.Api/Middlewares/"
    click PS "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/04. Infrastructure/LibrarySolution.Infrastructure.Persistence/"
    click ES "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/04. Infrastructure/LibrarySolution.Infrastructure.EmailService/"
    click DTP "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/04. Infrastructure/LibrarySolution.Infrastructure.DateTimeProvider/"
    click CR "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/04. Infrastructure/LibrarySolution.Infrastructure.Persistence/CachedRepositories/"
    click OP "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/04. Infrastructure/LibrarySolution.Infrastructure.Persistence/Outbox/"
    click UC "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/03. Application/LibrarySolution.Application/UseCases/"
    click BH "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/03. Application/LibrarySolution.Application/Behaviors/"
    click CQ "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/03. Application/LibrarySolution.Application/Abstractions/"
    click BA "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/02. Domain/LibrarySolution.Domain/Aggregates/Books/"
    click UA "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/02. Domain/LibrarySolution.Domain/Aggregates/Users/"
    click RA "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/02. Domain/LibrarySolution.Domain/Aggregates/Rents/"
    click DE "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/blob/master/03. LibrarySolution/02. Domain/LibrarySolution.Domain/Primitives/DomainEvent.cs"
    click SH "https://github.com/BOBx5/2024_.NET_Conf_CleanArchitecture/tree/master/03. LibrarySolution/01. Shared/LibrarySolution.Shared/"

    %% Styles
    classDef presentation fill:#FF9999
    classDef infrastructure fill:#99FF99
    classDef application fill:#9999FF
    classDef domain fill:#FFFF99
    classDef shared fill:#FF99FF

    %% Legend
    subgraph Legend
        L1[Presentation Layer]:::presentation
        L2[Infrastructure Layer]:::infrastructure
        L3[Application Layer]:::application
        L4[Domain Layer]:::domain
        L5[Shared Layer]:::shared
    end
```
