# bkiran2003/spaesthetic architecture

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

- Interactive diagram: https://gitdiagram.com/bkiran2003/spaesthetic
- Repository: https://github.com/bkiran2003/spaesthetic

## Overview

##### Project type and purpose
- This is a monolithic PHP-based e-commerce/web-app:
- Static front-end HTML pages (login, signup, price_list, admin dashboard) served under public_html.
- A set of REST-style PHP API endpoints under public_html/api that handle authentication, product/catalog management, cart & orders, payments, settings, etc.
- File upload storage (public_html/uploads).
- A vendor directory holding third-party libraries (composer packages or front-end libs).
- There is likely a MySQL (or similar) database behind db_connect.php, and an external payment gateway.

##### File structure
- public_html/
- *.html front-end views (index.html, login.html, signup.html, price_list.html, admin_login, admin_dashboard).
- /api/: PHP scripts providing a JSON/HTTP API (auth, admin_auth, get_*, manage_*, cart_handler, order_handler, payment_handler).
- /uploads/: persistent file store for user or product uploads.
- /vendor/: third-party code (libraries for DB access, routing, middleware, front-end frameworks, etc.).
- README.md is empty—so no existing architecture docs.
- config.php holds environment settings.
- db_connect.php is the database connector.

##### Main components
a. Client Browser (Web UI)
– Static HTML/CSS/JS served from public_html.
– Calls API endpoints via AJAX/Fetch.
b. Web Server Layer
– Nginx/Apache serving static files and dispatching /api requests to PHP interpreter.
c. PHP Application Layer
– public_html/api/*.php scripts orchestrating business logic.
– config.php (env config), db_connect.php (database driver).
d. Database
– MySQL (or equivalent) storing users, products, orders, settings.
e. File Storage
– public_html/uploads for images/documents.
f. Third-Party Libraries
– vendor directory: PHP packages (e.g. composer), front-end frameworks (e.g. jQuery, Bootstrap).
g. External Services
– Payment gateway (stripe/paypal), optional email/SMS services.

##### Relationships & data flows
- Browser → Web Server (HTTP GET/POST to HTML pages and /api endpoints)
- Web Server ↔ PHP Application
- PHP Application ↔ Database (via db_connect.php)
- PHP Application ↔ File Storage (read/write uploads folder)
- PHP Application ↔ Third-Party Libs (via vendor/*)
- PHP Application ↔ External Payment Gateway (HTTPS API calls)

##### Architectural patterns & design principles
- Monolithic three-tier design: Presentation (static HTML + client JS), Application (PHP API), Data (DB + file store).
- REST-style endpoints in /api for separation of concerns.
- Configuration abstraction in config.php.
- Vendor directory for dependency management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser Layer
    subgraph "Client Browser"
        direction TB
        Index["index.html"]:::frontend
        Login["login.html"]:::frontend
        Signup["signup.html"]:::frontend
        Pricelist["price_list.html"]:::frontend
        AdminLogin["admin_login.html"]:::frontend
        AdminDashboard["admin_dashboard.html"]:::frontend
    end

    %% Web Server Layer
    subgraph "Web Server (Nginx/Apache)"
        direction TB
        WebServer["Web Server"]:::app
    end

    %% PHP Application Layer
    subgraph "PHP Application Layer"
        direction TB
        Auth["auth.php"]:::app
        AdminAuth["admin_auth.php"]:::app
        UserAuth["user_auth.php"]:::app
        Cart["cart_handler.php"]:::app
        Order["order_handler.php"]:::app
        PaymentAPI["payment_handler.php"]:::app
        GetCustomers["get_customers.php"]:::app
        GetStats["get_dashboard_stats.php"]:::app
        GetOrders["get_orders.php"]:::app
        GetProducts["get_products.php"]:::app
        GetSettings["get_settings.php"]:::app
        ManageProducts["manage_products.php"]:::app
        ManageSettings["manage_settings.php"]:::app
        UpdateOrder["update_order_status.php"]:::app
        TestEnv["test_environment.php"]:::app
        Config["config.php"]:::app
        DBConn["db_connect.php"]:::app
    end

    %% Data & Storage
    subgraph "Data & Storage"
        direction TB
        Database["MySQL Database"]:::data
        Uploads["uploads/ (File Storage)"]:::data
    end

    %% Third-Party & External Services
    subgraph "Third-Party & External Services"
        direction TB
        Vendor["vendor/ (Libraries)"]:::external
        PaymentGateway["Payment Gateway"]:::external
        EmailService["Email/SMS Service"]:::external
    end

    %% Connections
    Index -->|HTTP GET/POST| WebServer
    Login -->|HTTP GET/POST| WebServer
    Signup -->|HTTP GET/POST| WebServer
    Pricelist -->|HTTP GET/POST| WebServer
    AdminLogin -->|HTTP GET/POST| WebServer
    AdminDashboard -->|HTTP GET/POST| WebServer

    WebServer -->|dispatch /api/*| Auth
    WebServer --> AdminAuth
    WebServer --> UserAuth
    WebServer --> Cart
    WebServer --> Order
    WebServer --> PaymentAPI
    WebServer --> GetCustomers
    WebServer --> GetStats
    WebServer --> GetOrders
    WebServer --> GetProducts
    WebServer --> GetSettings
    WebServer --> ManageProducts
    WebServer --> ManageSettings
    WebServer --> UpdateOrder
    WebServer --> TestEnv

    Auth -->|uses| Config
    AdminAuth --> Config
    UserAuth --> Config
    Cart --> Config
    Order --> Config
    PaymentAPI --> Config
    GetCustomers --> Config
    GetStats --> Config
    GetOrders --> Config
    GetProducts --> Config
    GetSettings --> Config
    ManageProducts --> Config
    ManageSettings --> Config
    UpdateOrder --> Config
    TestEnv --> Config

    Auth -->|connect| DBConn
    AdminAuth --> DBConn
    UserAuth --> DBConn
    Cart --> DBConn
    Order --> DBConn
    PaymentAPI --> DBConn
    GetCustomers --> DBConn
    GetStats --> DBConn
    GetOrders --> DBConn
    GetProducts --> DBConn
    GetSettings --> DBConn
    ManageProducts --> DBConn
    ManageSettings --> DBConn
    UpdateOrder --> DBConn
    TestEnv --> DBConn

    DBConn -->|queries| Database

    ManageProducts -->|file I/O| Uploads

    PaymentAPI -->|HTTPS API| PaymentGateway
    Order -->|notifications| EmailService

    %% Application uses vendor libraries
    Auth -->|autoload| Vendor
    AdminAuth --> Vendor
    UserAuth --> Vendor
    Cart --> Vendor
    Order --> Vendor
    PaymentAPI --> Vendor
    GetCustomers --> Vendor
    GetStats --> Vendor
    GetOrders --> Vendor
    GetProducts --> Vendor
    GetSettings --> Vendor
    ManageProducts --> Vendor
    ManageSettings --> Vendor
    UpdateOrder --> Vendor
    TestEnv --> Vendor

    %% Click Events
    click Index "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/index.html"
    click Login "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/login.html"
    click Signup "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/signup.html"
    click Pricelist "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/price_list.html"
    click AdminLogin "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/admin_login.html"
    click AdminDashboard "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/admin_dashboard.html"

    click Auth "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/auth.php"
    click AdminAuth "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/admin_auth.php"
    click UserAuth "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/user_auth.php"
    click Cart "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/cart_handler.php"
    click Order "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/order_handler.php"
    click PaymentAPI "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/payment_handler.php"
    click GetCustomers "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/get_customers.php"
    click GetStats "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/get_dashboard_stats.php"
    click GetOrders "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/get_orders.php"
    click GetProducts "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/get_products.php"
    click GetSettings "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/get_settings.php"
    click ManageProducts "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/manage_products.php"
    click ManageSettings "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/manage_settings.php"
    click UpdateOrder "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/update_order_status.php"
    click TestEnv "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/test_environment.php"

    click Config "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/config.php"
    click DBConn "https://github.com/bkiran2003/spaesthetic/blob/main/Downloads/public_html/api/db_connect.php"
    click Uploads "https://github.com/bkiran2003/spaesthetic/tree/main/Downloads/public_html/uploads"
    click Vendor "https://github.com/bkiran2003/spaesthetic/tree/main/Downloads/public_html/vendor"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085;
    classDef app fill:#d4edda,stroke:#155724,color:#155724;
    classDef data fill:#ffe5b4,stroke:#995700,color:#995700;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
