# jcomyn/proyecto-gpi architecture

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

- Interactive diagram: https://gitdiagram.com/jcomyn/proyecto-gpi
- Repository: https://github.com/jcomyn/proyecto-gpi

## Overview

##### Project type and purpose
- This is a full-stack car-rental system (“sistema de alquiler de coches”) built with:
- A Java/Spring Boot backend following a hexagonal (ports-and-adapters) architecture
- A React frontend (Material Dashboard template)
- A file-based H2 database
- Docker and docker-compose for local deployment

##### File structure
- Top-level:
- backend/ – Spring Boot code, organized in “application”, “domain”, “infrastructure” packages
- front/ – React app scaffolded around MUI-based Material Dashboard
- docker-compose.yml, init.sql – orchestration and DB init
- backend layers:
- application/ – DTOs, exceptions, service interfaces and their use-case logic
- domain/ – entities and repository interfaces (ports)
- infrastructure/ – REST controllers (adapters/entry points), persistence adapters (JPA + custom impl), mappers, exception handlers, CORS config
- front layers:
- src/services – API clients calling backend HTTP endpoints
- src/hooks, src/context – state management
- src/components, src/layouts, src/paginas – UI components and page flows

##### README
- The README confirms a Docker-Compose workflow and describes the system’s purpose: car-rental management.

##### Elements
- User → Frontend → Backend REST → DB
- Frontend (blue), Backend ports/adapters (orange), Domain (green), DB (gray)

##### Detail is key
- Don’t omit layers: explicitly show DTOs, mappers, exception handlers
- Hexagonal structure: encapsulate domain inside application layer, surrounded by adapters
- External boundary (browser, Docker network)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Docker Compose Layer
    subgraph "Docker-Compose Network" 
        direction TB
        Compose["docker-compose.yml"]:::docker
        subgraph Containers
            direction TB
            FE_Container["Frontend Container"]:::frontend
            BE_Container["Backend Container"]:::backend
            DB_Cylinder[(H2 Database<br/>gpi-db.*.db)]:::db
        end
        Compose --> FE_Container
        Compose --> BE_Container
        Compose --> DB_Cylinder
    end

    %% Browser to Frontend
    Browser["User Browser"]:::external
    Browser -->|"HTTP"| FE_Container

    %% Frontend Layer
    subgraph "Frontend (React)" 
        direction TB
        EntryPoint["Entry Point<br/>index.js / App.js"]:::frontend
        UI["UI Components"]:::frontend
        Layouts["Layouts"]:::frontend
        Pages["Pages (Routes)"]:::frontend
        APIClients["API Clients (services)"]:::frontend
        StateMgmt["State Management<br/>(hooks & context)"]:::frontend

        EntryPoint --> UI
        EntryPoint --> Layouts
        EntryPoint --> Pages
        Pages --> APIClients
        APIClients --> StateMgmt
        UI --> StateMgmt
        Layouts --> StateMgmt
        Pages --> UI
        FE_Container -->|"serves React"| EntryPoint
        EntryPoint -->|"calls REST"| BE_Container
    end

    %% Backend Layer
    subgraph "Backend (Spring Boot)" 
        direction TB
        subgraph "Hexagonal Architecture" 
            direction LR
            subgraph "Ports (Interfaces)" 
                direction TB
                SvcPorts["Service Interfaces"]:::ports
                RepoPorts["Repository Ports"]:::ports
            end
            subgraph "Domain & Application" 
                direction TB
                DomainEnt["Domain Entities"]:::domain
                DTOs["DTOs"]:::application
                AppEx["Application Exceptions"]:::application
                SvcImpl["Service Implementations"]:::application
                DomainEnt --> SvcImpl
                SvcPorts --> SvcImpl
                SvcImpl --> RepoPorts
                DTOs --> SvcImpl
                SvcImpl --> DomainEnt
            end
            subgraph "Adapters" 
                direction TB
                Controllers["REST Controllers"]:::adapters
                Mappers["Mappers"]:::adapters
                JPARepo["JPA Repositories"]:::adapters
                CustomRepo["Custom Repo Impl"]:::adapters
                Advice["Exception Handlers"]:::adapters
                Cors["CORS Config"]:::adapters

                Controllers --> Mappers
                Mappers --> DTOs
                Controllers --> SvcPorts
                SvcImpl --> CustomRepo
                CustomRepo --> DB_Cylinder
                JPARepo --> DB_Cylinder
                Advice --> Controllers
                Cors --> Controllers
            end
            Controllers ---|"implements"| SvcPorts
            RepoPorts ---|"used by"| CustomRepo
        end
        BE_Container -->|"runs"| BackendApp["BackendApplication"]:::backend
    end

    %% Database flow
    BE_Container -->|"JDBC"| DB_Cylinder
    DB_Cylinder -->|"persists SQL"| DB_Cylinder

    %% Click Events
    click FE_Container "https://github.com/jcomyn/proyecto-gpi/tree/main/front/"
    click UI "https://github.com/jcomyn/proyecto-gpi/tree/main/front/src/components/"
    click Layouts "https://github.com/jcomyn/proyecto-gpi/tree/main/front/src/layouts/"
    click Pages "https://github.com/jcomyn/proyecto-gpi/tree/main/front/src/paginas/"
    click APIClients "https://github.com/jcomyn/proyecto-gpi/tree/main/front/src/services/"
    click StateMgmt "https://github.com/jcomyn/proyecto-gpi/tree/main/front/src/hooks/"
    click StateMgmt "https://github.com/jcomyn/proyecto-gpi/tree/main/front/src/context/"
    click EntryPoint "https://github.com/jcomyn/proyecto-gpi/blob/main/front/src/index.js"
    click EntryPoint "https://github.com/jcomyn/proyecto-gpi/blob/main/front/src/App.js"
    click BE_Container "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/"
    click BackendApp "https://github.com/jcomyn/proyecto-gpi/blob/main/backend/src/main/java/es/upm/backend/BackendApplication.java"
    click Compose "https://github.com/jcomyn/proyecto-gpi/blob/main/docker-compose.yml"
    click CustomRepo "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/infrastructure/repository/impl/"
    click JPARepo "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/infrastructure/repository/jpa/"
    click DTOs "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/application/dto/"
    click AppEx "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/application/exception/"
    click SvcPorts "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/application/services/"
    click DomainEnt "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/domain/entities/"
    click RepoPorts "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/domain/repository/"
    click Controllers "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/infrastructure/controllers/"
    click Mappers "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/infrastructure/mapper/"
    click Advice "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/src/main/java/es/upm/backend/infrastructure/advice/"
    click Cors "https://github.com/jcomyn/proyecto-gpi/blob/main/backend/src/main/java/es/upm/backend/infrastructure/config/CorsConfig.java"
    click BackendApp "https://github.com/jcomyn/proyecto-gpi/blob/main/backend/build.gradle"
    click __file_unnamed__ "https://github.com/jcomyn/proyecto-gpi/tree/main/front/Dockerfile"
    click __file_unnamed__ "https://github.com/jcomyn/proyecto-gpi/tree/main/backend/Dockerfile"
    click DB_Cylinder "https://github.com/jcomyn/proyecto-gpi/blob/main/backend/data/gpi-db.mv.db"
    click __file_unnamed__ "https://github.com/jcomyn/proyecto-gpi/blob/main/init.sql"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef backend fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef ports fill:#ffcc80,stroke:#fb8c00,color:#e65100
    classDef application fill:#c5e1a5,stroke:#7cb342,color:#33691e
    classDef domain fill:#a5d6a7,stroke:#388e3c,color:#1b5e20
    classDef adapters fill:#ffcc80,stroke:#fb8c00,color:#e65100
    classDef db fill:#e0e0e0,stroke:#9e9e9e,color:#616161
    classDef docker fill:#d1c4e9,stroke:#5e35b1,color:#311b92
    classDef external fill:#f8bbd0,stroke:#d81b60,color:#880e4f
```
