# codeurjc-daw-2024-25/webapp12 architecture

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

- Interactive diagram: https://gitdiagram.com/codeurjc-daw-2024-25/webapp12
- Repository: https://github.com/codeurjc-daw-2024-25/webapp12

## Overview

- Client/UI Layer:
- Browsers/Clients: Represent front-end users, including non registered users, registered users, and administrators.
- Front-end Assets: Illustrate that the presentation layer is served using Thymeleaf templates and static resources (CSS, JS, images).
- Backend Application Server:
- Controllers: Group all web controllers, REST controllers, and API endpoints (e.g., ActivityRestController, UserRestController, ReviewRestController, etc.).
- Services: Represent the business logic layer (e.g., ActivityService, UserService, EmailService, Recommendation algorithm).
- Repositories: Show the data access layer that interacts directly with the database (ActivityRepository, ReviewRepository, UserRepository, etc.).
- Security Module:
- CSRF and RepositoryUserDetails services.
- Database:
- External Services and Tools:
- Email SMTP: Show the integration with Gmail’s SMTP server for sending emails.
- PDF Generation: Mention the component responsible for generating PDFs upon activity enrollment.
- API Documentation: Represent the API docs (api-docs.yaml / api-docs.html) accessible externally.

##### Relationships and Data Flow
- Within the backend, map the flow:
– Controllers receive incoming requests and delegate tasks to the appropriate Service layers.
– Services process the business logic (including interactions with security, email, PDF generation, and recommendation algorithms).
– Services then interact with the Repository layer to persist or retrieve data from the MySQL database.
- That the Security Module (JWT filtering and authentication checks) runs before requests reach sensitive areas of the Controllers.
- That static assets (stored under the ‘static’ and ‘templates’ directories) are served as web pages.
- Integration with external SMTP for email notifications and with Docker for deployment.

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate components into presentation, business, data and security layers.
- RESTful API: Show that the backend exposes endpoints that follow REST conventions.
- Security by Design: Emphasize the use of JWT and Spring Security to handle authentication and authorization.
- Containerization: Illustrate how Docker and Docker Compose are used to build and run the application, facilitating easy deployment.
- MVC for Web Pages: Indicate that the front-end pages utilize the MVC structure (with controllers handling requests, templates rendering views, and static assets supporting the UI).

##### Detail and Clarity
- Be meticulous in capturing every key module described above.
- Don’t hesitate to break down larger components (like the backend) into sub-components if needed.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client/UI Layer
    subgraph "Client/UI Layer"
        Browser["Browser (User)"]:::frontend
        Thymeleaf_Templates["Thymeleaf Templates"]:::frontend
        Static_Resources["Static Resources"]:::frontend
    end

    %% Docker Container wrapping the Backend Application Server
    subgraph "Docker Container (Spring Boot App)"
        subgraph "Backend Application Server"
            %% Controllers
            subgraph "Controllers"
                Standard_Web_Controllers["Standard Web Controllers"]:::backend
                REST_API_Controllers["REST API Controllers"]:::backend
                Authentication_Controller["Authentication Controller"]:::backend
            end
            %% Services
            subgraph "Services"
                Business_Logic_Services["Business Logic Services"]:::backend
                Additional_Services["Additional Services"]:::backend
            end
            %% Repositories
            subgraph "Repositories"
                Repositories["Data Access Repositories"]:::backend
            end
            %% Security Module
            subgraph "Security Module"
                Spring_Security["Spring Security & CSRF"]:::security
                JWT_Components["JWT Components"]:::security
            end
        end
        Docker_Config["Docker Configuration"]:::container
    end

    %% External Integrations & Tools
    subgraph "External Services"
        Email_Service["Email Service"]:::external
        PDF_Generation["PDF Generation"]:::external
        API_Documentation["API Documentation"]:::external
    end

    %% Database
    MySQL_Database["MySQL Database (Pixel_Paradise)"]:::database

    %% Data Flow
    Browser -->|"loads"| Thymeleaf_Templates
    Browser -->|"loads"| Static_Resources
    Browser -->|"HTTP_Request"| JWT_Components
    JWT_Components -->|"authorize"| Standard_Web_Controllers
    JWT_Components -->|"authorize"| REST_API_Controllers
    JWT_Components -->|"authorize"| Authentication_Controller

    Standard_Web_Controllers -->|"delegate"| Business_Logic_Services
    REST_API_Controllers -->|"delegate"| Business_Logic_Services
    Authentication_Controller -->|"delegate"| Business_Logic_Services

    Business_Logic_Services -->|"calls"| Repositories
    Additional_Services -->|"calls"| Repositories
    Repositories -->|"CRUD"| MySQL_Database

    Business_Logic_Services -->|"triggers"| Email_Service
    Business_Logic_Services -->|"generates"| PDF_Generation

    Browser -->|"accesses"| API_Documentation

    %% Styles
    classDef frontend fill:#d3e4cd,stroke:#333,stroke-width:2px;
    classDef backend fill:#c9d6e3,stroke:#333,stroke-width:2px;
    classDef security fill:#f7cac9,stroke:#333,stroke-width:2px;
    classDef database fill:#f2b8a0,stroke:#333,stroke-width:2px;
    classDef external fill:#fefbd8,stroke:#333,stroke-width:2px;
    classDef container fill:#c1d6fa,stroke:#333,stroke-width:2px;

    %% Click Events
    click Thymeleaf_Templates "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/resources/templates"
    click Static_Resources "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/resources/static"
    click Standard_Web_Controllers "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/java/es/codeurjc/backend/Controllers"
    click REST_API_Controllers "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/java/es/codeurjc/backend/rest"
    click Authentication_Controller "https://github.com/codeurjc-daw-2024-25/webapp12/blob/main/src/main/backend/src/main/java/es/codeurjc/backend/auth/LoginController.java"
    click Business_Logic_Services "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/java/es/codeurjc/backend/Service"
    click Additional_Services "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/java/es/codeurjc/backend/service"
    click Repositories "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/java/es/codeurjc/backend/Repository"
    click Spring_Security "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/java/es/codeurjc/backend/Security"
    click JWT_Components "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/src/main/java/es/codeurjc/backend/security/jwt"
    click Email_Service "https://github.com/codeurjc-daw-2024-25/webapp12/blob/main/src/main/backend/src/main/java/es/codeurjc/backend/Service/EmailService.java"
    click API_Documentation "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/api-docs"
    click Docker_Config "https://github.com/codeurjc-daw-2024-25/webapp12/tree/main/src/main/backend/docker"
```
