# nam25081108/web_shop_dep architecture

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

- Interactive diagram: https://gitdiagram.com/nam25081108/web_shop_dep
- Repository: https://github.com/nam25081108/web_shop_dep

## Overview

##### Project Type and Purpose
- The project is a web application with both a user-facing portion and an administrative backend. The presence of pages like index.php, cart.php, checkout-*, product pages, and a separate admin folder indicates it’s built for online shopping/e-commerce.
- The README is minimal (“Web”) with team member names, but the file structure gives a clear picture of an e-commerce system with functionalities such as user registration, product management, order processing, and customer management.

##### File Structure
- There are two main sections: the public-facing store (files in the project root like index.php, cart.php, checkout pages, css, js, fonts, and images) and the admin portion (under the “admin” directory containing its own classes, pages, configuration, and assets).
- The “classes” directories in both the root and admin folders include files for category, product, etc., suggesting a separation of business logic for the storefront as well as additional administrative functions.
- A “Test_Unit” directory with various unit tests (for Address, Cart, Customer, Payment, Product, User) indicates emphasis on testing core functionalities.
- There are also configuration files (e.g., config.php, admin/config/config.php), build files (composer.json and composer.lock) and SQL scripts, highlighting dependency management and database integration.

a. Main Components:
- Frontend (Customer-Facing Website): Contains pages related to product browsing (shop-grid.php, single-product.php), user accounts (registration.php, my-account.php), and checkout processes.
- Backend / Admin Panel: Managed under the admin folder, this includes components for administering users, products, orders (donhang, hoadon), categories, and reports.
- Business Logic Layer: Represented by PHP class files in “admin/classes” and “classes” (handling entities such as User, Product, Category, Customer).
- Database: Although not detailed in the file tree aside from the SQL file (sql/web2.sql), it is implied as the persistent data layer.
- Testing Module: Highlight the “Test_Unit” directory that contains unit tests to ensure key functionalities (address, cart, etc.) are working.
- Libraries and Dependencies: Include components like vendor (likely third-party libraries managed via Composer) and assets (JavaScript libraries in admin/js, CSS frameworks).

b. Relationships and Interactions:
- Admin Panel to the Database showing CRUD operations for managing products, orders, and users.
- Data validations, session handling (see session.php in lib) and configuration management.

c. Architectural Patterns & Design Principles:
- Separation of Concerns: Distinguishing between presentation (frontend pages and admin pages) and business logic (PHP classes).
- Modular Design: The use of directories for tests, libraries, and configuration promotes organized, modular code.
- MVC/MV* Influence: While not explicitly using a framework, components are logically separated (templates for header.php/footer.php, business logic in classes) resembling an MVC pattern.
- Dependency Management: Use of Composer (composer.json in both project root and admin) indicates a reliance on Composer-managed libraries and adherence to modern PHP practices.

d. Relevant Technologies & Frameworks:
- PHP as the core server-side language.
- HTML, CSS, JavaScript for the frontend, including libraries for UI elements (jQuery, Nivo Slider, Owl Carousel, DataTables, and others as seen in the file tree).
- MySQL (inferred from the SQL dump file) for the database.
- Unit testing frameworks (given the Test_Unit directory) to ensure application reliability.
- Optional: External libraries in the vendor folder managed by Composer.

- Use clear labels for each component (e.g., “Frontend UI”, “Admin Panel”, “Business Logic”, “Data Access Layer/Database”, “Unit Tests”).
- From the browser to the PHP endpoints.
- Between the business logic layer and the database.
- From the admin panel to the business logic, indicating CRUD operations.
- A different representation for backend business logic modules (classes in “classes” directories).
- Distinct markers for testing components.
- To note integration points:
- Payment processing (inferred from PaymentTest and order processing pages).
- Session management and configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("Client Browser"):::ui

    subgraph "Customer Facing"
        FUI("Frontend UI"):::ui
        FBL("Storefront Business Logic"):::bl
        FUI -->|"Executes_Business_Logic"| FBL
    end

    subgraph "Admin Section"
        AP("Admin Panel"):::ui
        ABL("Admin Business Logic"):::bl
        AP -->|"Executes_Business_Logic"| ABL
    end

    DB("Database"):::db
    SES("Session Management"):::ses
    TM("Testing Module"):::test
    DM_R("Dependency Management (Root)"):::dep
    DM_A("Dependency Management (Admin)"):::dep
    VL("Vendor Libraries"):::dep

    A -->|"HTTP_Request"| FUI
    A -->|"HTTP_Request"| AP

    FBL -->|"CRUD_Operations"| DB
    ABL -->|"CRUD_Operations"| DB

    FUI -->|"Handles_Sessions"| SES
    AP -->|"Handles_Sessions"| SES

    FBL -->|"Uses_Libraries"| DM_R
    ABL -->|"Uses_Libraries"| DM_A

    FBL -->|"Uses_Libraries"| VL
    ABL -->|"Uses_Libraries"| VL

    TM -->|"Tests_Functionality"| FBL
    TM -->|"Tests_Functionality"| ABL

    %% Click Events
    click FUI "https://github.com/nam25081108/web_shop_dep/blob/main/index.php"
    click AP "https://github.com/nam25081108/web_shop_dep/tree/main/admin"
    click FBL "https://github.com/nam25081108/web_shop_dep/tree/main/classes"
    click ABL "https://github.com/nam25081108/web_shop_dep/tree/main/admin/classes"
    click DB "https://github.com/nam25081108/web_shop_dep/blob/main/sql/web2.sql"
    click SES "https://github.com/nam25081108/web_shop_dep/blob/main/lib/session.php"
    click TM "https://github.com/nam25081108/web_shop_dep/tree/main/Test_Unit"
    click DM_R "https://github.com/nam25081108/web_shop_dep/blob/main/composer.json"
    click DM_A "https://github.com/nam25081108/web_shop_dep/blob/main/admin/composer.json"
    click VL "https://github.com/nam25081108/web_shop_dep/tree/main/vendor"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef bl fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef db fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef test fill:#f8bbd0,stroke:#880e4f,stroke-width:2px;
    classDef dep fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px;
    classDef ses fill:#d7ccc8,stroke:#4e342e,stroke-width:2px;
```
