# pragadesh-waran/e-commerce architecture

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

- Interactive diagram: https://gitdiagram.com/pragadesh-waran/e-commerce
- Repository: https://github.com/pragadesh-waran/e-commerce

## Overview

This is a **static, multi-page, front-end-only e-commerce site** (“minimal e-commerce”) with:
- **Two HTML pages** (Home + Shop)
- **A shared cart** persisted in **`localStorage`**
- **Checkout and inquiries via WhatsApp deep links** (no backend, no database)
- Product catalog/config stored in a local JS module (`data.js`)

- **Client-side modules** and their responsibilities
- **State/storage boundaries** (in-memory vs `localStorage`)
- **Integration to external service** (WhatsApp)
- **Navigation between pages** and shared UI (cart drawer on both pages)

There is no server component beyond a static file host (e.g., `python -m http.server`), so do not invent API layers or databases.

##### File-structure-driven component breakdown
From the tree:

- `index.html` — Home page shell
- `products.html` — Shop page shell
- `styles.css` — Global styling and CSS variables
- `data.js` — Product catalog + configuration (`products`, `CATEGORIES`, `WHATSAPP_NUMBER`)
- `script.js` — Shared runtime logic: cart + shared UI elements across pages
- `products-page.js` — Shop-only logic: category dropdown, filtering, “coming soon” notice, product grid
- `images/` — Static assets

This naturally maps to **three layers** on the client:
##### Data/config + persistence: `data.js` + `localStorage`

And one **external integration**:
- **WhatsApp** (deep link / send message)

##### Delivery / Runtime boundary
- **Static File Host** (any static server / CDN / local python server)
- Serves: `index.html`, `products.html`, `.js`, `.css`, `images/*`
- Everything below executes here

##### Pages (top-level UI entry points)
Inside “Browser”, show two entry points:
- **Home Page (`index.html`)**
- Renders hero, featured products
- Links to shop
- Includes cart drawer UI
- **Shop Page (`products.html`)**
- Renders category dropdown + product grid
- Clothing category “coming soon” notice
- Includes cart drawer UI

##### Shared modules
- **Product & Config Module (`data.js`)**
- Exposes `products[]`, `CATEGORIES`, `WHATSAPP_NUMBER`
- **Shared Cart / UI Controller (`script.js`)**
- Cart operations: add, remove, qty update
- Cart drawer UI behavior (open/close/update)
- Persists cart to `localStorage`
- Generates WhatsApp order message + link

##### Page-specific module
- **Shop Controller (`products-page.js`)**
- Category dropdown custom UI
- Filter logic: Intimate Jewellery renders grid; Clothing renders notice
- Hooks “Add to cart” buttons into shared cart module (`script.js`)

##### Storage + external service
- **Browser `localStorage`**
- Stores cart state (line items, qty)
- **WhatsApp (External)**
- “Checkout” deep link sends formatted order summary
- “Inquire” deep link per product

##### Page load / composition
- `index.html` → loads → `styles.css`
- `index.html` → loads → `data.js`
- `index.html` → loads → `script.js`

- `products.html` → loads → `styles.css`
- `products.html` → loads → `data.js`
- `products.html` → loads → `script.js`
- `products.html` → loads → `products-page.js`

##### Catalog usage
- `script.js` → reads → `data.js` (for WhatsApp number and/or product info if needed)
- `products-page.js` → reads → `data.js` (products + categories)

##### Cart state lifecycle
- User action (“Add to cart”, “Update qty”, “Remove”) → `script.js`
- `script.js` ↔ updates UI in DOM (cart drawer)
- `script.js` ↔ reads/writes ↔ `localStorage` (persist + restore on page load)

##### Checkout/inquiry
- “Checkout” click → `script.js` → constructs message → opens `https://wa.me/<number>?text=...` → **WhatsApp**
- “Inquire” click (per product) → (page or `products-page.js`) → opens WhatsApp deep link → **WhatsApp**

##### Navigation
- `index.html` → link → `products.html`
- That **cart persists across navigation** due to `localStorage`

##### Architectural patterns / design principles to highlight
Even though it’s small, capture these explicitly:

- **No-backend / JAMstack-style static site**: all logic runs client-side.
- **Module separation by responsibility**:
- `data.js` = source of truth for catalog/config
- `script.js` = shared cart + shared UI (cross-page)
- `products-page.js` = page-specific behavior
- **State persistence pattern**: `localStorage` as the “database” for cart
- **Externalized checkout**: order submission delegated to WhatsApp instead of server-side order APIs

- User ↔ Browser-based site
- Site ↔ WhatsApp
- Site ↔ localStorage (as internal dependency)
- Static host as the delivery mechanism

This avoids the common mistake of drawing a fake “Backend API” or “Database”.

- Cart drawer exists on **both pages**
- Cart persistence via `localStorage` enables cross-page continuity
- Category dropdown with two categories; one is “coming soon”
- Checkout is not a payment flow; it’s a **message handoff** to WhatsApp
- `data.js` is the single place to edit products, categories, WhatsApp number

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Actors / External
  U([User]):::actor
  WA["WhatsApp (External)\nwa.me deep link"]:::external

  %% Delivery
  HOST["Static File Host\n(HTTP server / CDN)"]:::host

  %% Browser boundary
  subgraph B["Browser (Client Runtime)"]
    direction TB

    %% Shared assets
    subgraph ASSETS["Static assets & styling"]
      direction TB
      CSS["styles.css\n(Global styling + CSS variables)"]:::asset
      IMGS["images/*\n(Static images)"]:::asset
    end

    %% Data/config + persistence
    subgraph DATASTORE["Data/config & persistence"]
      direction TB
      DATA["data.js\n(products[], CATEGORIES, WHATSAPP_NUMBER)"]:::data
      LS[("localStorage\n(cart state: line items + qty)")]:::storage
    end

    %% Shared logic
    subgraph SHARED["Shared runtime (cross-page)"]
      direction TB
      CARTUI["Cart Drawer UI\n(shared on both pages)"]:::ui
      SHAREDJS["script.js\nCart ops + drawer behavior\nPersist/restore cart\nWhatsApp checkout link"]:::logic
    end

    %% Pages (UI entry points)
    subgraph PAGES["Pages (UI entry points)"]
      direction TB

      subgraph HOME["Home Page"]
        direction TB
        INDEX["index.html\nHero + Featured products\nLink to Shop"]:::page
      end

      subgraph SHOP["Shop Page"]
        direction TB
        PRODUCTS["products.html\nCategory dropdown + product grid\nClothing: 'coming soon'"]:::page
        SHOPJS["products-page.js\nDropdown UI + filtering\nWires 'Add to cart'\nInquire links"]:::logic
      end
    end
  end

  %% Delivery / runtime relationships
  U -->|"HTTP GET"| HOST
  HOST -->|"serves HTML/CSS/JS/images"| B

  %% Page loads / composition (order: data before logic)
  INDEX -->|"loads CSS"| CSS
  INDEX -->|"loads images"| IMGS
  INDEX -->|"loads (before logic)"| DATA
  INDEX -->|"loads shared runtime"| SHAREDJS

  PRODUCTS -->|"loads CSS"| CSS
  PRODUCTS -->|"loads images"| IMGS
  PRODUCTS -->|"loads (before logic)"| DATA
  PRODUCTS -->|"loads shared runtime"| SHAREDJS
  PRODUCTS -->|"loads shop controller"| SHOPJS

  %% Catalog usage
  SHAREDJS -->|"reads config/products as needed"| DATA
  SHOPJS -->|"reads products + categories"| DATA

  %% Cart lifecycle + UI updates
  U -->|"add/remove/update qty"| SHAREDJS
  SHAREDJS -->|"updates cart drawer DOM"| CARTUI
  SHAREDJS <-->|"persists cart / hydrates on load"| LS

  %% Shop interactions
  U -->|"select category"| SHOPJS
  SHOPJS -->|"calls shared cart ops"| SHAREDJS

  %% Navigation + persistence note
  INDEX -->|"navigate (Shop link)"| PRODUCTS
  LS -.->|"cart persists across pages"| CARTUI

  %% Checkout / inquiry handoff
  U -->|"checkout click"| SHAREDJS
  SHAREDJS -->|"opens wa.me with order summary"| WA
  U -->|"inquire click (per product)"| SHOPJS
  SHOPJS -->|"opens wa.me with product text"| WA

  %% Click events (component mapping)
  click INDEX "https://github.com/pragadesh-waran/e-commerce/blob/main/index.html"
  click PRODUCTS "https://github.com/pragadesh-waran/e-commerce/blob/main/products.html"
  click CSS "https://github.com/pragadesh-waran/e-commerce/blob/main/styles.css"
  click DATA "https://github.com/pragadesh-waran/e-commerce/blob/main/data.js"
  click SHAREDJS "https://github.com/pragadesh-waran/e-commerce/blob/main/script.js"
  click SHOPJS "https://github.com/pragadesh-waran/e-commerce/blob/main/products-page.js"
  click IMGS "https://github.com/pragadesh-waran/e-commerce/tree/main/images/"

  %% Styles
  classDef actor fill:#ffffff,stroke:#111827,stroke-width:2px,color:#111827
  classDef host fill:#eef2ff,stroke:#4338ca,stroke-width:2px,color:#111827
  classDef page fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#0b1b3a
  classDef logic fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#052e12
  classDef data fill:#e0f2fe,stroke:#0284c7,stroke-width:2px,color:#082f49
  classDef asset fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#111827
  classDef storage fill:#ffedd5,stroke:#f97316,stroke-width:2px,color:#7c2d12
  classDef external fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px,color:#2e1065
  classDef ui fill:#e0e7ff,stroke:#4f46e5,stroke-width:2px,color:#1e1b4b
```
