# mikelgarduno/deustostream architecture

> Architecture diagram of the GitHub repository mikelgarduno/deustostream, 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/mikelgarduno/deustostream
- Repository: https://github.com/mikelgarduno/deustostream

## Overview

##### Main Components
- Frontend Layer: Represented by the Thymeleaf templates (HTML files in src/main/resources/templates) and static assets (CSS files within src/main/resources/static). This layer handles the presentation and user interactions.
- Backend Layer: The Spring Boot application is the core, encapsulated in the RestApiApplication.java file. This includes:
- Controllers (in the controller package, e.g., GenerosController.java, DeustoStreamController.java) that deal with HTTP requests.
- Services (in the service package, such as AuthService.java and DeustoStreamService.java) that encapsulate business logic.
- Repositories (in the repository package, e.g., PeliculaRepository.java, SerieRepository.java, UsuarioRepository.java) that interact with the MySQL database.
- Models (in the model package) that define the domain entities like Pelicula, Series, and Usuario.
- Configuration/Infrastructure Layer: Contains configuration files and interceptors (e.g., LoginInterceptor.java, WebConfig.java) that manage cross-cutting concerns like security and request routing.
- Database: MySQL, as set up by the dbsetup.sql script which creates a dedicated database (restapidb) and a user (spq) with the appropriate permissions.
- Integration/Client Components: Although less emphasized, the WebController in the client package indicates potential integrations or web-based client handling.

##### Relationships and Interactions
- Data Flow: Start with the user interacting with the frontend (web pages rendered with Thymeleaf) and making HTTP requests.
- Controllers receive these requests, invoke the service layer for processing, and fetch/modify data via the repository layer.
- Services implement business logic (such as authentication via AuthService) and manage data interactions.
- The repository layer, using JPA/Hibernate, communicates with the MySQL database.
- Configuration classes (LoginInterceptor and WebConfig) ensure secured and well-configured request processing.
- Also, note the initialization of data through the configuration class “inicializarDatos.java”.

##### Architectural Patterns and Design Principles
- Layered Architecture (Separation of Concerns): Clearly divided among controllers, services, and repositories.
- MVC Pattern: The Spring Boot project leverages MVC with controllers and Thymeleaf templates.
- Dependency Injection and Inversion of Control: Handled by Spring Boot’s core functionalities.
- RESTful API Principles: Controllers may expose REST endpoints for various operations.

##### Relevant Technologies to Highlight
- Java and Spring Boot for the application framework.
- MySQL as the database for persistent storage.
- Maven for dependency management and build automation.
- JPA/Hibernate for the ORM layer.
- Thymeleaf for server-side view rendering.
- Testing components (present in src/test) for ensuring quality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User("User"):::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1("Thymeleaf Templates"):::frontend
        FE2("Static Assets"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        APP("RestApiApplication"):::backend

        subgraph "Controllers"
            DSC("DeustoStreamController"):::backend
            GC("GenerosController"):::backend
        end

        subgraph "Services"
            AS("AuthService"):::backend
            DS("DeustoStreamService"):::backend
        end

        subgraph "Repositories"
            PR("PeliculaRepository"):::backend
            SR("SerieRepository"):::backend
            UR("UsuarioRepository"):::backend
        end

        subgraph "Domain Models"
            Models("Model Directory"):::backend
        end

        subgraph "Configuration/Interceptors"
            LI("LoginInterceptor"):::config
            WC("WebConfig"):::config
            ID("inicializarDatos"):::config
        end

        subgraph "Integration/Client"
            WC2("WebController"):::backend
        end
    end

    %% Database
    DB("MySQL Database"):::database
    DBSetup("dbsetup.sql"):::database

    %% Maven Build (Operational)
    Maven("Maven Build/Packaging"):::config

    %% Data Flow Connections
    User -->|"interacts"| FE1
    User -->|"loads assets"| FE2
    FE1 -->|"renders requests"| APP
    FE2 -->|"supports UI"| APP
    APP -->|"receives HTTP request"| DSC
    APP -->|"receives HTTP request"| GC
    DSC -->|"calls"| AS
    GC -->|"calls"| AS
    AS -->|"invokes"| DS
    DS -->|"accesses data via"| PR
    DS -->|"accesses data via"| SR
    DS -->|"accesses data via"| UR
    PR -->|"queries/updates"| DB
    SR -->|"queries/updates"| DB
    UR -->|"queries/updates"| DB
    WC -->|"configures"| DSC
    LI -->|"intercepts"| DSC
    ID -->|"initializes"| Models
    WC2 -->|"handles integration"| APP
    DBSetup -->|"sets up database"| DB
    Maven -->|"builds"| APP

    %% Click Events
    click FE1 "https://github.com/mikelgarduno/deustostream/tree/main/src/main/resources/templates"
    click FE2 "https://github.com/mikelgarduno/deustostream/tree/main/src/main/resources/static"
    click APP "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/RestApiApplication.java"
    click DSC "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/controller/DeustoStreamController.java"
    click GC "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/controller/GenerosController.java"
    click AS "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/service/AuthService.java"
    click DS "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/service/DeustoStreamService.java"
    click PR "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/repository/PeliculaRepository.java"
    click SR "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/repository/SerieRepository.java"
    click UR "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/repository/UsuarioRepository.java"
    click Models "https://github.com/mikelgarduno/deustostream/tree/main/src/main/java/com/example/restapi/model"
    click LI "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/config/LoginInterceptor.java"
    click WC "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/config/WebConfig.java"
    click ID "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/config/inicializarDatos.java"
    click DBSetup "https://github.com/mikelgarduno/deustostream/blob/main/src/main/resources/dbsetup.sql"
    click WC2 "https://github.com/mikelgarduno/deustostream/blob/main/src/main/java/com/example/restapi/client/WebController.java"

    %% Styles
    classDef external fill:#FFEB99,stroke:#333,stroke-width:2px;
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#D5F5E3,stroke:#117864,stroke-width:2px;
    classDef config fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
