# adhilgafoor00-stack/online_computer_hardware_selling_web_project architecture

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

- Interactive diagram: https://gitdiagram.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project
- Repository: https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project

## Overview

This is a **small full‑stack e‑commerce web application**:
- **Frontend**: static **vanilla HTML/CSS/JS** pages (multiple entry points: `index.html`, `products.html`, `cart.html`, `order.html`, `admin.html`, etc.)
- **Backend**: **Flask / Flask‑RESTful** API in `backend/app.py`
- **Persistence**: **SQLite** dev database (`backend/database.db`), with an intended **PostgreSQL** production option
- **Core domains**: product catalog, cart, orders, authentication/authorization, and admin management

- Browser-based UI → REST API → database
- Role separation (customer vs admin)
- Major API resources (products, cart, orders, auth, admin)
- Where static assets live and how they’re served/deployed

Top-level structure indicates a **monorepo** with a static front end and a Python backend:

**Frontend (static)**
- HTML pages at repo root:
`index.html`, `products.html`, `cart.html`, `order.html`, `pc-builder.html`, `admin.html`, `register.html`, `signup.html`, `service.html`
- Assets:
`css/style.css`, `js/script.js`, `images/`

**Backend**
- `backend/app.py` → likely contains Flask app creation + routing/resources for `/api/...`
- `backend/requirements.txt` → runtime deps (Flask, Flask‑RESTful, SQLAlchemy)
- `backend/database.db` → SQLite file (dev persistence)

**Config/IDE**

##### README-derived architecture details
From README:
- REST API endpoints for products/cart/orders/admin/auth
- Auth includes password hashing + role-based access control (RBAC)
- DB: SQLite (dev) / PostgreSQL (prod)
- “Admin dashboard” exists (admin UI + admin API routes)

This project is small enough that one page can contain Level 1 + a simplified Level 2 callout.

##### Architectural patterns / principles to highlight
- **Client–Server** with **RESTful API**
- **Resource-based routing** (products, cart, orders, auth, admin)
- **RBAC** for admin operations
- **ORM-based persistence** (SQLAlchemy)
- **Environment-dependent DB** (SQLite vs PostgreSQL)

##### Labels (be explicit)
- Name components with both **role + artifact**:
- “Frontend Pages (HTML)” + list key pages
- “Frontend Logic (`js/script.js` - Fetch/AJAX)”
- “Flask REST API (`backend/app.py` / Flask‑RESTful)”
- “SQLAlchemy ORM”
- “Relational DB (SQLite dev / Postgres prod)”

- Browser → Static hosting: “GET /index.html, /css/style.css, /js/script.js”
- Browser JS → Flask API: “HTTPS JSON REST”
- Flask API → DB: “SQLAlchemy (CRUD)”
- DB → Flask → Browser: “JSON responses”

##### Don’t overthink it: split into *more* components than fewer
- API Gateway/Flask routing
- Auth/RBAC
- Catalog
- Cart
- Orders
- Admin
- ORM layer
- DB

Even if all of that is currently in `backend/app.py`, it’s still the real architecture at the system level.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% ========= Users =========
  subgraph "Users"
    Cust["Customer"]:::external
    Adm["Admin"]:::external
  end

  %% ========= Client / Browser =========
  subgraph "Client (Web Browser)"
    subgraph "Frontend Pages (Static HTML)"
      Index["Landing Page (index.html)"]:::frontend
      Products["Product Catalog (products.html)"]:::frontend
      Cart["Cart (cart.html)"]:::frontend
      Order["Checkout / Order (order.html)"]:::frontend
      PCBuilder["PC Builder (pc-builder.html)"]:::frontend
      Register["Register (register.html)"]:::frontend
      Signup["Signup (signup.html)"]:::frontend
      Service["Service (service.html)"]:::frontend
      AdminUI["Admin Dashboard (admin.html)"]:::frontend
    end

    subgraph "Shared Frontend Assets"
      Script["Frontend Logic (Fetch/AJAX client)"]:::frontend
      Styles["Styles (CSS)"]:::frontend
      Images["Images / Static Assets"]:::frontend
    end
  end

  %% ========= Delivery / Hosting =========
  subgraph "Delivery (Deployment Options)"
    StaticHost["Static Web Server (or Flask static)"]:::infra
    APIServer["API Host"]:::infra
  end

  %% ========= Backend =========
  subgraph "Backend (Flask / Flask-RESTful)"
    FlaskApp["Flask REST API (App + Routing)"]:::backend

    subgraph "API Resources (logical modules)"
      Auth["Auth Service\nPOST /api/auth/login\nPOST /api/auth/register"]:::backend
      ProductsAPI["Product Service\nGET /api/products\nGET /api/products/<id>"]:::backend
      CartAPI["Cart Service\nPOST /api/cart\nPUT /api/cart/<item_id>\nDELETE /api/cart/<item_id>"]:::backend
      OrdersAPI["Order Service\nPOST /api/orders"]:::backend
      AdminAPI["Admin Service\nGET /api/admin/users\n(+admin mgmt endpoints)"]:::backend
    end

    subgraph "Cross-cutting"
      RBAC["RBAC Guards (admin-only routes)"]:::backend
      Hashing["Password Hashing / Verification"]:::backend
      ORM["SQLAlchemy ORM"]:::backend
    end

    Deps["Python Dependencies\n(Flask, Flask-RESTful, SQLAlchemy, ...)"]:::backendSupport
  end

  %% ========= Data =========
  subgraph "Data"
    DB[("Relational DB\nSQLite (dev) / PostgreSQL (prod)")]:::database
  end

  %% ========= User -> Pages =========
  Cust -->|"uses"| Index
  Cust -->|"uses"| Products
  Cust -->|"uses"| Cart
  Cust -->|"uses"| Order
  Cust -->|"uses"| PCBuilder
  Cust -->|"uses"| Register
  Cust -->|"uses"| Signup
  Cust -->|"uses"| Service
  Adm -->|"uses"| AdminUI

  %% ========= Static asset loading =========
  Index -->|"loads"| Script
  Products -->|"loads"| Script
  Cart -->|"loads"| Script
  Order -->|"loads"| Script
  PCBuilder -->|"loads"| Script
  Register -->|"loads"| Script
  Signup -->|"loads"| Script
  Service -->|"loads"| Script
  AdminUI -->|"loads"| Script

  Index -->|"loads"| Styles
  Products -->|"loads"| Styles
  Cart -->|"loads"| Styles
  Order -->|"loads"| Styles
  PCBuilder -->|"loads"| Styles
  Register -->|"loads"| Styles
  Signup -->|"loads"| Styles
  Service -->|"loads"| Styles
  AdminUI -->|"loads"| Styles

  Script -->|"loads"| Images

  %% ========= Delivery paths =========
  Cust -->|"GET /*.html, /css/*, /js/*, /images/*"| StaticHost
  Adm -->|"GET /admin.html, /css/*, /js/*"| StaticHost
  StaticHost -->|"serves static content"| Index
  StaticHost -->|"serves static content"| Products
  StaticHost -->|"serves static content"| Cart
  StaticHost -->|"serves static content"| Order
  StaticHost -->|"serves static content"| PCBuilder
  StaticHost -->|"serves static content"| Register
  StaticHost -->|"serves static content"| Signup
  StaticHost -->|"serves static content"| Service
  StaticHost -->|"serves static content"| AdminUI
  StaticHost -->|"serves"| Script
  StaticHost -->|"serves"| Styles
  StaticHost -->|"serves"| Images

  Script -->|"HTTPS JSON REST /api/*"| APIServer
  APIServer -->|"routes to Flask"| FlaskApp

  %% ========= API internal wiring =========
  FlaskApp -.->|"dispatches"| Auth
  FlaskApp -.->|"dispatches"| ProductsAPI
  FlaskApp -.->|"dispatches"| CartAPI
  FlaskApp -.->|"dispatches"| OrdersAPI
  FlaskApp -.->|"dispatches"| AdminAPI

  Auth -.->|"uses"| Hashing
  AdminAPI -.->|"enforced by"| RBAC

  Auth -->|"CRUD (Users)"| ORM
  ProductsAPI -->|"CRUD (Products)"| ORM
  CartAPI -->|"CRUD (Cart/CartItems)"| ORM
  OrdersAPI -->|"CRUD (Orders/OrderItems)"| ORM
  AdminAPI -->|"CRUD (Users/Orders/Products)"| ORM

  ORM -->|"SQL (CRUD)"| DB

  %% ========= Key request flows (explicit) =========
  Script -->|"GET /api/products"| ProductsAPI
  Script -->|"GET /api/products/<id>"| ProductsAPI
  Script -->|"POST /api/cart"| CartAPI
  Script -->|"PUT /api/cart/<item_id>"| CartAPI
  Script -->|"DELETE /api/cart/<item_id>"| CartAPI
  Script -->|"POST /api/orders"| OrdersAPI
  Script -->|"POST /api/auth/login"| Auth
  Script -->|"POST /api/auth/register"| Auth
  Script -->|"GET /api/admin/users"| AdminAPI

  Auth -->|"returns session cookie or token"| Script
  ProductsAPI -->|"returns JSON"| Script
  CartAPI -->|"returns JSON"| Script
  OrdersAPI -->|"returns JSON"| Script
  AdminAPI -->|"returns JSON"| Script

  %% ========= Click events (component_mapping) =========
  click Index "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/index.html"
  click Products "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/products.html"
  click Cart "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/cart.html"
  click Order "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/order.html"
  click PCBuilder "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/pc-builder.html"
  click Register "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/register.html"
  click Signup "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/signup.html"
  click Service "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/service.html"
  click AdminUI "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/admin.html"
  click Script "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/js/script.js"
  click Styles "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/css/style.css"
  click Images "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/tree/master/images/"
  click FlaskApp "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/app.py"
  click Auth "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/app.py"
  click RBAC "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/app.py"
  click ProductsAPI "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/app.py"
  click CartAPI "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/app.py"
  click OrdersAPI "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/app.py"
  click AdminAPI "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/app.py"
  click DB "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/database.db"
  click Deps "https://github.com/adhilgafoor00-stack/online_computer_hardware_selling_web_project/blob/master/backend/requirements.txt"

  %% ========= Styles =========
  classDef external fill:#E5E7EB,stroke:#6B7280,color:#111827,stroke-width:1px
  classDef frontend fill:#DBEAFE,stroke:#2563EB,color:#0F172A,stroke-width:1px
  classDef backend fill:#DCFCE7,stroke:#16A34A,color:#052e16,stroke-width:1px
  classDef backendSupport fill:#ECFDF5,stroke:#22C55E,color:#064e3b,stroke-width:1px
  classDef database fill:#FFEDD5,stroke:#F97316,color:#7C2D12,stroke-width:1px
  classDef infra fill:#F3F4F6,stroke:#9CA3AF,color:#111827,stroke-width:1px
```
