# jalfalc/tfg-thebeast architecture

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

- Interactive diagram: https://gitdiagram.com/jalfalc/tfg-thebeast
- Repository: https://github.com/jalfalc/tfg-thebeast

## Overview

##### Project type and purpose
- This is a PHP-based full-stack MVC web application (“TFG-TheBeast”) for user registration/login and booking/reservation of services (e.g., facial cleaning).
- Key features: user registration, login/logout, viewing services, making and editing reservations, listing user’s own reservations.

##### File structure
- Top-level directories:
- BBDD: contains database schema (database.sql) for MySQL.
- src: the entire MVC application, subdivided into Controller, Model, View, plus static assets (css, js, img).
- notas: contains project notes.
- Controllers (src/Controller): one controller per route/page (Login, Logout, Registro, Servicios, Reservas, MisReservas, EditarReserva, Verify, Principal).
- Models (src/Model):
- DAO/Conexion.php – database connection setup.
- DAO/MySqlDAO.php – generic data-access implementation.
- Usuario.php – user entity.
- Views (src/View): per-page PHP templates and shared header/footer sub-folders.
- Static assets: organized under src/css and src/js by feature/folder, plus img directory at project root.
- Entry point: src/index.php routes incoming requests to the appropriate controller.

##### README for additional insights
- Contains notes on path-resolution issues for CSS/JS/images when index.php is entry point.

a. Main components
1) Client Browser – renders HTML/CSS/JS, initiates HTTP requests.
2) Web Server & PHP Runtime – Apache/Nginx+PHP-FPM serving index.php.
3) MVC Layers:
- Router / Front Controller (index.php)
- Controllers – handle requests, invoke models, choose views
- Models / DAO – execute SQL against MySQL via Conexion and MySqlDAO
- Views – render HTML with CSS/JS assets
4) Static Assets – CSS, JS, images served either by web server directly or via PHP.
5) Database – MySQL instance initialized by BBDD/database.sql.
b. Relationships & interactions
- Browser → HTTP GET/POST → Web Server → index.php
- index.php → dispatch → appropriate Controller
- Controller → calls Model/DAO → Database
- Model → returns data → Controller → passes to View
- View → embeds static asset links → generates HTML → Response → Browser
- Static asset requests (CSS/JS/img) → Web Server → served directly
c. Architectural patterns & design principles
- MVC pattern separates concerns (routing/controllers, business logic/models, presentation/views).
- DAO pattern abstracts database operations.
- Single entry point (Front Controller) centralizes routing.
d. Technologies & frameworks
- PHP (7.x/8.x), MySQL, HTML5, CSS3, Vanilla JS.

##### Detail level
- Index.php as the entry point router that dispatches to Controllers.
- Path-resolution issues near static assets to highlight deployment considerations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Tier
    subgraph "Presentation Tier"
        Browser["Client Browser"]:::frontend
        StaticAssets["Static Assets\n(CSS/JS/Images)"]:::frontend
    end

    %% Application Tier
    subgraph "Application Tier"
        WebServer["Web Server + PHP-FPM"]:::app
        Router["Front Controller\nindex.php"]:::app

        subgraph "Controllers"
            LoginCtrl["Login_Controller"]:::app
            LogoutCtrl["Logout_Controller"]:::app
            RegistroCtrl["Registro_Controller"]:::app
            ServiciosCtrl["Servicios_Controller"]:::app
            ReservasCtrl["Reservas_Controller"]:::app
            MisReservasCtrl["MisReservas_Controller"]:::app
            PrincipalCtrl["Principal_Controller"]:::app
            VerifyCtrl["Verify_Controller"]:::app
        end

        subgraph "Models / DAO"
            Conexion["DAO/Conexion"]:::app
            MySqlDAO["DAO/MySqlDAO"]:::app
            Usuario["Usuario Entity"]:::app
        end

        subgraph "Views"
            HeaderV["Header_View"]:::frontend
            FooterV["Footer_View"]:::frontend
            LoginV["Login_View"]:::frontend
            RegistroV["Registro_View"]:::frontend
            ServiciosV["Servicios_View"]:::frontend
            ReservasV["Reservas_View"]:::frontend
            MisReservasV["MisReservas_View"]:::frontend
            EditarReservaV["EditarReserva_View"]:::frontend
            PrincipalV["Principal_View"]:::frontend
        end
    end

    %% Data Tier
    subgraph "Data Tier"
        Database[(MySQL Database)]:::data
        Schema["Database Schema"]:::data
    end

    %% Documentation
    subgraph "Documentation"
        README["README.md"]:::app
        Notes["Project Notes"]:::app
    end

    %% Connections
    Browser -->|HTTP GET/POST| WebServer
    Browser -->|Requests assets| StaticAssets
    StaticAssets --> WebServer
    WebServer --> Router
    Router --> LoginCtrl
    Router --> LogoutCtrl
    Router --> RegistroCtrl
    Router --> ServiciosCtrl
    Router --> ReservasCtrl
    Router --> MisReservasCtrl
    Router --> PrincipalCtrl
    Router --> VerifyCtrl

    %% Controllers to Models
    LoginCtrl --> Conexion
    LogoutCtrl --> Conexion
    RegistroCtrl --> Conexion
    ServiciosCtrl --> Conexion
    ReservasCtrl --> Conexion
    MisReservasCtrl --> Conexion
    PrincipalCtrl --> Conexion
    VerifyCtrl --> Conexion

    Conexion --> MySqlDAO
    MySqlDAO --> Database
    Schema --> Database

    %% Controllers to Views
    LoginCtrl --> LoginV
    RegistroCtrl --> RegistroV
    ServiciosCtrl --> ServiciosV
    ReservasCtrl --> ReservasV
    MisReservasCtrl --> MisReservasV
    PrincipalCtrl --> PrincipalV
    VerifyCtrl --> HeaderV
    LogoutCtrl --> FooterV
    EditarReservaV --> ReservasCtrl

    %% Views to Browser
    LoginV --> Browser
    RegistroV --> Browser
    ServiciosV --> Browser
    ReservasV --> Browser
    MisReservasV --> Browser
    PrincipalV --> Browser
    HeaderV --> Browser
    FooterV --> Browser

    %% Documentation to nothing

    %% Click Events
    click Schema "https://github.com/jalfalc/tfg-thebeast/blob/main/BBDD/database.sql"
    click Router "https://github.com/jalfalc/tfg-thebeast/blob/main/src/index.php"
    click LoginCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/Login_Controller.php"
    click LogoutCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/Logout_Controller.php"
    click RegistroCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/Registro_Controller.php"
    click ServiciosCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/Servicios_Controller.php"
    click ReservasCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/Reservas_Controller.php"
    click MisReservasCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/MisReservas_Controller.php"
    click PrincipalCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/Principal_Controller.php"
    click VerifyCtrl "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Controller/Verify_Controller.php"
    click Conexion "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Model/DAO/Conexion.php"
    click MySqlDAO "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Model/DAO/MySqlDAO.php"
    click Usuario "https://github.com/jalfalc/tfg-thebeast/blob/main/src/Model/Usuario.php"
    click HeaderV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/Header/Header_View.php"
    click FooterV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/Footer/Footer_View.php"
    click LoginV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/Login_View.php"
    click RegistroV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/Registro_View.php"
    click ServiciosV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/Servicios_View.php"
    click ReservasV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/Reservas_View.php"
    click MisReservasV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/MisReservas_View.php"
    click EditarReservaV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/EditarReserva_View.php"
    click PrincipalV "https://github.com/jalfalc/tfg-thebeast/blob/main/src/View/Principal_View.php"
    click README "https://github.com/jalfalc/tfg-thebeast/blob/main/README.md"
    click Notes "https://github.com/jalfalc/tfg-thebeast/blob/main/notas/notas.md"

    %% Styles
    classDef frontend fill:#a2d2ff,stroke:#023e8a,color:#023e8a
    classDef app fill:#b7e4c7,stroke:#2d6a4f,color:#2d6a4f
    classDef data fill:#ffd6a5,stroke:#e85d04,color:#e85d04
```
