# anagonbu/app_cajero architecture

> Architecture diagram of the GitHub repository anagonbu/app_cajero, 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/anagonbu/app_cajero
- Repository: https://github.com/anagonbu/app_cajero

## Overview

##### Components Identification
- Frontend/UI Layer:
- Represented by the Thymeleaf HTML templates located under the resources/templates folder (home.html, movimientos.html, operation.html, etc.).
- This layer handles user interaction (login, operation selection, form submissions for entering amounts, etc.).
- Web/Controller Layer:
- Includes the standard controllers (e.g., HomeController in cajeroweb/controller) and the REST controller (cajeroRestcontroller in cajeroweb/restontroller).
- This layer handles HTTP requests and manages session state (storing the current account number).
- Business Logic / Service Layer:
- These components handle validation (e.g., account existence, balance checks) and orchestrate transactions such as deposits, withdrawals, and transfers.
- Data Persistence Layer:
- The data access layer includes the DAO implementations (CuentaDaoImplJpaMy8, MovimientoDaoImplJpaMy8) and Spring Data JPA repository interfaces (CuentaRepository, MovimientoRepository).
- This layer maps the entities (Cuenta and Movimiento) to the underlying database (backed by cajero_2024.sql).
- Database:
- The underlying database is configured via the application.properties file and is prepped using the provided SQL script (cajero_2024.sql) to create the necessary tables.

##### Relationships and Interactions
- The UI layer interacts with the Controllers; when a user initiates an operation (e.g., deposit, withdrawal, transfer), the request is sent to the appropriate controller.
- Controllers call functions on the DAO/repository layer (either directly or via a subtly embedded business logic layer) to perform database operations.
- The DAOs and repositories then access the persistence layer, which reads from and writes to the database.
- In addition, session management is used to maintain the state of current account operations between HTTP requests.

##### Architectural Patterns and Key Design Principles
- MVC Pattern: The separation is clear between the Model (entities, DAO, repository), View (HTML templates), and Controller (web and REST controllers).
- Data Access using Spring Data JPA: Emphasizes CRUD operations on entities and handling persistence automatically.
- DAO Pattern: Custom DAO implementations (CuentaDaoImplJpaMy8, MovimientoDaoImplJpaMy8) possibly add additional business logic around data operations.
- Integration Points: Although no external services are directly shown, the design implies possible future integration with external banking services or logging if required.

##### Relevant Technologies and Frameworks
- Spring Boot: To develop the web application and manage dependency injection.
- Spring MVC: Underpins the Model-View-Controller architecture.
- Spring Data JPA: Simplifies the interaction with the relational database.
- Thymeleaf: Template engine for rendering HTML views.
- Maven: For build and dependency management (as seen with pom.xml, mvnw, and mvnw.cmd).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Top Level: Client and UI
    Client["User (Browser)"]:::frontend
    UI["UI/Thymeleaf Templates"]:::frontend
    Client -->|"HTTP_Request"| UI

    %% Controllers
    Controller["Web Controller: HomeController"]:::controller
    Rest["REST Controller: cajeroRestcontroller"]:::controller
    UI -->|"Form_Submission"| Controller
    UI -->|"API_Call"| Rest

    %% Business Logic/Data Access Layer
    subgraph "Business Logic/Data Access Layer"
        DAO1["DAO: CuentaDaoImplJpaMy8"]:::datalayer
        DAO2["DAO: MovimientoDaoImplJpaMy8"]:::datalayer
        Repo1["Repository: CuentaRepository"]:::datalayer
        Repo2["Repository: MovimientoRepository"]:::datalayer
    end
    Controller -->|"Invoke_DAO"| DAO1
    Controller -->|"Invoke_DAO"| DAO2
    Rest -->|"Invoke_Repository"| Repo1
    Rest -->|"Invoke_Repository"| Repo2

    %% Domain Model Subgraph
    subgraph "Domain Model"
        E1["Entity: Cuenta"]:::entity
        E2["Entity: Movimiento"]:::entity
    end
    DAO1 -->|"MapsTo"| E1
    Repo1 -->|"MapsTo"| E1
    DAO2 -->|"MapsTo"| E2
    Repo2 -->|"MapsTo"| E2

    %% Database and Configuration
    DB["Database"]:::config
    Config["Configuration: application.properties"]:::config
    SQL["SQL Script: cajero_2024.sql"]:::config
    DAO1 -->|"DB_Operation"| DB
    DAO2 -->|"DB_Operation"| DB
    Repo1 -->|"DB_Operation"| DB
    Repo2 -->|"DB_Operation"| DB
    Config -->|"Initializes"| DB
    SQL -->|"Initializes"| DB

    %% Build and Dependency Management
    Build["Build & Dependencies: Maven"]:::build
    Controller --- Build
    Rest --- Build

    %% Click Events
    click UI "https://github.com/anagonbu/app_cajero/tree/main/AGB_Actividad_03_Cajero/src/main/resources/templates"
    click Controller "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/controller/HomeController.java"
    click Rest "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/restontroller/cajeroRestcontroller.java"
    click DAO1 "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/modelo/dao/CuentaDaoImplJpaMy8.java"
    click DAO2 "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/modelo/dao/MovimientoDaoImplJpaMy8.java"
    click Repo1 "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/repository/CuentaRepository.java"
    click Repo2 "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/repository/MovimientoRepository.java"
    click E1 "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/entities/Cuenta.java"
    click E2 "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/java/cajeroweb/entities/Movimiento.java"
    click Config "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/src/main/resources/application.properties"
    click SQL "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/cajero_2024.sql"
    click Build "https://github.com/anagonbu/app_cajero/blob/main/AGB_Actividad_03_Cajero/pom.xml"

    %% Class Definitions for Colors
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef controller fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef datalayer fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef entity fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef build fill:#FFB6C1,stroke:#000,stroke-width:1px;
```
