# 1adrianm/loansavingsystem_clean-architecture architecture

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

- Interactive diagram: https://gitdiagram.com/1adrianm/loansavingsystem_clean-architecture
- Repository: https://github.com/1adrianm/loansavingsystem_clean-architecture

## Overview

##### Project Type and Purpose
- This project is a Clean Architecture–based financial application concerned with handling loans, savings, and related operations (clients, prestamos, guarantees, payments, etc.).
- It is a full-stack solution built using a .NET backend combined with an Angular web UI. The system follows Domain Driven Design (DDD) patterns and organizes business logic into distinct layers (Domain, Application, Infrastructure, Presentation/WebApi).

##### Main Components
- Domain Layer: Contains core business entities such as Cliente, Prestamo, Garantia, CuotaPrestamo, Inversionista, Prestatario, etc. It encapsulates the business rules and domain exceptions.
- Application Layer: Hosts command and query handlers (e.g., CreateClientCommandHandler, UpdatePrestamoCommandHandler) and defines interfaces (e.g., IUnitOfWork) that orchestrate business use cases, communication between the domain and outer layers.
- Infrastructure Layer: Implements data access and persistence mechanisms. It contains repositories, mappers (e.g., ClientMapper, PrestamoMapper), and the EF Core database context (AhorrosPrestamosDb2Context) to interact with the database.
- Web API (Presentation for server side): Exposes RESTful endpoints (organized by domain functionality in folders such as Endpoints/Client, Endpoints/Prestamo, etc.), incorporates middeware (ExceptionMiddleware) and configuration logic. It acts as the gateway to the Application layer.
- Angular Web UI (Client-Side Presentation): A separate project (under Presentation.AngularWebUI) implementing the front end with Angular components, services, pages, and forms for user interactions – such as login, signup, creating or editing clients and loans.

##### Relationships and Interactions
- The Angular UI communicates with the backend Web API through HTTP/REST calls.
- The Web API layer receives requests, applies middleware (i.e., Exception handling, validation), and routes calls to the Application layer.
- The Application layer handles business logic through commands and queries. It uses dependency injection to invoke domain operations and dispatch repository calls.
- The Domain layer encapsulates entities and business rules, staying independent of external concerns.
- The Infrastructure layer provides implementations required for persistence and external data manipulation. It supports the Application layer by implementing repositories and mapping domain entities to database models.

##### Architectural Patterns and Design Principles
- Clean Architecture – separation of concerns into independent layers with dependencies directed inward (from Presentation to Application to Domain).
- Command/Query Responsibility Segregation (CQRS) as seen with distinct Command and Query folders inside the Application layer.
- Dependency Injection is clearly used across layers, as indicated by dedicated DependencyInjection.cs files in each layer.
- Repository Pattern in the Infrastructure layer that abstracts database operations.
- The Angular front end follows component-driven design patterns with clear separation between pages, forms, and services.

##### Relevant Technologies and Frameworks
- .NET (Core) is used for the backend (WebApi, Application, Domain, Infrastructure).
- Entity Framework Core is likely used for persistence (given the DbContext and repository implementations).
- Angular (with TypeScript) is used for the client-side UI.
- Additional supporting libraries include mapper libraries for transforming data between layers and possibly middleware for error handling and request validation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Angular Frontend"
        A1("Angular UI"):::angular
    end

    subgraph "Web API Layer"
        W1("REST Endpoints & Middleware"):::webapi
    end

    subgraph "Application Layer"
        AP1("Command & Query Handlers"):::application
    end

    subgraph "Business Logic"
        D1("Domain Entities & Rules"):::domain
        I1("Infrastructure (Repositories & Persistence)"):::infrastructure
    end

    A1 -->|"HTTP/REST"| W1
    W1 -->|"Routes"| AP1
    AP1 -->|"ExecutesUseCases"| D1
    AP1 -->|"RepositoryCalls"| I1

    click A1 "https://github.com/1adrianm/loansavingsystem_clean-architecture/tree/main/Presentation.AngularWebUI/frontal_ui"
    click W1 "https://github.com/1adrianm/loansavingsystem_clean-architecture/tree/main/WebApi"
    click AP1 "https://github.com/1adrianm/loansavingsystem_clean-architecture/blob/main/Application/SeedOfWork/IUnitOfWork.cs"
    click D1 "https://github.com/1adrianm/loansavingsystem_clean-architecture/tree/main/Domain/Entities"
    click I1 "https://github.com/1adrianm/loansavingsystem_clean-architecture/tree/main/Infrastructure/Repositories"

    classDef angular fill:#ffebcd,stroke:#333,stroke-width:2px;
    classDef webapi fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef application fill:#e2f0cb,stroke:#333,stroke-width:2px;
    classDef domain fill:#fbdfe2,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#e0dfe2,stroke:#333,stroke-width:2px;
```
