# audio10/e-reservation architecture

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

- Interactive diagram: https://gitdiagram.com/audio10/e-reservation
- Repository: https://github.com/audio10/e-reservation

## Overview

##### Main Components
- Application Entry Point: Represent the core Spring Boot application that bootstraps the service (EReservationApplication.java).
- Model Layer (com.platzi.ereservation.modelo): This contains the domain entities like Cliente and Reserva. These classes represent the tables of the database (mapped via JPA and Hibernate).
- Business/Service Layer (com.platzi.ereservation.negocio): This layer includes components such as the repositories (ClienteRepository, ReservaRepository) and services (ClienteService) that handle business logic and persistence.
- View/Controller Layer (com.platzi.ereservation.vista): This layer implements the REST controllers (e.g., LoginController and ClienteResource) that expose endpoints to client requests. Additionally, it includes resources such as the VO objects (ClienteVO) and the templates/static resources (home.html, login.html, styles.css).
- Configuration & Utilities: Include utility classes (BasicConfiguration, SwaggerConfiguration) and configuration files (application.properties, application.yaml) that set up database connections, Swagger documentation, and general application configuration.
- External and Supporting Technologies:
- Spring Boot with embedded Tomcat for running a standalone web server.
- Spring Data JPA & Hibernate for ORM.
- Swagger (via Spring Fox) for API documentation.
- Maven as the build tool (pom.xml, mvnw scripts) and possibly Lombok to reduce boilerplate in models.
- A PostgreSQL database (as described in the README with Docker commands for setup).

##### Architectural Patterns & Design Principles
- MVC pattern: Separate the system into three clearly distinct layers – Model (data entities), View (web controllers and templates), and Controller/Service (business logic and REST layer).
- Dependency Injection as provided by Spring, showing that components like Controllers, Services, and Repositories are managed as Spring beans.
- Use of JPA/Hibernate for ORM, mapping database tables to Java objects.
- That the system is designed to be modular, with a clear separation between the layers which supports maintainability and scalability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Client["Client / Browser"]:::client
    end

    %% Web Server and Application Entry
    subgraph "Web Server (Spring Boot with embedded Tomcat)"
        EResApp["EReservationApplication"]:::webserver
    end

    %% Controller & View Layer (Vista)
    subgraph "Controller Layer (Vista)"
        LoginCtrl["LoginController"]:::controller
        ClienteRes["ClienteResource"]:::controller
        ClienteVO["ClienteVO"]:::controller
        subgraph "Templates & Static Resources"
            HomeTemp["Home Template (home.html)"]:::controller
            LoginTemp["Login Template (login.html)"]:::controller
            Stylesheet["Stylesheet (styles.css)"]:::controller
        end
    end

    %% Service Layer (Negocio)
    subgraph "Service Layer (Negocio)"
        ClienteSvc["ClienteService"]:::service
    end

    %% Repository & Model Layer
    subgraph "Repository & Model Layer"
        subgraph "Repositories"
            ClienteRepo["ClienteRepository"]:::repository
            ReservaRepo["ReservaRepository"]:::repository
        end
        subgraph "Model Entities"
            ClienteEnt["Cliente Entity"]:::model
            ReservaEnt["Reserva Entity"]:::model
        end
    end

    %% Configuration & Utilities
    subgraph "Configuration & Utilities"
        BasicConfig["BasicConfiguration"]:::config
        SwaggerConfig["SwaggerConfiguration"]:::config
        AppProps["application.properties"]:::config
        AppYaml["application.yaml"]:::config
    end

    %% Build & External Configuration
    subgraph "Build & External Configuration"
        Pom["pom.xml"]:::build
        MavenWrap["Maven Wrapper Scripts"]:::build
    end

    %% Database Layer
    subgraph "Database Layer"
        PostgreSQL["PostgreSQL Database"]:::database
    end

    %% Connections
    Client -->|"HTTP Request"| EResApp
    EResApp -->|"Routes Request"| LoginCtrl
    EResApp -->|"Routes Request"| ClienteRes
    LoginCtrl -->|"Invokes"| ClienteSvc
    ClienteRes -->|"Invokes"| ClienteSvc
    ClienteSvc -->|"Calls"| ClienteRepo
    ClienteSvc -->|"Calls"| ReservaRepo
    ClienteRepo -->|"Maps to"| ClienteEnt
    ReservaRepo -->|"Maps to"| ReservaEnt
    ClienteRepo -->|"Accesses"| PostgreSQL
    ReservaRepo -->|"Accesses"| PostgreSQL
    %% View responds back to client via templates
    LoginCtrl -->|"Renders"| HomeTemp
    ClienteRes -->|"Renders"| LoginTemp
    ClienteRes -->|"Serves"| Stylesheet

    %% Configuration connections (influence bootstrap and system setup)
    EResApp -->|"Uses"| BasicConfig
    EResApp -->|"Uses"| SwaggerConfig
    EResApp -->|"Reads"| AppProps
    EResApp -->|"Reads"| AppYaml

    %% Build system supports project configuration
    EResApp ---|"Built with"| Pom
    EResApp ---|"Built with"| MavenWrap

    %% Click Events
    click EResApp "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/EReservationApplication.java"
    click ClienteEnt "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/modelo/Cliente.java"
    click ReservaEnt "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/modelo/Reserva.java"
    click ClienteRepo "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/negocio/repository/ClienteRepository.java"
    click ReservaRepo "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/negocio/repository/ReservaRepository.java"
    click ClienteSvc "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/negocio/services/ClienteService.java"
    click LoginCtrl "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/vista/controllers/LoginController.java"
    click ClienteRes "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/vista/resources/ClienteResource.java"
    click ClienteVO "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/vista/resources/vo/ClienteVO.java"
    click HomeTemp "https://github.com/audio10/e-reservation/blob/develop/src/main/resources/templates/home.html"
    click LoginTemp "https://github.com/audio10/e-reservation/blob/develop/src/main/resources/templates/login.html"
    click Stylesheet "https://github.com/audio10/e-reservation/blob/develop/src/main/resources/static/css/styles.css"
    click BasicConfig "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/util/BasicConfiguration.java"
    click SwaggerConfig "https://github.com/audio10/e-reservation/blob/develop/src/main/java/com/platzi/ereservation/util/SwaggerConfiguration.java"
    click AppProps "https://github.com/audio10/e-reservation/blob/develop/src/main/resources/application.properties"
    click AppYaml "https://github.com/audio10/e-reservation/blob/develop/src/main/resources/application.yaml"
    click Pom "https://github.com/audio10/e-reservation/blob/develop/pom.xml"
    click MavenWrap "https://github.com/audio10/e-reservation/tree/develop/mvnw"

    %% Styles
    classDef client fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef webserver fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef controller fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef service fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef repository fill:#d1c4e9,stroke:#333,stroke-width:2px;
    classDef model fill:#ffebcc,stroke:#333,stroke-width:2px;
    classDef config fill:#d0f0c0,stroke:#333,stroke-width:2px;
    classDef build fill:#fcd5ce,stroke:#333,stroke-width:2px;
    classDef database fill:#d9ead3,stroke:#333,stroke-width:2px;
```
