# rubenmolerorios/allblue architecture

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

- Interactive diagram: https://gitdiagram.com/rubenmolerorios/allblue
- Repository: https://github.com/rubenmolerorios/allblue

## Overview

##### Project Type and Purpose
- This is a monolithic, server-rendered PHP full-stack web application with two main user interfaces: an “admin” panel and a “shop” (public storefront).
- It follows an MVC (Model-View-Controller) pattern, interfacing with a relational database (via src/config/database.php) and serving static assets from a “public” directory.

##### Main Components
a. Web Server Layer
- Apache (or Nginx) receiving HTTP requests, honoring .htaccess
- Routes all requests to index.php (front controller)
b. Application Core
- Front Controller (index.php, autoload.php, include.php)
- Router logic (decides which controller in src/controllers handles the request)
c. MVC Modules
- Controllers (src/controllers/*.php)
- Models (src/models/*.php)
- Views (admin/view/... and shop/view/...)
d. Asset Server
- Static files under public/ (CSS, JS, images)
e. Database
- MySQL (or compatible), schema in sql/basededatosproyecto.sql
- Connection managed by src/db/DB.php and config/database.php
f. Two Functional Zones
- Admin interface (admin/index.php → admin/view/…)
- Shop interface (shop/index.php → shop/view/…)

##### Relationships and Data Flow
1. Client → Web Server → index.php
2. index.php loads autoload/include, picks a Controller
3. Controller invokes Models ↔ DB via DB.php
4. Controller compiles data, selects a View
5. View renders HTML + references assets in public/
6. Response served back to client
7. Separate flows for admin vs. shop, but share same MVC core and DB

##### Architectural Patterns & Principles
- MVC separation: Controllers manage request & business logic, Models encapsulate data access, Views handle presentation
- Single code-base modularity: admin vs. shop modules share src/ core
- Clear separation of static vs. dynamic content
- Configuration isolation: parameters.php, database.php

##### Technologies & Frameworks
- PHP 7+ or 8
- Apache/Nginx with .htaccess
- MySQL (or MariaDB)
- Plain JavaScript, CSS
- PSR-4 autoloading (autoload.php)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client and Web Server
    Client["Client (Browser)"]:::external -->|HTTP Request| WebServer["Apache/Nginx Server"]:::server
    WebServer -->|Honors .htaccess| HT[".htaccess"]:::server
    WebServer -->|Routes to| Index["index.php"]:::core

    %% Bootstrapping
    Index --> Autoload["autoload.php"]:::core
    Index --> Include["include.php"]:::core
    Index --> Router["Router Logic"]:::core

    %% Core Configuration & DB Abstraction
    Router --> ConfigParams["parameters.php"]:::core
    Router --> ConfigDB["database.php"]:::core
    Router --> DBAbstraction["DB.php"]:::core
    DBAbstraction --> DBSchema["basededatosproyecto.sql"]:::db
    DBAbstraction --> Database["MySQL Database"]:::db

    %% MVC Layers
    subgraph "Controllers" 
        direction TB
        ArticleCtrl["ArticleController"]:::controller
        CarritoCtrl["CarritoController"]:::controller
        ErrorCtrl["ErrorController"]:::controller
        OrderCtrl["OrderController"]:::controller
        ReviewCtrl["ReviewController"]:::controller
        RolUserCtrl["RolUserController"]:::controller
        TypeCtrl["TypeController"]:::controller
        UserCtrl["UserController"]:::controller
    end
    Router -->|Selects| ArticleCtrl
    Router --> CarritoCtrl
    Router --> ErrorCtrl
    Router --> OrderCtrl
    Router --> ReviewCtrl
    Router --> RolUserCtrl
    Router --> TypeCtrl
    Router --> UserCtrl

    subgraph "Models"
        direction TB
        ArticleModel["Article"]:::model
        ArticleOrderModel["ArticleOrder"]:::model
        OrderModel["Order"]:::model
        ReviewModel["Review"]:::model
        RolUserModel["RolUser"]:::model
        TypeArticleModel["TypeArticle"]:::model
        UserModel["User"]:::model
    end
    ArticleCtrl -->|uses| ArticleModel
    CarritoCtrl -->|uses| ArticleOrderModel
    OrderCtrl -->|uses| OrderModel
    ReviewCtrl -->|uses| ReviewModel
    RolUserCtrl -->|uses| RolUserModel
    TypeCtrl -->|uses| TypeArticleModel
    UserCtrl -->|uses| UserModel

    ArticleModel -->|CRUD| DBAbstraction
    ArticleOrderModel --> DBAbstraction
    OrderModel --> DBAbstraction
    ReviewModel --> DBAbstraction
    RolUserModel --> DBAbstraction
    TypeArticleModel --> DBAbstraction
    UserModel --> DBAbstraction

    %% Views and Responses
    subgraph "Admin Module"
        direction TB
        AdminEntry["admin/index.php"]:::core
        AdminEntry --> Router
        subgraph "Admin Views"
            direction TB
            AV1["admin/view/article/*.php"]:::view
            AV2["admin/view/auth/*.php"]:::view
            AV3["admin/view/order/*.php"]:::view
            AV4["admin/view/review/*.php"]:::view
            AV5["admin/view/type/*.php"]:::view
            AV6["admin/view/user/*.php"]:::view
            AVH["admin/view/include/header.php"]:::view
            AVF["admin/view/include/footer.php"]:::view
        end
        ArticleCtrl --> AV1
        CarritoCtrl --> AV2
        OrderCtrl --> AV3
        ReviewCtrl --> AV4
        TypeCtrl --> AV5
        UserCtrl --> AV6
        AV1 -->|renders HTML| Client
        AVH --> AVF
    end

    subgraph "Shop Module"
        direction TB
        ShopEntry["shop/index.php"]:::core
        ShopEntry --> Router
        subgraph "Shop Views"
            direction TB
            SV1["shop/view/article/*.php"]:::view
            SV2["shop/view/auth/*.php"]:::view
            SV3["shop/view/carrito/*.php"]:::view
            SV4["shop/view/type/*.php"]:::view
            SVH["shop/view/include/header.php"]:::view
            SVF["shop/view/include/footer.php"]:::view
        end
        ArticleCtrl --> SV1
        CarritoCtrl --> SV3
        TypeCtrl --> SV4
        SV1 -->|renders HTML| Client
        SVH --> SVF
    end

    %% Static Assets
    subgraph "Static Asset Server"
        direction TB
        JSAdmin["public/js/admin/custom.js"]:::asset
        JSShop["public/js/shop/custom.js"]:::asset
        MainJS["public/js/main.js"]:::asset
        CSSAdmin["public/style/admin/*.css"]:::asset
        CSSMain["public/style/*.css"]:::asset
        ImgArt["public/image/articles/"]:::asset
        ImgKeep["public/image/.gitkeep"]:::asset
    end
    AV1 -->|references| JSAdmin
    SV1 -->|references| JSShop
    ArticleCtrl --> CSSAdmin
    ArticleCtrl --> CSSMain
    AV1 --> ImgArt

    %% Styles
    classDef server fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef core fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef controller fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef model fill:#cfd8dc,stroke:#333,stroke-width:1px
    classDef view fill:#fff9c4,stroke:#333,stroke-width:1px
    classDef db fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef asset fill:#eceff1,stroke:#333,stroke-width:1px
    classDef external fill:#f0f4c3,stroke:#333,stroke-width:1px

    %% Click Events
    click HT "https://github.com/rubenmolerorios/allblue/blob/main/.htaccess"
    click Index "https://github.com/rubenmolerorios/allblue/blob/main/index.php"
    click Autoload "https://github.com/rubenmolerorios/allblue/blob/main/autoload.php"
    click Include "https://github.com/rubenmolerorios/allblue/blob/main/include.php"
    click ConfigDB "https://github.com/rubenmolerorios/allblue/blob/main/src/config/database.php"
    click ConfigParams "https://github.com/rubenmolerorios/allblue/blob/main/src/config/parameters.php"
    click DBAbstraction "https://github.com/rubenmolerorios/allblue/blob/main/src/db/DB.php"
    click DBSchema "https://github.com/rubenmolerorios/allblue/blob/main/sql/basededatosproyecto.sql"
    click ArticleCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/ArticleController.php"
    click CarritoCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/CarritoController.php"
    click ErrorCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/ErrorController.php"
    click OrderCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/OrderController.php"
    click ReviewCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/ReviewController.php"
    click RolUserCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/RolUserController.php"
    click TypeCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/TypeController.php"
    click UserCtrl "https://github.com/rubenmolerorios/allblue/blob/main/src/controllers/UserController.php"
    click ArticleModel "https://github.com/rubenmolerorios/allblue/blob/main/src/models/Article.php"
    click ArticleOrderModel "https://github.com/rubenmolerorios/allblue/blob/main/src/models/ArticleOrder.php"
    click OrderModel "https://github.com/rubenmolerorios/allblue/blob/main/src/models/Order.php"
    click ReviewModel "https://github.com/rubenmolerorios/allblue/blob/main/src/models/Review.php"
    click RolUserModel "https://github.com/rubenmolerorios/allblue/blob/main/src/models/RolUser.php"
    click TypeArticleModel "https://github.com/rubenmolerorios/allblue/blob/main/src/models/TypeArticle.php"
    click UserModel "https://github.com/rubenmolerorios/allblue/blob/main/src/models/User.php"
    click AdminEntry "https://github.com/rubenmolerorios/allblue/blob/main/admin/index.php"
    click AV1 "https://github.com/rubenmolerorios/allblue/tree/main/admin/view/article"
    click AV2 "https://github.com/rubenmolerorios/allblue/tree/main/admin/view/auth"
    click AV3 "https://github.com/rubenmolerorios/allblue/tree/main/admin/view/order"
    click AV4 "https://github.com/rubenmolerorios/allblue/tree/main/admin/view/review"
    click AV5 "https://github.com/rubenmolerorios/allblue/tree/main/admin/view/type"
    click AV6 "https://github.com/rubenmolerorios/allblue/tree/main/admin/view/user"
    click AVH "https://github.com/rubenmolerorios/allblue/blob/main/admin/view/include/header.php"
    click AVF "https://github.com/rubenmolerorios/allblue/blob/main/admin/view/include/footer.php"
    click ShopEntry "https://github.com/rubenmolerorios/allblue/blob/main/shop/index.php"
    click SV1 "https://github.com/rubenmolerorios/allblue/tree/main/shop/view/article"
    click SV2 "https://github.com/rubenmolerorios/allblue/tree/main/shop/view/auth"
    click SV3 "https://github.com/rubenmolerorios/allblue/tree/main/shop/view/carrito"
    click SV4 "https://github.com/rubenmolerorios/allblue/tree/main/shop/view/type"
    click SVH "https://github.com/rubenmolerorios/allblue/blob/main/shop/view/include/header.php"
    click SVF "https://github.com/rubenmolerorios/allblue/blob/main/shop/view/include/footer.php"
    click JSAdmin "https://github.com/rubenmolerorios/allblue/blob/main/public/js/admin/custom.js"
    click JSShop "https://github.com/rubenmolerorios/allblue/blob/main/public/js/shop/custom.js"
    click MainJS "https://github.com/rubenmolerorios/allblue/blob/main/public/js/main.js"
    click CSSAdmin "https://github.com/rubenmolerorios/allblue/tree/main/public/style/admin"
    click CSSMain "https://github.com/rubenmolerorios/allblue/tree/main/public/style"
    click ImgArt "https://github.com/rubenmolerorios/allblue/tree/main/public/image/articles/"
    click ImgKeep "https://github.com/rubenmolerorios/allblue/blob/main/public/image/.gitkeep"
```
