# herberthreyes07/ts1-hola-mundo architecture

> Architecture diagram of the GitHub repository herberthreyes07/ts1-hola-mundo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/herberthreyes07/ts1-hola-mundo
- Repository: https://github.com/herberthreyes07/ts1-hola-mundo

## Overview

##### Project type and purpose
- This is a full-stack PHP web application implementing an online video-game store.
- It follows a classic MVC pattern:
- app/controllers – HTTP request handlers
- app/models – data structures
- app/views – HTML/PHP templates
- app/dao – persistence logic
- public – web-accessible entry points and static assets

##### File structure
- Top-level:
- app/ — application core
- app/config/database.php holds DB credentials; app/core/DatabaseConnection.php wraps PDO/MySQLi.
- Controllers are grouped by role: AdminController, AuthController, CashierController, CustomerController, UserController.
- DAOs: one per entity (VideoGameDAO, UserDAO, etc.), plus join-table DAOs (VideoGameGenreDAO).
- Views reflect MVC: subfolders by role (admin/, auth/, cashier/, customer/, user/) and global layouts.
- Utilities: app/utils/Validations.php for input checks.

##### README for additional insights
- The app runs under XAMPP (Apache + MySQL).
- DB setup scripts are in /db (not shown in file_tree) but key to persistence.
- Entry URL: http://localhost/miproyecto/public.

##### Main components
a. Presentation Layer
- Browser / Client
- Web Server (Apache via XAMPP)
- public/*.php entry scripts
- Static assets (CSS, JS, images)
b. Application Layer
- Front Controller / Router (public/index.php et al)
- Controllers (app/controllers/)
- Validation (app/utils/Validations.php)
c. Business & Persistence Layer
- Models (app/models/)
- Data Access Objects (app/dao/)
- DatabaseConnection (app/core/)
- MySQL Database
d. External Services
- (Optional) GitDiagram link for documentation

##### Relationships & data flow
1. Client → HTTP Request → public/*.php
2. Entry script loads app/config, core, routes to the appropriate Controller
3. Controller performs Validations → invokes DAO methods
4. DAO uses DatabaseConnection to execute SQL against MySQL
5. DAO returns Model objects to Controller
6. Controller passes Models to Views
7. Views rendered into HTML → Response back to Client
8. Static asset requests served directly by Apache

##### Architectural patterns & design principles
- MVC separation: clear layers for controllers, views, models
- Single Responsibility: each DAO handles one entity
- Reusable core component: DatabaseConnection
- Folder-based modularity by user role (admin, cashier, customer, user)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Browser"]:::client
        Apache["Apache (XAMPP)"]:::infrastructure
        subgraph "Entry Points"
            direction TB
            Index["index.php"]:::entry
            AdminEntry["admin.php"]:::entry
            CashierEntry["cashier.php"]:::entry
            CustomerEntry["customer.php"]:::entry
        end
        subgraph "Static Assets"
            direction TB
            CSS["CSS (styles.css)"]:::static
            IMG["Images"]:::static
            ICON["Icons"]:::static
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Router["Front Controller / Router"]:::application
        subgraph "Controllers (app/controllers)"
            direction TB
            AdminCtrl["AdminController"]:::controllers
            AuthCtrl["AuthController"]:::controllers
            CashierCtrl["CashierController"]:::controllers
            CustomerCtrl["CustomerController"]:::controllers
            UserCtrl["UserController"]:::controllers
        end
        Validations["Validations"]:::utility
    end

    %% Business & Persistence Layer
    subgraph "Business & Persistence Layer"
        direction TB
        subgraph "Models (app/models)"
            direction TB
            DigitalCodeModel["DigitalCode"]:::models
            GenreModel["Genre"]:::models
            PlatformModel["Platform"]:::models
            UserModel["User"]:::models
            VideoGameModel["VideoGame"]:::models
            VideoGamePlatformModel["VideoGamePlatform"]:::models
        end
        subgraph "DAOs (app/dao)"
            direction TB
            DigitalCodeDAO["DigitalCodeDAO"]:::daos
            GenreDAO["GenreDAO"]:::daos
            PlatformDAO["PlatformDAO"]:::daos
            UserDAO["UserDAO"]:::daos
            VideoGameDAO["VideoGameDAO"]:::daos
            VideoGameGenreDAO["VideoGameGenreDAO"]:::daos
            VideoGamePlatformDAO["VideoGamePlatformDAO"]:::daos
        end
        DBConn["DatabaseConnection"]:::core
        Config["database.php"]:::config
        MySQL["MySQL Database"]:::database
    end

    %% External Documentation
    GitDoc["GitDiagram Documentation"]:::external

    %% Connections
    Browser -->|"HTTP Request"| Apache
    Browser -->|"Requests assets"| CSS
    Browser --> IMG
    Browser --> ICON

    Apache --> Index
    Apache --> AdminEntry
    Apache --> CashierEntry
    Apache --> CustomerEntry

    Index --> Router
    AdminEntry --> Router
    CashierEntry --> Router
    CustomerEntry --> Router

    Router --> AdminCtrl
    Router --> AuthCtrl
    Router --> CashierCtrl
    Router --> CustomerCtrl
    Router --> UserCtrl

    AdminCtrl --> Validations
    AuthCtrl --> Validations
    CashierCtrl --> Validations
    CustomerCtrl --> Validations
    UserCtrl --> Validations

    AdminCtrl --> DigitalCodeDAO
    AdminCtrl --> GenreDAO
    AdminCtrl --> PlatformDAO
    AdminCtrl --> UserDAO
    AdminCtrl --> VideoGameDAO
    AdminCtrl --> VideoGameGenreDAO
    AdminCtrl --> VideoGamePlatformDAO

    AuthCtrl --> UserDAO
    CashierCtrl --> VideoGameDAO
    CashierCtrl --> VideoGamePlatformDAO
    CustomerCtrl --> VideoGameDAO
    CustomerCtrl --> VideoGameGenreDAO
    UserCtrl --> UserDAO

    DigitalCodeDAO --> DBConn
    GenreDAO --> DBConn
    PlatformDAO --> DBConn
    UserDAO --> DBConn
    VideoGameDAO --> DBConn
    VideoGameGenreDAO --> DBConn
    VideoGamePlatformDAO --> DBConn

    DBConn --> MySQL
    Config --> DBConn

    DigitalCodeDAO --> DigitalCodeModel
    GenreDAO --> GenreModel
    PlatformDAO --> PlatformModel
    UserDAO --> UserModel
    VideoGameDAO --> VideoGameModel
    VideoGamePlatformDAO --> VideoGamePlatformModel
    VideoGameGenreDAO --> GenreModel

    AdminCtrl -->|"renders"| Views
    AuthCtrl --> Views
    CashierCtrl --> Views
    CustomerCtrl --> Views
    UserCtrl --> Views
    Views --> Browser

    GitDoc --> Router

    %% Click Events
    click Index "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/public/index.php"
    click AdminEntry "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/public/admin.php"
    click CashierEntry "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/public/cashier.php"
    click CustomerEntry "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/public/customer.php"
    click CSS "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/public/css/styles.css"
    click IMG "https://github.com/herberthreyes07/ts1-hola-mundo/tree/main/public/img/"
    click ICON "https://github.com/herberthreyes07/ts1-hola-mundo/tree/main/public/icons/"
    click AdminCtrl "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/controllers/AdminController.php"
    click AuthCtrl "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/controllers/AuthController.php"
    click CashierCtrl "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/controllers/CashierController.php"
    click CustomerCtrl "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/controllers/CustomerController.php"
    click UserCtrl "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/controllers/UserController.php"
    click Validations "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/utils/Validations.php"
    click DigitalCodeModel "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/models/DigitalCode.php"
    click GenreModel "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/models/Genre.php"
    click PlatformModel "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/models/Platform.php"
    click UserModel "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/models/User.php"
    click VideoGameModel "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/models/VideoGame.php"
    click VideoGamePlatformModel "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/models/VideoGamePlatform.php"
    click DigitalCodeDAO "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/dao/DigitalCodeDAO.php"
    click GenreDAO "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/dao/GenreDAO.php"
    click PlatformDAO "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/dao/PlatformDAO.php"
    click UserDAO "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/dao/UserDAO.php"
    click VideoGameDAO "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/dao/VideoGameDAO.php"
    click VideoGameGenreDAO "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/dao/VideoGameGenreDAO.php"
    click VideoGamePlatformDAO "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/dao/VideoGamePlatformDAO.php"
    click DBConn "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/core/DatabaseConnection.php"
    click Config "https://github.com/herberthreyes07/ts1-hola-mundo/blob/main/app/config/database.php"

    %% Styles
    classDef client fill:#E0F7FA,stroke:#006064;
    classDef infrastructure fill:#ECEFF1,stroke:#607D8B;
    classDef entry fill:#CFD8DC,stroke:#546E7A;
    classDef static fill:#FFF3E0,stroke:#FB8C00;
    classDef application fill:#E3F2FD,stroke:#1E88E5;
    classDef controllers fill:#BBDEFB,stroke:#2196F3;
    classDef utility fill:#FFF9C4,stroke:#FBC02D;
    classDef models fill:#C8E6C9,stroke:#388E3C;
    classDef daos fill:#A5D6A7,stroke:#43A047;
    classDef core fill:#DCEDC8,stroke:#558B2F;
    classDef config fill:#F0F4C3,stroke:#A1887F;
    classDef database fill:#FFCDD2,stroke:#D32F2F;
    classDef external fill:#E1BEE7,stroke:#8E24AA;
```
