# pramod-vishwakarma/restaurant-pwa architecture

> Architecture diagram of the GitHub repository pramod-vishwakarma/restaurant-pwa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pramod-vishwakarma/restaurant-pwa
- Repository: https://github.com/pramod-vishwakarma/restaurant-pwa

## Overview

##### Project Type and Purpose
- This is a front-end–only Progressive Web App (PWA) for a restaurant site: a static, multi-page application built with HTML, CSS3 (compiled from SCSS), JavaScript (including jQuery), and Material Bootstrap (MDB).
- There is no backend service or database in this repo; all pages and interaction logic live in the client.

##### High-Level Component Breakdown
a. Client / Browser
- Renders HTML pages (index.html, home.html, menu.html, add-to-cart.html, feedback.html, etc.).
- Executes JavaScript logic for UI interactions (cart management, feedback forms, page navigation).
- Stores transient data (e.g., shopping cart contents) in localStorage or IndexedDB.
b. Service Worker (PWA layer)
- Caches HTML, CSS, JS, and image assets for offline availability (even if not explicitly provided, you’d include this in the PWA design).
- Intercepts network requests to serve cached assets or fall back to offline page.
c. Static Asset Server / CDN (or GitHub Pages, Netlify, etc.)
- Hosts all the compiled resources: HTML, CSS, JS bundles, images.
d. Build Pipeline (Dev-time)
- SCSS source → compiled CSS (css/style.css).
- JS libraries (Bootstrap/MDB, custom scripts) consolidated and minified.

##### Relationships and Data Flow
- User opens the PWA in the browser → Browser checks for Service Worker → SW installs and caches assets.
- For each page navigation:
- Browser requests HTML → SW serves from cache or network.
- HTML references CSS and JS → SW serves from cache → Browser renders UI.
- User actions (add to cart, submit feedback) → Custom JS updates the DOM and persists data in localStorage.
- Build step (outside of the user’s session) compiles SCSS to CSS and bundles JavaScript libraries.

##### Architectural Patterns & Design Principles
- Progressive Enhancement: starts as a static multi-page site, layered with JS for richer UX.
- PWA Cache-First strategy: static assets served from the Service Worker cache.
- Modular CSS/JS:
- SCSS folders organized by bootstrap-rtl-fix, bootstrap, free, custom → logical separation of vendor vs override vs custom styles.
- JS under src/js → splits Bootstrap source, free MDB scripts, utilities.
- No server-side MVC; all rendering and state management occur client-side.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build Pipeline
    subgraph "Build Pipeline"
        direction TB
        BP_DIR["SCSS Source Directory"]:::build
        BP_CSS["Compiled CSS (css/style.css)"]:::build
        BP_JS_SRC["JS Source (src/js/)"]:::build
        JS_BUNDLE["Compiled JS Bundles (js/)"]:::build
        CUSTOM1["_styles.scss"]:::build
        CUSTOM2["_variables.scss"]:::build
    end

    BP_DIR -->|"compile SCSS"| BP_CSS
    BP_DIR -->|"includes custom styles"| CUSTOM1
    BP_DIR -->|"includes custom variables"| CUSTOM2
    BP_JS_SRC -->|"bundle JS"| JS_BUNDLE

    %% Asset Server / CDN
    subgraph "Asset Server / CDN"
        direction TB
        AS_HTML["Static HTML Pages"]:::asset
        AS_CSS["Compiled CSS (css/style.css)"]:::asset
        AS_JS["Compiled JS Bundles (js/)"]:::asset
        AS_IMG["Image Assets (img/)"]:::asset
    end

    BP_CSS -->|"deploy CSS"| AS_CSS
    JS_BUNDLE -->|"deploy JS"| AS_JS

    %% Browser / PWA Shell
    subgraph "Browser / PWA Shell"
        direction TB
        SW["Service Worker"]:::runtime
        UI["Browser UI (HTML Pages + JS)"]:::runtime
        STORAGE["localStorage / IndexedDB"]:::runtime
    end

    AS_HTML -->|"GET index.html"| SW
    AS_CSS -->|"Cache CSS"| SW
    AS_JS -->|"Cache JS"| SW
    AS_IMG -->|"Cache images"| SW

    SW -->|"serve cached assets"| UI
    UI -->|"Read/Write cart data"| STORAGE

    %% External API (future)
    API["External API / Backend"]:::external
    UI -.->|"REST call"| API

    %% Click Events
    click BP_DIR "https://github.com/pramod-vishwakarma/restaurant-pwa/tree/main/src/scss/"
    click BP_CSS "https://github.com/pramod-vishwakarma/restaurant-pwa/blob/main/css/style.css"
    click BP_JS_SRC "https://github.com/pramod-vishwakarma/restaurant-pwa/tree/main/src/js/"
    click JS_BUNDLE "https://github.com/pramod-vishwakarma/restaurant-pwa/tree/main/js/"
    click CUSTOM1 "https://github.com/pramod-vishwakarma/restaurant-pwa/blob/main/src/scss/custom/_styles.scss"
    click CUSTOM2 "https://github.com/pramod-vishwakarma/restaurant-pwa/blob/main/src/scss/custom/_variables.scss"
    click AS_HTML "https://github.com/pramod-vishwakarma/restaurant-pwa/blob/main/index.html"
    click AS_JS "https://github.com/pramod-vishwakarma/restaurant-pwa/tree/main/js/"
    click AS_IMG "https://github.com/pramod-vishwakarma/restaurant-pwa/tree/main/img/"

    %% Styles
    classDef build fill:#bbbbbb,stroke:#333,stroke-width:1px,color:#000
    classDef asset fill:#a3c9f1,stroke:#036,stroke-width:1px,color:#000
    classDef runtime fill:#b2f2b2,stroke:#070,stroke-width:1px,color:#000
    classDef external fill:none,stroke-dasharray: 5 5,stroke:#888,color:#888
```
