# hiepfre3101/food_lum architecture

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

- Interactive diagram: https://gitdiagram.com/hiepfre3101/food_lum
- Repository: https://github.com/hiepfre3101/food_lum

## Overview

##### Main Components
- Client-facing Frontend: This is composed of the "view" directory (which contains pages like home, login, signup, product detail, order pages) and the "template/site" directory (which provides HTML templates for the user interface).
- Admin Dashboard: Separated into the "admin" directory, specifically under "admin/view", which hosts various PHP pages for administration such as managing categories, products, orders, comments, users, sliders, and vouchers.
- Controllers: The "controller" directory contains PHP files that implement the business logic (e.g., c_client.php, c_admin.php, c_order.php). They coordinate request handling by bridging the frontend and the underlying data layers.
- Models: Found in the "model" directory, these files deal directly with the database interactions (e.g., m_product.php, m_order.php, m_user.php) and include configuration files for DB connections.
- Mailing Module: The "mail" directory, especially "mail/send_mail", incorporates PHPMailer along with related configuration and language files. This component is responsible for the email functionality within the web application.
- Configuration Files: Scattered across "controller/config.php", "model/config.php", and similar, which likely hold common settings for DB, server, or other environment variables.
- Entry Points: The "index.php" file acts as the primary entry point for the website, handling the initial dispatch of requests.

##### Relationships and Interactions
- The user (or admin) interacts with the website via the UI pages (in "view" and "template/site"). Requests are sent to "index.php" or other routing scripts.
- These requests are forwarded to the appropriate controller (found in the "controller" directory), where the business logic is executed.
- Controllers interact with the models (in the "model" directory) to retrieve or update data from the database.
- Once the logic is processed, controllers call the views to render the HTML content, using standard PHP view files (both in "admin/view" for the backend and "view" for general pages).
- For email notifications or confirmations, the application integrates the mailing module in the "mail/send_mail" directory.
- The public directory serves the static assets required for both the frontend and admin sections of the site.

##### Architectural Patterns and Design Principles
- MVC Pattern: The clear separation into Models, Views, and Controllers helps modularize the design.
- Separation of Concerns: Differentiation of client vs. admin modules ensures clear domain boundaries.
- Reusability & Extensibility: With templated HTML in the "template" directory and the modular mailer component, the design supports reuse and potential future extensions.
- Dependency Handling: Configuration files ensure that dependencies like database connections and external APIs (like VNPay) are managed centrally.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        CB["Client (Browser)"]:::client
        CV["Client Views"]:::view
        TS["Template Site"]:::view
        AD["Admin Dashboard Views"]:::admin
    end

    %% Entry & Routing
    subgraph "Entry & Routing"
        EP["Entry Point: index.php"]:::entry
        CC["Config (Controller)"]:::config
        MC["Config (Model)"]:::config
    end

    %% Controllers Layer
    subgraph "Controllers Layer"
        C1["Controller: c_client.php"]:::controller
        C2["Controller: c_admin.php"]:::controller
        C3["Controller: c_order.php"]:::controller
        C4["Controller: c_product.php"]:::controller
        VN["VNPay Payment"]:::controller
    end

    %% Models Layer
    subgraph "Models Layer"
        M1["Model: m_product.php"]:::model
        M2["Model: m_order.php"]:::model
        M3["Model: m_user.php"]:::model
        DB["Database"]:::database
    end

    %% Utilities
    subgraph "Utilities"
        MAIL["Mail Module (PHPMailer)"]:::mail
        PA["Public Assets (CSS,JS,Images)"]:::assets
    end

    %% Connections for UI and Entry
    CB -->|"request"| EP
    EP -->|"routes"| C1
    EP -->|"routes"| C2
    EP -->|"routes"| C3
    EP -->|"routes"| C4
    EP -->|"routes"| VN

    %% Configuration injections
    CC -->|"loads"| C1
    CC -->|"loads"| C2
    CC -->|"loads"| C3
    CC -->|"loads"| C4
    CC -->|"loads"| VN
    MC -->|"loads"| M1
    MC -->|"loads"| M2
    MC -->|"loads"| M3

    %% Controllers to Views
    C1 -->|"renders"| CV
    C3 -->|"renders"| CV
    C4 -->|"renders"| CV
    C2 -->|"renders"| AD

    %% Controllers to Models
    C1 -->|"calls"| M1
    C2 -->|"calls"| M1
    C3 -->|"calls"| M2
    C4 -->|"calls"| M1
    VN -->|"integrates"| M2

    %% Models to Database
    M1 -->|"CRUD"| DB
    M2 -->|"CRUD"| DB
    M3 -->|"CRUD"| DB

    %% Controllers trigger Mail operations
    C3 -->|"sends email"| MAIL
    C2 -->|"sends email"| MAIL

    %% Public Assets served to Client and Templates
    PA -->|"assets"| CV
    PA -->|"assets"| TS

    %% Template Site contributes to UI
    TS -->|"provides layout"| CV

    %% Click Events
    click CB "https://github.com/hiepfre3101/food_lum/blob/main/index.php"
    click CV "https://github.com/hiepfre3101/food_lum/tree/main/view/"
    click TS "https://github.com/hiepfre3101/food_lum/tree/main/template/site/"
    click AD "https://github.com/hiepfre3101/food_lum/tree/main/admin/view/"
    click EP "https://github.com/hiepfre3101/food_lum/blob/main/index.php"
    click CC "https://github.com/hiepfre3101/food_lum/blob/main/controller/config.php"
    click MC "https://github.com/hiepfre3101/food_lum/blob/main/model/config.php"
    click C1 "https://github.com/hiepfre3101/food_lum/blob/main/controller/c_client.php"
    click C2 "https://github.com/hiepfre3101/food_lum/blob/main/controller/c_admin.php"
    click C3 "https://github.com/hiepfre3101/food_lum/blob/main/controller/c_order.php"
    click C4 "https://github.com/hiepfre3101/food_lum/blob/main/controller/c_product.php"
    click VN "https://github.com/hiepfre3101/food_lum/blob/main/controller/vnpay_create_payment.php"
    click M1 "https://github.com/hiepfre3101/food_lum/blob/main/model/m_product.php"
    click M2 "https://github.com/hiepfre3101/food_lum/blob/main/model/m_order.php"
    click M3 "https://github.com/hiepfre3101/food_lum/blob/main/model/m_user.php"
    click MAIL "https://github.com/hiepfre3101/food_lum/tree/main/mail/send_mail/"
    click PA "https://github.com/hiepfre3101/food_lum/tree/main/public/"

    %% Styles
    classDef client fill:#f9e6ff,stroke:#333,stroke-width:2px;
    classDef view fill:#e0ffff,stroke:#333,stroke-width:2px;
    classDef admin fill:#ffe6e6,stroke:#333,stroke-width:2px;
    classDef entry fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef controller fill:#d1e0e0,stroke:#333,stroke-width:2px;
    classDef model fill:#d1ffd1,stroke:#333,stroke-width:2px;
    classDef database fill:#f7d6ad,stroke:#333,stroke-width:2px;
    classDef mail fill:#ffd1dc,stroke:#333,stroke-width:2px;
    classDef assets fill:#d1d1ff,stroke:#333,stroke-width:2px;
    classDef config fill:#fff2cc,stroke:#333,stroke-width:2px;
```
