# seb4s-dl/tienda-perfumes architecture

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

- Interactive diagram: https://gitdiagram.com/seb4s-dl/tienda-perfumes
- Repository: https://github.com/seb4s-dl/tienda-perfumes

## Overview

##### Project type and purpose
- This is a monolithic, full-stack PHP e-commerce application (“Tienda-Perfumes”) that provides an online storefront for browsing products, managing a shopping cart, processing orders, and administering products/orders.

##### File structure
- Top-level dirs:
- assets/ (CSS, images) – static frontend resources
- js/ (JavaScript) – client-side logic for cart interactions, order management
- pages/ (PHP view templates + controllers) – renders HTML pages
- backend/ (PHP API scripts) – AJAX endpoints for CRUD and business logic
- includes/ (header, footer, session validation) – shared UI fragments & auth checks
- db/ (db connection, SQL dumps) – MySQL schema & connection utility
- uploads/ – persistent storage for uploaded product images
- index.php – entry point routing to pages/
- db/db.php – encapsulates database connection

##### README
- Minimal (“# Tienda-Perfumes”), so we infer purpose from file names and folder organization.

##### Components
a. Main components
1. Client (Web Browser)
2. Web Server + PHP Application
– Static Asset Server (serves assets/css & assets/img)
– PHP View Layer (pages/*.php + includes/)
– PHP API Layer (backend/*.php)
3. Database (MySQL)
4. File Storage (uploads/)
b. Relationships and interactions
- Browser requests HTML via index.php → pages/*.php (with header/footer)
- Browser loads CSS/JS/images directly from assets/
- pages/*.php issue SQL queries via db/db.php to MySQL
- Client-side JavaScript calls backend/*.php endpoints for operations (add to cart, register, login, CRUD)
- Backend scripts read/write to MySQL and upload/delete files in uploads/
c. Architectural patterns and design principles
- Monolithic PHP MVC-like structure (pages = view+controller, backend = API endpoints, includes = shared components)
- Separation of concerns: static assets vs view templates vs business logic vs data persistence
- REST-ish endpoints for AJAX interactions (e.g., carrito.php, listar_productos.php)
d. Technologies & frameworks
- PHP 7+ (plain PHP files, no framework)
- MySQL (SQL scripts in db/)
- HTML/CSS (assets/css)
- JavaScript (vanilla, AJAX calls in js/)
- Apache/Nginx (assumed web server)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Web Browser"]:::client
        AssetsCSS["assets/css/"]:::asset
        AssetsIMG["assets/img/"]:::asset
        JS["js/"]:::asset
    end

    %% Server Layer
    subgraph "Web Server / PHP Application"
        direction TB

        subgraph "Presentation Layer"
            direction TB
            Index["index.php"]:::server
            Header["includes/header.php"]:::view
            Footer["includes/footer.php"]:::view
            SessionVal["includes/validarSession.php"]:::view
            Pages["pages/"]:::view
        end

        subgraph "API Layer"
            direction TB
            subgraph "Auth & Session"
                Login["login.php"]:::api
                Register["register.php"]:::api
                Logout["logout.php"]:::api
            end
            subgraph "Cart & Orders"
                CartAPI["carrito.php"]:::api
                ProcessOrder["procesarPedido.php"]:::api
                MyOrders["mis_pedidos.php"]:::api
                GetOrders["obtener_pedidos.php"]:::api
                ChangeStatus["cambiar_estado_pedido.php"]:::api
                EmptyCart["vaciarCarrito.php"]:::api
                DetailOrder["detailPedido.php"]:::api
                GetDetail["obtener_detalle_pedido.php"]:::api
            end
            subgraph "Product Management"
                List1["listar_productos.php"]:::api
                List2["listar_productos2.php"]:::api
                UpdateProd["actualizar_producto.php"]:::api
                DeleteProd["eliminar_producto.php"]:::api
                ProductAPI["producto.php"]:::api
                PedidoAPI["pedido.php"]:::api
                CategoriesAPI["mostrarCategorias.php"]:::api
                ShowImage["mostrarimagen.php"]:::api
                SearchAPI["busqueda.php"]:::api
            end
            DBConn["db/db.php"]:::server
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        MySQL["MySQL Database"]:::db
        Uploads["uploads/"]:::storage
    end

    %% Connections
    Browser -->|HTTP GET| Index
    Browser -->|GET assets| AssetsCSS
    Browser -->|GET assets| AssetsIMG
    Browser -->|GET JS| JS
    Index -->|includes| Header
    Index -->|includes| Footer
    Index -->|session check| SessionVal
    Index -->|routes to| Pages
    Pages -->|SQL queries via| DBConn
    JS -->|AJAX calls| CartAPI
    JS -->|AJAX calls| ProcessOrder
    JS -->|AJAX calls| Login
    JS -->|AJAX calls| Register
    CartAPI -->|reads/writes| DBConn
    ProcessOrder -->|reads/writes| DBConn
    Login -->|reads/writes| DBConn
    Logout -->|reads/writes| DBConn
    List1 -->|reads/writes| DBConn
    UpdateProd -->|reads/writes| DBConn
    DeleteProd -->|reads/writes| DBConn
    ProductAPI -->|reads/writes| DBConn
    CategoriesAPI -->|reads/writes| DBConn
    ShowImage -->|reads image| Uploads
    DeleteProd -->|deletes image| Uploads
    DBConn -->|connects to| MySQL

    %% Click Events
    click AssetsCSS "https://github.com/seb4s-dl/tienda-perfumes/tree/main/assets/css/"
    click AssetsIMG "https://github.com/seb4s-dl/tienda-perfumes/tree/main/assets/img/"
    click JS "https://github.com/seb4s-dl/tienda-perfumes/tree/main/js/"
    click Index "https://github.com/seb4s-dl/tienda-perfumes/blob/main/index.php"
    click Header "https://github.com/seb4s-dl/tienda-perfumes/blob/main/includes/header.php"
    click Footer "https://github.com/seb4s-dl/tienda-perfumes/blob/main/includes/footer.php"
    click SessionVal "https://github.com/seb4s-dl/tienda-perfumes/blob/main/includes/validarSession.php"
    click Pages "https://github.com/seb4s-dl/tienda-perfumes/tree/main/pages/"
    click Login "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/login.php"
    click Register "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/register.php"
    click Logout "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/logout.php"
    click CartAPI "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/carrito.php"
    click ProcessOrder "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/procesarPedido.php"
    click MyOrders "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/mis_pedidos.php"
    click GetOrders "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/obtener_pedidos.php"
    click ChangeStatus "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/cambiar_estado_pedido.php"
    click EmptyCart "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/vaciarCarrito.php"
    click DetailOrder "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/detailPedido.php"
    click GetDetail "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/obtener_detalle_pedido.php"
    click List1 "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/listar_productos.php"
    click List2 "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/listar_productos2.php"
    click UpdateProd "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/actualizar_producto.php"
    click DeleteProd "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/eliminar_producto.php"
    click ProductAPI "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/producto.php"
    click PedidoAPI "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/pedido.php"
    click CategoriesAPI "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/mostrarCategorias.php"
    click ShowImage "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/mostrarimagen.php"
    click SearchAPI "https://github.com/seb4s-dl/tienda-perfumes/blob/main/backend/busqueda.php"
    click DBConn "https://github.com/seb4s-dl/tienda-perfumes/blob/main/db/db.php"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px
    classDef asset fill:#ccc,stroke:#333,stroke-width:1px
    classDef server fill:#b3d9ff,stroke:#333,stroke-width:1px
    classDef view fill:#99ccff,stroke:#333,stroke-width:1px
    classDef api fill:#66b2ff,stroke:#333,stroke-width:1px
    classDef db fill:#0a0,stroke:#060,stroke-width:1px
    classDef storage fill:#999,stroke:#333,stroke-width:1px
```
