# lucas-barreto1/customer-loans architecture

> Architecture diagram of the GitHub repository lucas-barreto1/customer-loans, 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/lucas-barreto1/customer-loans
- Repository: https://github.com/lucas-barreto1/customer-loans

## Overview

##### Main system components
- Application Entry Point: Mark the main class (LoansApplication.java) representing the application bootstrapping with Spring Boot.
- Controller Layer: Highlight the LoanController, which is responsible for handling API requests and converting JSON payloads into Java objects via DTO classes (CustomerLoanRequest, CustomerLoanResponse, LoanResponse).
- Service Layer: Emphasize the LoanService that encapsulates business logic for processing loan requests.
- Domain Model: Represent the domain classes (Customer, Loan, and enumerations like LoanType) which define the core business entities.
- Configuration: Note the presence of configuration via application.properties.
- Testing Components: Optionally, acknowledge test packages (provided under src/test) to show unit testing and factories (CustomerFactory) for generating test instances.

##### And illustrate relationships
- Data Flow: Show the API request entering the Controller and then being delegated to the Service layer.
- Communication: Indicate how the Service layer uses the Domain models and possibly throws exceptions when needed.
- Return flow: The Service sends data back via the Controller as DTO responses.
- Configuration affects how all these components behave (e.g., dependency injection by Spring).

##### Architectural Patterns and Design Principles
- Layered architecture (Controller → Service → Domain).
- The use of DTOs suggests a clear separation of concerns between API representations and internal domain objects.
- Leverage Spring Boot’s dependency injection pattern to manage components.
- The Maven project structure reinforces a standard Java enterprise setup.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "API Entry"
        A("LoansApplication"):::entry
    end

    subgraph "Controller Layer"
        B("LoanController"):::controller
        C("CustomerLoanRequest"):::controller
        D("CustomerLoanResponse"):::controller
        E("LoanResponse"):::controller
    end

    subgraph "Service Layer"
        F("LoanService"):::service
    end

    subgraph "Domain Models"
        G("Customer"):::domain
        H("Loan"):::domain
        I("LoanType"):::domain
    end

    subgraph "Exception Handling"
        J("LoanNotAvailableException"):::exception
    end

    subgraph "Configuration"
        K("application.properties"):::config
    end

    subgraph "Testing Components"
        L("LoansApplicationTests"):::test
        M("CustomerTest"):::test
        N("LoanTest"):::test
        O("CustomerFactory"):::test
    end

    Q("Client Request"):::client

    %% Relationships
    Q -->|"submit"| B
    A -->|"bootstrap"| B
    B -->|"delegate"| F
    F -->|"processes"| G
    F -->|"processes"| H
    F -->|"processes"| I
    F -->|"throws"| J
    F -->|"returns"| B
    B -->|"response"| Q

    %% Configuration dependencies
    K --- A
    K --- B
    K --- F

    %% Click Events
    click A "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/LoansApplication.java"
    click B "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/controllers/LoanController.java"
    click C "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/controllers/dto/CustomerLoanRequest.java"
    click D "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/controllers/dto/CustomerLoanResponse.java"
    click E "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/controllers/dto/LoanResponse.java"
    click F "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/service/LoanService.java"
    click G "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/domain/Customer.java"
    click H "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/domain/Loan.java"
    click I "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/domain/enums/LoanType.java"
    click J "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/java/com/lcs/loans/domain/exceptions/LoanNotAvailableException.java"
    click K "https://github.com/lucas-barreto1/customer-loans/blob/main/src/main/resources/application.properties"
    click L "https://github.com/lucas-barreto1/customer-loans/blob/main/src/test/java/com/lcs/loans/LoansApplicationTests.java"
    click M "https://github.com/lucas-barreto1/customer-loans/blob/main/src/test/java/com/lcs/loans/domain/CustomerTest.java"
    click N "https://github.com/lucas-barreto1/customer-loans/blob/main/src/test/java/com/lcs/loans/domain/LoanTest.java"
    click O "https://github.com/lucas-barreto1/customer-loans/blob/main/src/test/java/com/lcs/loans/factory/CustomerFactory.java"

    %% Styles
    classDef entry fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef controller fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef service fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef domain fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef exception fill:#FF9999,stroke:#333,stroke-width:2px;
    classDef config fill:#D9D9D9,stroke:#333,stroke-width:2px;
    classDef test fill:#E0CCFF,stroke:#333,stroke-width:2px;
    classDef client fill:#F9E79F,stroke:#333,stroke-width:2px;
```
