# asbel05/spring-boot-jpa architecture

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

- Interactive diagram: https://gitdiagram.com/asbel05/spring-boot-jpa
- Repository: https://github.com/asbel05/spring-boot-jpa

## Overview

##### Project type and purpose
- This is a monolithic backend application built with Spring Boot and Spring Data JPA.
- It exposes REST endpoints for managing Usuarios, Equipos, and Reservas.

##### File structure
- Top‑level artifacts: pom.xml, mvnw scripts, application.yml
- src/main/java/com/gozhu:
- controller – REST controllers for three resources
- service – business‑logic interfaces + impl packages
- repository – Spring Data JPA repositories
- entity – JPA entity classes
- dto – request/response DTOs grouped by resource
- mapper – DTO⇆entity conversion
- src/main/resources: application.yml holds DB and server config
- src/test: basic Spring Boot integration test

##### README
- Shows four REST endpoints per resource: list and get by id
- Confirms a simple CRUD REST API

a. Main components
- Client (e.g. browser, Postman, mobile app)
- Spring Boot Application
· Controllers (EquipoController, ReservaController, UsuarioController)
· Service Layer (EquipoService, ReservaService, UsuarioService)
· Mapper Layer (EquipoMapper, ReservaMapper, UsuarioMapper)
· Repository Layer (EquipoRepository, ReservaRepository, UsuarioRepository)
- Relational Database (configured in application.yml)
b. Relationships & data flow
1. Client → HTTP Request → Controller
2. Controller → calls Service
3. Service → uses Mapper to convert DTO to Entity
4. Service → invokes Repository to perform CRUD
5. Repository → persists/fetches Entity → DB
6. Service → Mapper converts Entity → DTO → Controller → Client
c. Architectural patterns & principles
- Layered architecture (Controller → Service → Repository)
- DTO pattern to decouple API models from persistence models
- Dependency Injection via Spring
- Single‑module monolith
d. Key technologies
- Java 17+ (assumed by Spring Boot version)
- Spring Boot (web starter, data‑jpa)
- Spring Data JPA & Hibernate
- Maven
- Relational DB (H2/MySQL/PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External Systems"
        Client["Client (Browser/Postman/Mobile)"]:::external
        Database["Relational Database"]:::external
    end

    subgraph "Spring Boot Application"
        SJ["SpringJpaApplication"]:::application

        subgraph "Controllers"
            EC["EquipoController"]:::controller
            RC["ReservaController"]:::controller
            UC["UsuarioController"]:::controller
        end

        subgraph "Service Layer"
            ES["EquipoService"]:::service
            RS["ReservaService"]:::service
            US["UsuarioService"]:::service
            ESI["EquipoServiceImpl"]:::serviceImpl
            RSI["ReservaServiceImpl"]:::serviceImpl
            USI["UsuarioServiceImpl"]:::serviceImpl
        end

        subgraph "Mapper Layer"
            EM["EquipoMapper"]:::mapper
            RM["ReservaMapper"]:::mapper
            UM["UsuarioMapper"]:::mapper
        end

        subgraph "Repository Layer"
            ER["EquipoRepository"]:::repository
            RR["ReservaRepository"]:::repository
            UR["UsuarioRepository"]:::repository
        end
    end

    Client -->|HTTP GET/POST| EC
    Client -->|HTTP GET/POST| RC
    Client -->|HTTP GET/POST| UC

    EC -->|"calls methods"| ESI
    RC -->|"calls methods"| RSI
    UC -->|"calls methods"| USI

    ESI -->|"convert DTO→Entity"| EM
    RSI -->|"convert DTO→Entity"| RM
    USI -->|"convert DTO→Entity"| UM

    EM -->|"mapped Entity"| ESI
    RM -->|"mapped Entity"| RSI
    UM -->|"mapped Entity"| USI

    ESI -->|"invoke CRUD"| ER
    RSI -->|"invoke CRUD"| RR
    USI -->|"invoke CRUD"| UR

    ER -->|SQL Query| Database
    RR -->|SQL Query| Database
    UR -->|SQL Query| Database

    Database -->|Result| ER
    Database -->|Result| RR
    Database -->|Result| UR

    ESI -->|"Entity→DTO"| EM
    RSI -->|"Entity→DTO"| RM
    USI -->|"Entity→DTO"| UM

    EM -->|"return DTO"| EC
    RM -->|"return DTO"| RC
    UM -->|"return DTO"| UC

    click SJ "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/SpringJpaApplication.java"
    click EC "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/controller/EquipoController.java"
    click RC "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/controller/ReservaController.java"
    click UC "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/controller/UsuarioController.java"
    click ES "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/service/EquipoService.java"
    click RS "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/service/ReservaService.java"
    click US "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/service/UsuarioService.java"
    click ESI "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/service/impl/EquipoServiceImpl.java"
    click RSI "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/service/impl/ReservaServiceImpl.java"
    click USI "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/service/impl/UsuarioServiceImpl.java"
    click EM "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/mapper/EquipoMapper.java"
    click RM "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/mapper/ReservaMapper.java"
    click UM "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/mapper/UsuarioMapper.java"
    click ER "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/repository/EquipoRepository.java"
    click RR "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/repository/ReservaRepository.java"
    click UR "https://github.com/asbel05/spring-boot-jpa/blob/master/src/main/java/com/gozhu/repository/UsuarioRepository.java"

    classDef controller fill:#cce5ff,stroke:#4d94ff
    classDef service fill:#d5f5e3,stroke:#27ae60
    classDef serviceImpl fill:#abebc6,stroke:#229954
    classDef mapper fill:#fcf3cf,stroke:#f1c40f
    classDef repository fill:#f9e79f,stroke:#d68910
    classDef external fill:#ececec,stroke:#999999
    classDef application fill:#e8f6f3,stroke:#1abc9c
```
