How pragadesh-waran/e-commerce works
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