# puneethreddyhc/online-shopping-system architecture

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

- Interactive diagram: https://gitdiagram.com/puneethreddyhc/online-shopping-system
- Repository: https://github.com/puneethreddyhc/online-shopping-system

## Overview

##### Project Type and Purpose
- This project is a web-based online shopping system. It includes separate user and admin interfaces and relies on a MySQL database (imported via the provided SQL file). The README confirms it is a DBMS project with both admin and user layouts.
- Its primary purpose is to allow regular users to browse products, add items to a cart, check out, and also features functionalities like wishlist, product reviews, and search. On the other side, there is an advanced admin section for managing users, products, orders, and suppliers.

##### Analyzing the File Structure
- There are clearly two major groupings: the end-user interface (files like index.php, cart.php, checkout.php, login.php, register.php, etc.) and the admin interface (located in the “admin” folder with further subdivisions such as “admin/admin”, “admin/assets”, “admin/login.php”, and other PHP files for adding or editing products, users, etc.).
- In addition to the UI pages, there are directories for styling (css, assets/css, assets/scss), scripts (js, assets/js), and images (img, assets/img), which hint at the use of front-end libraries and themes (e.g., Material Dashboard, Font Awesome).
- There are configuration files (config.php, db.php, includes/db.php), which show how the application connects to the database.
- The “database” directory holds the SQL dump to initialize the “onlineshop” MySQL database.

a. Main Components:
- Frontend (User Interface): Represent all public-facing pages (index.php, product.php, cart.php, checkout_process.php, etc.). This component is served by the PHP/Apache backend.
- Admin Portal: A separate module corresponding to the files in the “admin” folder—this includes admin pages (like admin/index.php, login.php, product list, and asset files) and dedicated server scripts (such as server/server.php, mapping.php, etc.).
- Database Layer: Represent the MySQL database “onlineshop” which is initialized using the SQL file from the “database” directory.
- Server Environment: Indicate the Apache web server and PHP runtime environment that process the PHP scripts and serve the appropriate HTML/CSS/JS to the client.
- Assets and Shared Components: Show libraries, CSS, JavaScript files, and common includes such as header, footer, and navigation components that are shared between user and admin pages.

b. Relationships and Interactions:
- If applicable, show that static assets (CSS, JS, Images) served by a web server are used by both interfaces.

c. Important Architectural Patterns and Design Principles:
- Separation of Concerns: Emphasize that the system decouples the user interface from business logic (PHP scripts) and data storage (MySQL).
- Modularization: Note that the project separates the admin interface from the main user interface for better management and security.
- Use of MVC-like patterns: Even if not strict, files are organized into controllers/logic, view files (HTML with CSS/JS), and models (database connection files).
- Notes on routing and page control (e.g., from login and registration pages to session management and redirection).

d. Technologies and Frameworks:
- PHP for server-side processing.
- MySQL as the database.
- Apache (via XAMPP/WAMP) as the web server.
- Frontend libraries and assets (Material Dashboard, Font Awesome, custom CSS and JS) for styling and UI interactions.
- Possibly additional third-party libraries for functionalities like notifications (bootstrap-notify.js).

##### Detailed Elements
- That both the frontend and admin sections are running on the same application server but are separated logically by directory.
- Optionally, add a note about session management in PHP (e.g., user authentication and admin authentication check) as part of the server application layer.

- The separation between user and admin interfaces.
- The central role of the PHP application logic in communicating with a MySQL database.
- The use of shared static assets.
- And the overall interaction flow that supports core functionalities like product display, order processing, and administration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level Clients
    UB("User Browser"):::browser
    AB("Admin Browser"):::browser

    %% Frontend (User Interface) Subgraph with Mapped Files
    subgraph "Frontend (User Interface)"
        U1("index.php"):::file
        U2("product.php"):::file
        U3("cart.php"):::file
        U4("checkout.php"):::file
        U5("checkout_process.php"):::file
        U6("login.php"):::file
        U7("register.php"):::file
        U8("header.php"):::file
        U9("footer.php"):::file
        U10("topheader"):::directory
    end

    %% Admin Portal Subgraph with Mapped Files
    subgraph "Admin Portal"
        A1("admin/admin/index.php"):::file
        A2("admin/admin/add_products.php"):::file
        A3("admin/admin/edituser.php"):::file
        A4("admin/admin/assets"):::directory
        A5("admin/admin/includes"):::directory
        A6("admin/login.php"):::file
        A7("admin/reg.php"):::file
        A8("admin/server/server.php"):::file
        A9("admin/admin/includes/db.php"):::config
    end

    %% Configuration Subgraph for DB connection files
    subgraph "Configuration"
        CFG1("config.php"):::config
        CFG2("db.php"):::config
    end

    %% Other Core Components
    FAS("Frontend Static Assets (CSS/JS/Images)"):::assets
    AAS("Admin Static Assets (CSS/JS/Images)"):::assets
    PAS("PHP/Apache Server"):::server
    DB("MySQL Database"):::database

    %% Connections for Frontend Flow
    UB -->|"accesses"| U1
    U1 -->|"loaded_from"| FAS
    U1 -->|"processed_by"| PAS

    %% Connections for Admin Flow
    AB -->|"accesses"| A1
    A1 -->|"loaded_from"| AAS
    A1 -->|"processed_by"| PAS

    %% Server and Database Interaction
    PAS -->|"queries"| DB

    %% Configuration Feeding into Server Environment
    CFG1 -->|"configures"| PAS
    CFG2 -->|"configures"| PAS

    %% Click Events for Frontend Components
    click U1 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/index.php"
    click U2 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/product.php"
    click U3 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/cart.php"
    click U4 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/checkout.php"
    click U5 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/checkout_process.php"
    click U6 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/login.php"
    click U7 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/register.php"
    click U8 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/header.php"
    click U9 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/footer.php"
    click U10 "https://github.com/puneethreddyhc/online-shopping-system/tree/master/topheader"

    %% Click Events for Admin Components
    click A1 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/admin/admin/index.php"
    click A2 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/admin/admin/add_products.php"
    click A3 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/admin/admin/edituser.php"
    click A4 "https://github.com/puneethreddyhc/online-shopping-system/tree/master/admin/admin/assets"
    click A5 "https://github.com/puneethreddyhc/online-shopping-system/tree/master/admin/admin/includes"
    click A6 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/admin/login.php"
    click A7 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/admin/reg.php"
    click A8 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/admin/server/server.php"
    click A9 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/admin/admin/includes/db.php"

    %% Click Events for Configuration Files
    click CFG1 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/config.php"
    click CFG2 "https://github.com/puneethreddyhc/online-shopping-system/blob/master/db.php"

    %% Click Event for Database SQL Dump
    click DB "https://github.com/puneethreddyhc/online-shopping-system/blob/master/database/onlineshop.sql"

    %% Styles
    classDef browser fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef file fill:#E0F7FA,stroke:#000,stroke-width:1px;
    classDef directory fill:#FFF9C4,stroke:#000,stroke-width:1px;
    classDef config fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef server fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef database fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef assets fill:#D8BFD8,stroke:#000,stroke-width:1px;
```
