# migueloliveiradev/living architecture

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

- Interactive diagram: https://gitdiagram.com/migueloliveiradev/living
- Repository: https://github.com/migueloliveiradev/living

## Overview

##### Main Components
- Front End: Represent the Living.WebAPP, which is built on Nuxt 3 and Vue.js. This component handles the user interface and client-side logic, using PrimeVue for UI components and integrating with ESLint, TypeScript, and OpenAPI TypeScript for type-generation.
- Back End – API: Represent the Living.WebAPI project, built on ASP.NET Core. This project includes controllers (e.g., AuthController, PostController) that expose REST endpoints. Include aspects such as middleware (for authentication, exception handling) and documentation provided through Swagger.
- Domain Layer: Represent the Living.Domain project that contains core business logic, aggregates, domain entities (e.g., Post, User, Group), value objects, and domain constants. This layer enforces business rules and encapsulates domain models.
- Infrastructure: Represent the Living.Infraestructure project to show how persistence is managed. This includes the EF Core context, database configurations (targeting PostgreSQL), repositories (e.g., PostRepository, UserRepository), migrations, and identity services.

##### Relationships and Data Flow Between Components
- The Application layer communicates with the Domain layer to execute business logic and then coordinates with the Infrastructure layer (via the Unit of Work and Repository patterns) for database operations.
- External services such as the PostgreSQL database (managed via Entity Framework Core) should be shown connected to the Infrastructure layer.
- Authentication flows: Highlight the use of ASP.NET Core Identity in the API and Infrastructure layers, and indicate any integrations with token services (as seen in ITokenService and related handlers/services) for handling authentication.

##### Architectural Patterns and Technologies
- Mediator Pattern: Indicate the use of MediatR for decoupling and handling operations.
- DI (Dependency Injection): Although implicit in the modular design, indicate that most components are wired together through .NET’s dependency injection.
- ORM: Highlight that EF Core works as the ORM connecting to PostgreSQL.
- Identity and Security: Call out the ASP.NET Core Identity integration for user management.
- Testing: Optionally add a note that robust unit and integration testing is covered by xUnit, Testcontainers, and other testing frameworks.

##### Additional Notes
- Since the project also includes tests and tooling modules, include a small section (if space permits) that shows how tests validate the core components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Front End
    WebClient("Web Client (Nuxt/VueJS)"):::frontend

    %% API Layer Subgraph
    subgraph "API Layer (ASP.NET Core)"
        APILayer("API Core"):::backend
        Controllers("Controllers"):::backend
        Extensions("Extensions"):::backend
        Filters("Filters"):::backend
        ProgramAPI("Program.cs"):::backend
        Middleware("Middleware (Auth,Exception)"):::backend
        Swagger("Swagger (API Docs)"):::backend
    end

    %% Application Layer Subgraph
    subgraph "Application Layer (CQRS & MediatR)"
        AppLayer("Use Cases"):::application
        CreatePost("CreatePostCommand"):::application
        LoginUser("LoginUserCommand"):::application
    end

    %% Domain Layer Subgraph
    subgraph "Domain Layer (Business Models & Rules)"
        Domain("Domain Core"):::domain
        DomainBase("Base"):::domain
        DomainFeatures("Features"):::domain
        DomainMapper("Mapper"):::domain
    end

    %% Infrastructure Layer Subgraph
    subgraph "Infrastructure Layer (EF Core & Repositories)"
        Infra("Infrastructure Core"):::infrastructure
        EFContext("EF Core Context"):::infrastructure
        Repositories("Repositories"):::infrastructure
        IdentityServices("Identity Services"):::infrastructure
        Configurations("Configuration"):::infrastructure
        Migrations("Migrations"):::infrastructure
    end

    %% External Database
    PostgreSQLDB("PostgreSQL Database"):::external

    %% Supporting Modules: Shared Utilities
    subgraph "Shared Utilities"
        Shared("Shared Core"):::support
        SharedExt("Extensions"):::support
        SharedHandlers("Handlers"):::support
        SharedHelpers("Helpers"):::support
    end

    %% Supporting Modules: Tools & Scripts
    subgraph "Tools & Scripts"
        Tools("Tools Core"):::support
        ToolsCommands("Commands"):::support
        ToolsTemplates("Templates"):::support
        ToolsProgram("Program.cs"):::support
    end

    %% Supporting Modules: Testing
    subgraph "Testing Modules"
        UnitTests("Unit Tests"):::support
        IntegrationTests("Integration Tests"):::support
    end

    %% Main Data Flows
    WebClient -->|"RESTAPICalls"| APILayer
    APILayer -->|"DelegatesCommands"| AppLayer
    AppLayer -->|"ExecutesBusinessLogic"| Domain
    AppLayer -->|"PersistsData"| Infra
    Infra -->|"ORMOperations"| PostgreSQLDB

    %% Internal Connections in API Layer
    APILayer --> Controllers
    Controllers --> Middleware
    Middleware --> Extensions
    Extensions --> Filters
    Filters --> ProgramAPI
    ProgramAPI --> Swagger

    %% Internal Connections in Application Layer
    AppLayer --> CreatePost
    AppLayer --> LoginUser

    %% Internal Connections in Domain Layer
    Domain --> DomainBase
    DomainBase --> DomainFeatures
    DomainFeatures --> DomainMapper

    %% Internal Connections in Infrastructure Layer
    Infra --> EFContext
    EFContext --> Repositories
    Repositories --> IdentityServices
    IdentityServices --> Configurations
    Configurations --> Migrations

    %% Connections to Supporting Modules
    AppLayer -->|"Uses"| Shared
    Shared --> Tools
    UnitTests --- APILayer
    UnitTests --- AppLayer
    UnitTests --- Infra
    IntegrationTests --- APILayer
    IntegrationTests --- AppLayer
    IntegrationTests --- Infra

    %% Click Events
    click WebClient "https://github.com/migueloliveiradev/living/blob/main/Living.WebAPP"
    click APILayer "https://github.com/migueloliveiradev/living/blob/main/Living.WebAPI"
    click Controllers "https://github.com/migueloliveiradev/living/tree/main/Living.WebAPI/Controllers"
    click Extensions "https://github.com/migueloliveiradev/living/tree/main/Living.WebAPI/Extensions"
    click Filters "https://github.com/migueloliveiradev/living/tree/main/Living.WebAPI/Filters"
    click ProgramAPI "https://github.com/migueloliveiradev/living/blob/main/Living.WebAPI/Program.cs"
    click AppLayer "https://github.com/migueloliveiradev/living/tree/main/Living.Application/UseCases"
    click Domain "https://github.com/migueloliveiradev/living/blob/main/Living.Domain"
    click DomainBase "https://github.com/migueloliveiradev/living/tree/main/Living.Domain/Base"
    click DomainFeatures "https://github.com/migueloliveiradev/living/tree/main/Living.Domain/Features"
    click DomainMapper "https://github.com/migueloliveiradev/living/tree/main/Living.Domain/Mapper"
    click Infra "https://github.com/migueloliveiradev/living/blob/main/Living.Infraestructure"
    click EFContext "https://github.com/migueloliveiradev/living/tree/main/Living.Infraestructure/Context"
    click Repositories "https://github.com/migueloliveiradev/living/tree/main/Living.Infraestructure/Repositories"
    click IdentityServices "https://github.com/migueloliveiradev/living/tree/main/Living.Infraestructure/Identity"
    click Shared "https://github.com/migueloliveiradev/living/blob/main/Living.Shared"
    click SharedExt "https://github.com/migueloliveiradev/living/tree/main/Living.Shared/Extensions"
    click SharedHandlers "https://github.com/migueloliveiradev/living/tree/main/Living.Shared/Handlers"
    click SharedHelpers "https://github.com/migueloliveiradev/living/tree/main/Living.Shared/Helpers"
    click Tools "https://github.com/migueloliveiradev/living/blob/main/Living.Tools"
    click ToolsCommands "https://github.com/migueloliveiradev/living/tree/main/Living.Tools/Commands"
    click ToolsTemplates "https://github.com/migueloliveiradev/living/tree/main/Living.Tools/Templates"
    click ToolsProgram "https://github.com/migueloliveiradev/living/blob/main/Living.Tools/Program.cs"
    click UnitTests "https://github.com/migueloliveiradev/living/blob/main/Living.Tests.Unit"
    click IntegrationTests "https://github.com/migueloliveiradev/living/blob/main/Living.Tests"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef application fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef domain fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef infrastructure fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef support fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#fefefe,stroke:#343a40,stroke-width:2px;

    class WebClient frontend;
    class APILayer,Controllers,Extensions,Filters,ProgramAPI,Middleware,Swagger backend;
    class AppLayer,CreatePost,LoginUser application;
    class Domain,DomainBase,DomainFeatures,DomainMapper domain;
    class Infra,EFContext,Repositories,IdentityServices,Configurations,Migrations infrastructure;
    class PostgreSQLDB external;
    class Shared,SharedExt,SharedHandlers,SharedHelpers,Tools,ToolsCommands,ToolsTemplates,ToolsProgram,UnitTests,IntegrationTests support;
```
