# ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8 architecture

> Architecture diagram of the GitHub repository ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8
- Repository: https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8

## Overview

##### Main Components
- Frontend – The view layer comprises static HTML/CSS (with templates stored under “src/main/resources/templates” and “static”). These are used for the user interface (e.g., home page, account, routine, trainers, etc.).
- Controllers – Located in “controllers”, these are Spring MVC endpoints (e.g., UserController, TrainerController, ExerciseController) that receive clients’ requests.
- Services – Business logic is encapsulated in service classes (e.g., ExerciseServices, RoutineServices, CommentService) which process data and encapsulate logic.
- Repositories – Data persistence is managed by repository interfaces (e.g., UserRepository, TrainerRepository) that interface with the MySQL database.
- Database – MySQL holds the persistent data. The README even provides instructions for creating a “gymapp” schema.
- DTO & Mappers – These are used to transfer and map data between layers; they help in decoupling the internal model from the exposed API.

##### Relationships and Interactions
- When a user interacts with the web pages (front-end), their requests (either GET or POST) are routed to a specific Controller.
- The Controller then calls the corresponding Service to execute the necessary business logic.
- The Service uses one or more Repository components to perform CRUD operations on the MySQL database.
- Data is transformed via DTO classes and their associated Mapper classes before being sent to the view.
- GlobalControllerAdvice is in place to handle exceptions globally, so include it as a cross-cutting concern that intercepts errors from any component.
- There is also integration for handling user sessions, permissions (e.g., registered user vs. administrator), and file uploads (e.g., profile images).

##### Architectural Patterns and Technologies
- The application clearly implements the MVC pattern.
- It uses a multi-layered structure (Controllers → Services → Repositories → MySQL).
- Technologies include Java JDK, Spring Boot 3.4.2, Maven, and MySQL 8.0.33.0.
- The use of DTOs and Mappers shows the decoupling between internal representations (models) and external data transfer objects.
- The file structure suggests adoption of best practices in organizing code, with clear separations for configuration (application.properties), templates, and static content.

##### Final Elements
- Use clear labels for each component (e.g., “UserController,” “MaterialServices,” “MySQL Database”).
- Optionally, include an annotation or separate section for cross-cutting concerns like GlobalControllerAdvice.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        F1("Templates"):::frontend
        F2("Static Assets"):::frontend
    end

    subgraph "Backend"
        subgraph "Presentation Layer"
            C("Controllers"):::controllers
            G("GlobalControllerAdvice"):::advice
        end
        subgraph "Business Logic Layer"
            S("Services"):::services
            D("DTO & Mappers"):::dto
            U("UserSession Management"):::session
        end
        subgraph "Data Persistence Layer"
            R("Repositories"):::repositories
            P("Application Properties"):::config
        end
    end

    DB("MySQL Database\n(gymapp schema)"):::database

    %% Data Flow Arrows
    F1 -->|"HTTP_Request"| C
    F2 -->|"HTTP_Request"| C
    C -->|"calls"| S
    S -->|"uses"| R
    R -->|"CRUD"| DB
    S -->|"maps"| D
    C -->|"session"| U
    C -->|"error_handling"| G
    P -->|"DBConfig"| DB

    %% Click Events
    click F1 "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/tree/main/gymapp/src/main/resources/templates"
    click F2 "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/tree/main/gymapp/src/main/resources/static"
    click C "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/tree/main/gymapp/src/main/java/es/codeurjc/gymapp/controllers"
    click S "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/tree/main/gymapp/src/main/java/es/codeurjc/gymapp/services"
    click R "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/tree/main/gymapp/src/main/java/es/codeurjc/gymapp/repositories"
    click D "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/tree/main/gymapp/src/main/java/es/codeurjc/gymapp/DTO"
    click G "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/blob/main/gymapp/src/main/java/es/codeurjc/gymapp/GlobalControllerAdvice.java"
    click P "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/blob/main/gymapp/src/main/resources/application.properties"
    click U "https://github.com/ssdd-2025/practica-sistemas-distribuidos-2025-grupo-8/blob/main/gymapp/src/main/java/es/codeurjc/gymapp/model/UserSession.java"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef controllers fill:#FFCC99,stroke:#000,stroke-width:2px;
    classDef services fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef repositories fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef dto fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef advice fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef config fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef session fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef database fill:#FFA07A,stroke:#000,stroke-width:2px;
```
