# nova6892/php-shopping-portal architecture

> Architecture diagram of the GitHub repository nova6892/php-shopping-portal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nova6892/php-shopping-portal
- Repository: https://github.com/nova6892/php-shopping-portal

## Overview

##### Project type & purpose (from README + tree)
This is a **classic PHP + MySQL shopping portal** intended to run on an **Apache/PHP runtime**. It’s a **server-rendered web app** (not SPA), where PHP pages both render HTML and execute business logic, with a MySQL database for persistence. Static assets are served from the same Apache host (Bootstrap, CSS, images).

- Browser (client)
- Apache + PHP app (single deployable, multiple PHP endpoints)
- MySQL database
- Static assets (Bootstrap/CSS/images) served by Apache

##### What the file structure implies architecturally
Top-level:
- `Database/store.sql` — schema + possibly seed data. This indicates the authoritative DB model.
- `LifestyleStore/` — the web root (document root) containing:
- **UI/pages**: `index.php`, `products.php`, `cart.php`, `login.php`, `signup.php`, `settings.php`, `success.php`, etc.
- **Action/Controller-like scripts**: `login_submit.php`, `user_registration_script.php`, `setting_script.php`, `cart_add.php`, `cart_remove.php`, `logout.php`
- **Shared includes**: `connection.php`, `header.php`, `header2.php`, `check_if_added.php`
- **Static assets**: `bootstrap/`, `css/style.css`, `img/`

This suggests an architecture pattern of:
- **Page controllers / endpoint scripts** (each PHP file is an HTTP endpoint)
- **Shared library includes** (DB connection and helper functions)
- **No explicit “service layer” directory**; logic is likely inline in the endpoint scripts.
- **Session-based auth** (likely via `login_submit.php`, `logout.php`, and checks in header or pages).

##### Readme insights
README confirms:
- Hosted on **Apache server**
- Uses **PHP + MySQL**

##### Client
- “User Browser”
- Renders HTML/CSS, executes minimal JS (Bootstrap JS)

##### Web Server / Runtime
- “Apache HTTP Server”
- “PHP Runtime (mod_php or php-fpm)” (label whichever assumption you want; most likely mod_php in simple hosting)

##### Application (Monolith: LifestyleStore)
- **Public Pages (GET)**
- `index.php` (landing)
- `products.php` (product listing)
- `cart.php` (cart view)
- `settings.php` (settings view)
- `success.php` (order success)
- `login.php`, `signup.php` (forms)
- **Actions / Form handlers (POST/GET actions)**
- `login_submit.php` (authenticate)
- `user_registration_script.php` (create user)
- `setting_script.php` (change password/settings)
- `cart_add.php` (add item to cart)
- `cart_remove.php` (remove item)
- `logout.php` (destroy session)
- **Shared Includes**
- `connection.php` (DB connection configuration + creation)
- `header.php`, `header2.php` (common layout + nav; likely checks session)
- `check_if_added.php` (business rule helper: whether an item is already in cart)
- **Static Assets**
- `bootstrap/` (CSS/JS/fonts)
- `css/style.css`
- `img/`

##### Database
- “MySQL”
- Schema from `Database/store.sql`

- A subcomponent “Session Store (PHP default file sessions)” within the server, or

##### Important architectural patterns used here
- **Monolithic, server-rendered PHP**: each `.php` file acts like a controller+view.
- **Shared include-based composition**: `header*.php`, `connection.php` reused across endpoints.
- **Session-based authentication**: login creates session; pages check session to authorize.
- **Tight coupling of presentation and data access** (typical for small PHP projects): PHP endpoints likely query DB directly via connection include.

##### Relevant technologies
- Apache
- PHP
- MySQL
- Bootstrap (front-end styling)

##### “Don’t overthink it”: separate into as many components as possible
For this repo, the most faithful “detailed separation” is literally at the **file endpoint** granularity:
- Treat every PHP file reachable by HTTP as a component.
- Treat every include/helper as a component.
- Treat DB as a component with labeled tables (derived from `store.sql`).

- `users`
- `products/items`
- `users_items` / cart table
- `orders` (if present)

##### Top row: “Browser”
4) Inside LifestyleStore: four groups (Auth/Catalog/Cart/Account) with the specific PHP scripts
##### Bottom: “MySQL (store.sql schema)” with table list

This will be both “accurate” (matches repo) and “detailed” (captures each endpoint and shared module).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Title / Context
    U["User Browser<br/>(HTML/CSS, Bootstrap JS)"]:::client

    subgraph "Hosting Environment (Single Apache Host)"
        A["Apache HTTP Server"]:::server
        P["PHP Runtime<br/>(mod_php / php-fpm)"]:::server

        subgraph "LifestyleStore Monolith (Document Root)"
            LS["LifestyleStore (PHP endpoints + includes + assets)"]:::app

            subgraph "Public Pages (GET)"
                IDX["index.php<br/>(Landing)"]:::page
                PROD["products.php<br/>(Product listing)"]:::page
                CART["cart.php<br/>(Cart view)"]:::page
                LOGIN["login.php<br/>(Login form)"]:::page
                SIGNUP["signup.php<br/>(Signup form)"]:::page
                SETTINGS["settings.php<br/>(Account settings view)"]:::page
                SUCCESS["success.php<br/>(Order success)"]:::page
            end

            subgraph "Actions / Form Handlers (POST/GET)"
                LOGIN_SUB["login_submit.php<br/>(Authenticate user)"]:::action
                REG_SUB["user_registration_script.php<br/>(Create user)"]:::action
                SET_SUB["setting_script.php<br/>(Update password/settings)"]:::action
                CART_ADD["cart_add.php<br/>(Add item to cart)"]:::action
                CART_REM["cart_remove.php<br/>(Remove item from cart)"]:::action
                LOGOUT["logout.php<br/>(Destroy session)"]:::action
            end

            subgraph "Shared Includes (PHP include/require)"
                CONN["connection.php<br/>(MySQL config + connection)"]:::include
                HDR1["header.php<br/>(Common header/nav + session checks)"]:::include
                HDR2["header2.php<br/>(Alternate header/nav)"]:::include
                CHECKADD["check_if_added.php<br/>(Cart helper rule)"]:::include
            end

            subgraph "Static Assets (served by Apache)"
                BOOT["bootstrap/<br/>(CSS/JS/Fonts)"]:::asset
                CSS["css/style.css"]:::asset
                IMG["img/"]:::asset
            end

            SESS["PHP Sessions<br/>(default file-based session store)"]:::session
        end
    end

    DB[("MySQL Database<br/>Schema from store.sql")]:::db
    SQL["Database/store.sql<br/>(DDL + seed data)"]:::schema

    subgraph "Core Data Model (typical tables from store.sql)"
        T_USERS["users"]:::table
        T_ITEMS["items / products"]:::table
        T_CART["users_items<br/>(cart mapping)"]:::table
        T_ORDERS["orders (if present)"]:::table
    end

    %% Request/Response flows (vertical orientation)
    U -->|"HTTP(S) GET/POST"| A
    A -->|"Serve dynamic requests"| P
    P -->|"Execute PHP endpoint"| LS

    %% Static assets served directly by Apache
    U -->|"GET /bootstrap/*"| A
    U -->|"GET /css/style.css"| A
    U -->|"GET /img/*"| A
    A -->|"Static file response"| U

    %% Page navigation (server-rendered HTML)
    LS -->|"Render HTML pages"| U

    %% Endpoints (representative flows)
    U -->|"GET /index.php"| IDX
    U -->|"GET /products.php"| PROD
    U -->|"GET /cart.php"| CART
    U -->|"GET /login.php"| LOGIN
    U -->|"GET /signup.php"| SIGNUP
    U -->|"GET /settings.php"| SETTINGS
    U -->|"GET /success.php"| SUCCESS

    U -->|"POST /login_submit.php"| LOGIN_SUB
    U -->|"POST /user_registration_script.php"| REG_SUB
    U -->|"POST /setting_script.php"| SET_SUB
    U -->|"GET/POST /cart_add.php?item_id=..."| CART_ADD
    U -->|"GET/POST /cart_remove.php?item_id=..."| CART_REM
    U -->|"GET /logout.php"| LOGOUT

    %% Include relationships (composition)
    IDX -->|"includes"| HDR1
    PROD -->|"includes"| HDR1
    CART -->|"includes"| HDR1
    SETTINGS -->|"includes"| HDR1
    LOGIN -->|"includes"| HDR2
    SIGNUP -->|"includes"| HDR2

    IDX -->|"includes"| CONN
    PROD -->|"includes"| CONN
    CART -->|"includes"| CONN
    SETTINGS -->|"includes"| CONN
    SUCCESS -->|"includes"| CONN

    PROD -->|"uses helper"| CHECKADD
    CART_ADD -->|"uses helper"| CHECKADD

    LOGIN_SUB -->|"includes"| CONN
    REG_SUB -->|"includes"| CONN
    SET_SUB -->|"includes"| CONN
    CART_ADD -->|"includes"| CONN
    CART_REM -->|"includes"| CONN

    %% Sessions (auth)
    LOGIN_SUB -->|"creates/updates"| SESS
    SETTINGS -->|"requires session"| SESS
    CART -->|"requires session"| SESS
    CART_ADD -->|"requires session"| SESS
    CART_REM -->|"requires session"| SESS
    LOGOUT -->|"clears"| SESS

    %% DB interactions
    CONN -->|"MySQL driver (mysqli/PDO)"| DB
    DB --- T_USERS
    DB --- T_ITEMS
    DB --- T_CART
    DB --- T_ORDERS

    LOGIN_SUB -->|"SQL:select users"| DB
    REG_SUB -->|"SQL:insert users"| DB
    PROD -->|"SQL:select items"| DB
    CHECKADD -->|"SQL:select users_items"| DB
    CART_ADD -->|"SQL:insert/update users_items"| DB
    CART_REM -->|"SQL:delete/update users_items"| DB
    SET_SUB -->|"SQL:update users"| DB
    SUCCESS -->|"SQL:update order/cart state"| DB

    %% Schema source
    SQL -->|"defines schema"| DB

    %% Legend (color semantics)
    subgraph "Legend"
        L1["Client"]:::client
        L2["Server/Runtime"]:::server
        L3["App Container"]:::app
        L4["Public Page"]:::page
        L5["Action Script"]:::action
        L6["Shared Include"]:::include
        L7["Static Asset"]:::asset
        L8["Session"]:::session
        L9[("Database")]:::db
    end

    %% Click events (component mapping)
    click SQL "https://github.com/nova6892/php-shopping-portal/blob/main/Database/store.sql"
    click LS "https://github.com/nova6892/php-shopping-portal/tree/main/LifestyleStore/"

    click IDX "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/index.php"
    click PROD "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/products.php"
    click CART "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/cart.php"
    click LOGIN "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/login.php"
    click SIGNUP "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/signup.php"
    click SETTINGS "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/settings.php"
    click SUCCESS "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/success.php"

    click LOGIN_SUB "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/login_submit.php"
    click REG_SUB "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/user_registration_script.php"
    click SET_SUB "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/setting_script.php"
    click CART_ADD "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/cart_add.php"
    click CART_REM "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/cart_remove.php"
    click LOGOUT "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/logout.php"

    click CONN "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/connection.php"
    click HDR1 "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/header.php"
    click HDR2 "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/header2.php"
    click CHECKADD "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/check_if_added.php"

    click BOOT "https://github.com/nova6892/php-shopping-portal/tree/main/LifestyleStore/bootstrap/"
    click CSS "https://github.com/nova6892/php-shopping-portal/blob/main/LifestyleStore/css/style.css"
    click IMG "https://github.com/nova6892/php-shopping-portal/tree/main/LifestyleStore/img/"

    %% Styles
    classDef client fill:#d6ecff,stroke:#1d4ed8,stroke-width:1px,color:#0b1b3a
    classDef server fill:#e5e7eb,stroke:#374151,stroke-width:1px,color:#111827
    classDef app fill:#dcfce7,stroke:#166534,stroke-width:1px,color:#052e16
    classDef page fill:#bbf7d0,stroke:#15803d,stroke-width:1px,color:#052e16
    classDef action fill:#86efac,stroke:#166534,stroke-width:1px,color:#052e16
    classDef include fill:#fef9c3,stroke:#a16207,stroke-width:1px,color:#3a2200
    classDef asset fill:#ede9fe,stroke:#6d28d9,stroke-width:1px,color:#2e1065
    classDef session fill:#ffe4e6,stroke:#be123c,stroke-width:1px,color:#4c0519
    classDef db fill:#ffedd5,stroke:#c2410c,stroke-width:1px,color:#431407
    classDef schema fill:#fed7aa,stroke:#c2410c,stroke-width:1px,color:#431407
    classDef table fill:#fff7ed,stroke:#9a3412,stroke-width:1px,color:#431407
```
