# yendisgomes/cashflow architecture

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

- Interactive diagram: https://gitdiagram.com/yendisgomes/cashflow
- Repository: https://github.com/yendisgomes/cashflow

## Overview

##### Main Components

a. API Layer (Presentation)
- API Controllers (ExpensesController and ReportController)
- Middleware (CultureMiddleware) and Filters (ExceptionFilter)
- Swagger documentation integration

b. Application Layer
- Use Cases organized by feature (Expenses)
- AutoMapper configuration
- Report Generation components (PDF and Excel)

c. Domain Layer
- Core Expense entity
- Repository interfaces
- Domain enums and extensions

d. Infrastructure Layer
- MySQL database
- Entity Framework Context (CashflowDbContext)
- Repository implementations
- Unit of Work pattern implementation

##### Component Relationships

**[Client Applications] ↔ HTTP/REST**
- ↓
**[API Layer (Controllers)]**
- ↓
**[Application Layer (Use Cases)]**
- ↓
**[Domain Layer (Entities, Interfaces)]**
- ↓
**[Infrastructure Layer] ↔ MySQL Database**

##### Detailed Component Breakdown

**API Layer:**
- REST Endpoints
- Request/Response DTOs (from Communication project)
- Middleware Components
- Exception Filters

**Application Layer:**
- Expense Use Cases:
- * Register
- * Update
- * Delete
- * GetAll
- * GetById
- Report Generation:
- * PDF Generation
- * Excel Generation
- Validators

**Domain Layer:**
- Expense Entity
- Repository Interfaces
- Domain Enums
- Value Objects

**Infrastructure Layer:**
- DbContext
- Repository Implementations
- Unit of Work
- Database Configurations

##### Additional Elements

- Notes for important architectural decisions
- DDD layers separation clearly
- Flow of data through the system

##### Key Architectural Patterns to Highlight

- DDD layered architecture
- Repository Pattern
- Unit of Work Pattern
- CQRS-like separation (Read/Write repositories)
- Mediator pattern (if implemented in the Use Cases)

##### Technical Stack Indicators

- .NET 8 Runtime
- Entity Framework Core
- MySQL Database
- AutoMapper
- FluentValidation
- Swagger/OpenAPI

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        C[Client Applications]
    end

    subgraph API["API Layer"]
        direction TB
        AC["API Controllers"]:::api
        AM["API Middleware"]:::api
        EF["Exception Filter"]:::api
        SW["Swagger Documentation"]:::api
    end

    subgraph Application["Application Layer"]
        direction TB
        UC["Use Cases"]:::application
        subgraph Reports["Report Generation"]
            direction TB
            PDF["PDF Generator"]:::application
            XLS["Excel Generator"]:::application
        end
        AM_C["AutoMapper"]:::application
        VAL["Validators"]:::application
    end

    subgraph Domain["Domain Layer"]
        direction TB
        EE["Expense Entity"]:::domain
        RI["Repository Interfaces"]:::domain
        DE["Domain Enums"]:::domain
        I18N["Internationalization"]:::domain
    end

    subgraph Infrastructure["Infrastructure Layer"]
        direction TB
        DBC["DbContext"]:::infra
        REP["Repository Implementation"]:::infra
        UOW["Unit of Work"]:::infra
    end

    subgraph Communication["Communication Layer"]
        direction TB
        REQ["Request DTOs"]:::comm
        RES["Response DTOs"]:::comm
    end

    subgraph Database
        DB[(MySQL)]:::db
    end

    C --> AC
    AC --> UC
    AC --> REQ
    AC --> RES
    AM --> AC
    EF --> AC

    UC --> EE
    UC --> RI
    UC --> AM_C
    UC --> VAL
    UC --> PDF
    UC --> XLS

    PDF --> I18N
    XLS --> I18N

    REP --> RI
    REP --> EE
    REP --> DBC
    UOW --> DBC
    DBC --> DB

    %% Click Events
    click AC "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Api/Controllers"
    click AM "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Api/MIddleware"
    click EF "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Api/Filters/ExceptionFilter.cs"
    click UC "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Application/UseCases/Expenses"
    click PDF "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Application/UseCases/Expenses/Reports/Pdf"
    click XLS "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Application/UseCases/Expenses/Reports/Excel"
    click AM_C "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Application/AutoMapper/AutoMapping.cs"
    click VAL "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Application/UseCases/Expenses/ExpenseValidator.cs"
    click EE "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Domain/Entities/Expense.cs"
    click RI "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Domain/Repositories/Expenses"
    click DE "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Domain/Enums"
    click I18N "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Domain/Reports/ResourceReportGenerationMessages.resx"
    click DBC "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Infrastructure/DataAccess/CashflowDbContext.cs"
    click REP "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Infrastructure/DataAccess/Repositories/ExpensesRepository.cs"
    click UOW "https://github.com/yendisgomes/cashflow/blob/master/src/CashFlow.Infrastructure/DataAccess/UnitOfWork.cs"
    click REQ "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Communication/Requests"
    click RES "https://github.com/yendisgomes/cashflow/tree/master/src/CashFlow.Communication/Responses"

    %% Styling
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef application fill:#4CAF50,stroke:#2E7D32,color:white
    classDef domain fill:#FFC107,stroke:#FFA000,color:black
    classDef infra fill:#FF9800,stroke:#F57C00,color:white
    classDef db fill:#9E9E9E,stroke:#616161,color:white
    classDef comm fill:#E91E63,stroke:#C2185B,color:white

    %% Legend
    subgraph Legend
        L1["API Layer"]:::api
        L2["Application Layer"]:::application
        L3["Domain Layer"]:::domain
        L4["Infrastructure Layer"]:::infra
        L5["Database"]:::db
        L6["Communication"]:::comm
    end
```
