# oscarcpc/tiendasql architecture

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

## Overview

##### Main Components
- User Interface (Presentation Layer): This includes pages such as index.php, login.php, menu.php, header.php, perfil.php, productos.php, pedidos.php, and others. The “estilos” (CSS) and “img” directories, along with “recursos/head.php”, indicate front-end resources that build the visual interface.
- Business Logic / Controller Layer: The various PHP scripts that perform operations (borrarPedidos.php, borrarProd.php, borrarUsuario.php, updatePedidos.php, updateProd.php, updateUser.php, etc.) together with the “functions” folder (e.g., functions/form.php) and the “class/DAO.php” file implement the core business logic and data handling.
- Data Storage (Persistence Layer): The MySQL folder (with bd.sql) represents the primary database schema, while the “csv” directory (with cesta.csv, productos.csv, usuarios.csv, etc.) shows data backups or alternative data sources.

##### Relationships and Interactions
- The controllers (or business logic scripts) rely on DAO methods (in the class folder) to perform data operations. These controllers should be shown as mediators between the interface and the database layer.

##### Architectural Patterns and Design Elements
- Although not a full MVC framework, the separation of interface (UI pages), logic (various PHP and DAO classes), and data (MySQL and CSV) suggests a layered architecture.
- The use of a dedicated DAO class indicates use of the Data Access Object pattern, encapsulating data interactions.
- That typical operations include user management (login.php, usuarios.php, borrarUsuario.php, updateUser.php), product management (productos.php, borrarProd.php, updateProd.php), and order management (pedidos.php, borrarPedidos.php, updatePedidos.php).

##### Technologies, Frameworks, or Libraries
- PHP for server-side scripting.
- MySQL as the primary database (represented by the MySQL folder and bd.sql).
- Basic front-end resources (HTML/CSS found in “estilos”) and possibly JavaScript if embedded within any HTML templates.
- NetBeans (as indicated by the nbproject folder), which provides standard configuration but can be omitted from the high-level architecture if focusing on runtime components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI1("index.php"):::presentation
        UI2("login.php"):::presentation
        UI3("menu.php"):::presentation
        UI4("header.php"):::presentation
        UI5("perfil.php"):::presentation
        UI6("pedidos.php"):::presentation
        UI7("productos.php"):::presentation
        UI8("rexistro.php"):::presentation
        UI9("logoff.php"):::presentation
        CSS1("bootCSS.css"):::frontendStatic
        CSS2("dark.css"):::frontendStatic
        CSS3("style.css"):::frontendStatic
        HT("Head Template (recursos/head.php)"):::presentation
        IMG("Image Assets (img)"):::frontendStatic
    end

    %% Business Logic / Controller Layer
    subgraph "Business Logic / Controller Layer"
        BL1("CRUD: borrarPedidos.php"):::business
        BL2("CRUD: borrarProd.php"):::business
        BL3("CRUD: borrarUsuario.php"):::business
        BL4("CRUD: updatePedidos.php"):::business
        BL5("CRUD: updateProd.php"):::business
        BL6("CRUD: updateUser.php"):::business
        DAO("DAO Class (DAO.php)"):::backendLogic
        FUNC("Form Functions (form.php)"):::backendLogic
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB("MySQL Schema (bd.sql)"):::database
        CSV1("CSV: cesta.csv"):::csvStyle
        CSV2("CSV: productos.csv"):::csvStyle
        CSV3("CSV: usuarios.csv"):::csvStyle
        CSV4("CSV Backup: usuarios.bak"):::csvStyle
    end

    %% Data Flow from Presentation to Business Logic (Client Requests)
    UI1 -->|"request"| DAO
    UI2 -->|"request"| DAO
    UI3 -->|"request"| DAO
    UI4 -->|"request"| DAO
    UI5 -->|"request"| DAO
    UI6 -->|"request"| DAO
    UI7 -->|"request"| DAO
    UI8 -->|"request"| DAO
    UI9 -->|"request"| DAO
    HT -->|"includes"| UI1

    %% Business Logic interactions with Persistence
    DAO -->|"CRUD operations"| DB
    DAO -->|"read/write"| CSV1
    DAO -->|"read/write"| CSV2
    DAO -->|"read/write"| CSV3
    DAO -->|"read/write"| CSV4
    FUNC -->|"supports"| DAO

    %% Return flows from Persistence to Business Logic, and then back to UI (Responses)
    DB -->|"data"| DAO
    CSV1 -->|"data"| DAO
    CSV2 -->|"data"| DAO
    CSV3 -->|"data"| DAO
    CSV4 -->|"data"| DAO
    DAO -->|"response"| UI1
    DAO -->|"response"| UI2
    DAO -->|"response"| UI3
    DAO -->|"response"| UI4
    DAO -->|"response"| UI5
    DAO -->|"response"| UI6
    DAO -->|"response"| UI7
    DAO -->|"response"| UI8
    DAO -->|"response"| UI9

    %% Click Events for Presentation Layer
    click UI1 "https://github.com/oscarcpc/tiendasql/blob/main/index.php"
    click UI2 "https://github.com/oscarcpc/tiendasql/blob/main/login.php"
    click UI3 "https://github.com/oscarcpc/tiendasql/blob/main/menu.php"
    click UI4 "https://github.com/oscarcpc/tiendasql/blob/main/header.php"
    click UI5 "https://github.com/oscarcpc/tiendasql/blob/main/perfil.php"
    click UI6 "https://github.com/oscarcpc/tiendasql/blob/main/pedidos.php"
    click UI7 "https://github.com/oscarcpc/tiendasql/blob/main/productos.php"
    click UI8 "https://github.com/oscarcpc/tiendasql/blob/main/rexistro.php"
    click UI9 "https://github.com/oscarcpc/tiendasql/blob/main/logoff.php"
    click CSS1 "https://github.com/oscarcpc/tiendasql/blob/main/estilos/bootCSS.css"
    click CSS2 "https://github.com/oscarcpc/tiendasql/blob/main/estilos/dark.css"
    click CSS3 "https://github.com/oscarcpc/tiendasql/blob/main/estilos/style.css"
    click HT "https://github.com/oscarcpc/tiendasql/blob/main/recursos/head.php"
    click IMG "https://github.com/oscarcpc/tiendasql/tree/main/img"

    %% Click Events for Business Logic / Controller Layer
    click BL1 "https://github.com/oscarcpc/tiendasql/blob/main/borrarPedidos.php"
    click BL2 "https://github.com/oscarcpc/tiendasql/blob/main/borrarProd.php"
    click BL3 "https://github.com/oscarcpc/tiendasql/blob/main/borrarUsuario.php"
    click BL4 "https://github.com/oscarcpc/tiendasql/blob/main/updatePedidos.php"
    click BL5 "https://github.com/oscarcpc/tiendasql/blob/main/updateProd.php"
    click BL6 "https://github.com/oscarcpc/tiendasql/blob/main/updateUser.php"
    click DAO "https://github.com/oscarcpc/tiendasql/blob/main/class/DAO.php"
    click FUNC "https://github.com/oscarcpc/tiendasql/blob/main/functions/form.php"

    %% Click Events for Persistence Layer
    click DB "https://github.com/oscarcpc/tiendasql/blob/main/MySQL/bd.sql"
    click CSV1 "https://github.com/oscarcpc/tiendasql/blob/main/csv/cesta.csv"
    click CSV2 "https://github.com/oscarcpc/tiendasql/blob/main/csv/productos.csv"
    click CSV3 "https://github.com/oscarcpc/tiendasql/blob/main/csv/usuarios.csv"
    click CSV4 "https://github.com/oscarcpc/tiendasql/blob/main/csv/usuarios.bak"

    %% Class Definitions for styling
    classDef presentation fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef frontendStatic fill:#aed6f1,stroke:#1b4f72,stroke-width:2px;
    classDef business fill:#fad7a0,stroke:#9c640c,stroke-width:2px;
    classDef backendLogic fill:#abebc6,stroke:#239b56,stroke-width:2px;
    classDef database fill:#f5b7b1,stroke:#922b21,stroke-width:2px,stroke-dasharray: 5 5;
    classDef csvStyle fill:#d5f5e3,stroke:#1e8449,stroke-width:2px,stroke-dasharray: 2 2;
    
    %% Additional representative flows to emphasize layered interaction
    UI1 ---|"initiates"| DAO
    DAO ---|"performs"| DB
    DB ---|"returns"| DAO
    DAO ---|"sends"| UI1
```
