# cavargas10/yummycreativefooc architecture

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

- Interactive diagram: https://gitdiagram.com/cavargas10/yummycreativefooc
- Repository: https://github.com/cavargas10/yummycreativefooc

## Overview

##### Project type and purpose
- This is a full-stack PHP/JavaScript web application called “YUMMYCreativeFood.” It provides:
- A public site for browsing recipes, tips and videos (“vistas_normal”)
- A user-authenticated experience (“vistas_usuario”)
- An admin/dashboard interface for managing content (“vistas_dashboard”)
- It uses a traditional LAMP-style stack (PHP + MySQL), with JavaScript, CSS and CKEditor for rich text editing.

##### File structure
- Top-level folders:
- css, img, imagenesReceta, imagenesTips, video – static assets
- dll – database connection and validation classes (class_mysqli.php, config.php, validar.php)
- ProyectoWeb/Recursos – CKEditor integration and build (webpack.config.js)
- internas – internal scripts (e.g., procesar.php)
- seguridad – session management (seguridad.php, exit.php)
- vistas_dashboard, vistas_normal, vistas_usuario – each follows MVC subfolders:
– controlador/ – PHP controllers
– modelo/ – PHP models
– vistas/ – PHP view templates
- Root entrypoint: index.php
- Database model file: modelo_BD.mwb (MySQL Workbench schema)

##### README
- The README only contains the project name, but the folder names and file organization imply the major architectural components listed above.

a. Main components:
- Web Client (Browser) – requests HTML/CSS/JS
- Frontend Static Server – serves CSS, JS, image, video assets
- PHP Application Server – hosts index.php, routes requests to controllers
– Public Site Controllers (“vistas_normal/controlador”)
– User Site Controllers (“vistas_usuario/controlador”)
– Dashboard Controllers (“vistas_dashboard/controlador”)
– Security Module (“seguridad/seguridad.php”)
– Internal Processing (“internas/procesar.php”)
- Business Logic – Models in each MVC module (“modelo/”)
- Data Access Layer – dll/class_mysqli.php for DB connections
- Relational Database – MySQL (schema in modelo_BD.mwb)
- External Library – CKEditor (ProyectoWeb/Recursos)

b. Relationships and interactions:
1. Browser → Frontend Static Server (CSS, JS, images)
2. Browser → index.php → Router identifies module (normal, user, dashboard)
3. Controller calls Model to fetch/update data
4. Model uses Data Access Layer (class_mysqli) → MySQL
5. Controller returns a View (PHP template) → rendered HTML → Browser
6. Security Module intercepts requests for protected pages (dashboard/user)
7. CKEditor assets loaded on recipe/tips edit forms

c. Architectural patterns and design principles:
- MVC separation per module (normal, user, dashboard)
- Single entrypoint (index.php) routing to different controllers
- Centralized database connection class (dll)
- Role-based access control via seguridad/seguridad.php
- Static assets served separately from PHP views

d. Key technologies and libraries:
- PHP 7+ with MySQLi
- MySQL database (modelo_BD.mwb)
- CKEditor (ProyectoWeb/Recursos) built via webpack
- HTML/CSS/JavaScript for views
- PHP session management for security

##### Detail
- MVC modules (normal, user, dashboard)
- Security module intercepting protected routes
- Static-asset server and Webpack/CKEditor build process
- Data flow for key use-cases (browse recipes, add recipe via dashboard, comment submission, profile update)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier" 
        direction TB
        Browser["Web Browser"]:::client-blue
    end

    %% Presentation Tier
    subgraph "Presentation Tier" 
        direction TB
        StaticServer["Static Asset Server"]:::present-blue
        CSS["CSS Files"]:::present-blue
        IMG["Images"]:::present-blue
        VIDEO["Videos"]:::present-blue
        StaticServer --> CSS
        StaticServer --> IMG
        StaticServer --> VIDEO
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        Entry["index.php (Router)"]:::logic-green
        Security["Security Module"]:::logic-green
        Internals["Internal Scripts"]:::logic-green
        subgraph "Public Module (vistas_normal)"
            direction TB
            PN_Controller["Public Controller"]:::logic-green
            PN_Model["Public Model"]:::logic-green
            PN_View["Public View"]:::present-blue
        end
        subgraph "User Module (vistas_usuario)"
            direction TB
            US_Controller["User Controller"]:::logic-green
            US_Model["User Model"]:::logic-green
            US_View["User View"]:::present-blue
        end
        subgraph "Dashboard Module (vistas_dashboard)"
            direction TB
            DB_Controller["Dashboard Controller"]:::logic-green
            DB_Model["Dashboard Model"]:::logic-green
            DB_View["Dashboard View"]:::present-blue
            DB_Styles["Dashboard Styles"]:::present-blue
            DB_View --> DB_Styles
        end
        subgraph "Data Access Layer"
            direction TB
            DBClass["class_mysqli.php"]:::data-orange
            Config["config.php"]:::data-orange
            Valid["validar.php"]:::data-orange
        end
        Entry --> PN_Controller
        Entry --> US_Controller
        Entry --> DB_Controller
        Entry --> Security
        Security --> US_Controller
        Security --> DB_Controller
        PN_Controller --> PN_Model
        US_Controller --> US_Model
        DB_Controller --> DB_Model
        PN_Model --> DBClass
        US_Model --> DBClass
        DB_Model --> DBClass
        Internals["procesar.php"]:::logic-green
        Internals --> DBClass
    end

    %% External Library
    subgraph "External Libraries"
        direction TB
        CKEditor["CKEditor"]:::external-purple
    end
    CKEditor --> PN_View
    CKEditor --> US_View
    CKEditor --> DB_View

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        MySQL["MySQL Database"]:::data-orange
        DBClass --> MySQL
    end

    %% Client to Server interactions
    Browser --> StaticServer
    Browser --> Entry

    %% Styles
    classDef client-blue fill:#D0E6FF,stroke:#1E90FF,color:#1E90FF;
    classDef present-blue fill:#E0F7FA,stroke:#00ACC1,color:#006064;
    classDef logic-green fill:#E8F5E9,stroke:#43A047,color:#2E7D32;
    classDef data-orange fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
    classDef external-purple fill:#F3E5F5,stroke:#8E24AA,color:#6A1B9A;

    %% Click Events
    click CSS "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/css/"
    click IMG "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/img/"
    click VIDEO "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/video/"
    click Entry "https://github.com/cavargas10/yummycreativefooc/blob/main/ProyectoWeb/index.php"
    click PN_Controller "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_normal/controlador/"
    click PN_Model "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_normal/modelo/"
    click PN_View "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_normal/vistas/"
    click US_Controller "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_usuario/controlador/"
    click US_Model "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_usuario/modelo/"
    click US_View "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_usuario/vistas/"
    click DB_Controller "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_dashboard/controlador/"
    click DB_Model "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_dashboard/modelo/"
    click DB_View "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_dashboard/vistas/"
    click DB_Styles "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/vistas_dashboard/estilos/"
    click Security "https://github.com/cavargas10/yummycreativefooc/blob/main/ProyectoWeb/seguridad/seguridad.php"
    click Internals "https://github.com/cavargas10/yummycreativefooc/blob/main/ProyectoWeb/internas/procesar.php"
    click DBClass "https://github.com/cavargas10/yummycreativefooc/blob/main/ProyectoWeb/dll/class_mysqli.php"
    click Config "https://github.com/cavargas10/yummycreativefooc/blob/main/ProyectoWeb/dll/config.php"
    click Valid "https://github.com/cavargas10/yummycreativefooc/blob/main/ProyectoWeb/dll/validar.php"
    click CKEditor "https://github.com/cavargas10/yummycreativefooc/tree/main/ProyectoWeb/ProyectoWeb/Recursos/"
    click MySQL "https://github.com/cavargas10/yummycreativefooc/blob/main/modelo_BD.mwb"
```
