# kingshokha/shahboz_calculator architecture

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

- Interactive diagram: https://gitdiagram.com/kingshokha/shahboz_calculator
- Repository: https://github.com/kingshokha/shahboz_calculator

## Overview

#### Purpose and Runtime

Shahboz Calculator is a standalone, browser-only shopping calculator. It lets users maintain a product catalog, add priced quantities to a receipt, calculate totals, and copy a formatted receipt. No build system, backend, dependencies, or network service is required.

Entry point: `index.html`, which loads the application behavior from `app.js` and presentation rules from `style.css`.

#### UI Shell and Interaction Surface

`index.html` defines the calculator’s static UI structure: catalog management, product/quantity selection, receipt/history display, total summary, and copy/clear actions. It is the boundary between user input and the JavaScript state/update logic.

Responsive and dark-theme presentation is contained in `style.css`; it adapts the same UI for phone, tablet, and desktop layouts without introducing another runtime layer.

#### Client Application Controller

`app.js` is the primary application controller and contains the runtime behavior. It binds DOM controls from `index.html` to catalog edits, selection changes, quantity increment/decrement actions, receipt mutations, total recalculation, clearing, and clipboard export.

The app uses direct browser DOM manipulation rather than a framework, component runtime, or server-rendered interface.

#### Product Catalog State and Persistence

The product catalog consists of product names and per-unit prices. Catalog create, edit, and delete operations originate in the UI defined by `index.html` and are managed in `app.js`.

Catalog persistence crosses the browser-storage boundary through `localStorage`, allowing products to survive page reloads while remaining local to the user’s browser. There is no shared database, authentication, or remote synchronization.

#### Receipt Calculation Flow

A user selects a catalog product and quantity in `index.html`. `app.js` resolves the selected unit price, updates the live line-item preview, and appends the confirmed item to the in-memory receipt/history.

Each receipt item carries the product, unit price, quantity, and derived line total. Receipt rendering and aggregate calculations are updated after additions, removals, and full receipt clearing.

#### Totals and Export Boundary

`app.js` computes the receipt’s overall monetary total and total item count from the current receipt state, then updates the summary UI in `index.html`.

The copy action formats the current receipt into text and sends it through the browser clipboard API. This is the only external browser capability beyond `localStorage`; no receipt data is exported to a server.

#### Deployment Model

The repository is deployable as static files: `index.html`, `app.js`, and `style.css`. It can be opened directly from disk in a modern browser or hosted by any static-file server. All application state is client-side; only the catalog is durable via browser-local storage.

Main entry points: [`app.js`](https://github.com/kingshokha/shahboz_calculator/blob/main/app.js) (Application controller), [`index.html`](https://github.com/kingshokha/shahboz_calculator/blob/main/index.html) (Application shell), [`style.css`](https://github.com/kingshokha/shahboz_calculator/blob/main/style.css) (Responsive theme)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_static["Static application"]
  node_html["Application shell<br/>HTML entry point<br/>[index.html]"]
  node_styles["Responsive theme<br/>CSS presentation<br/>[style.css]"]
  node_app["Application controller<br/>browser JavaScript<br/>[app.js]"]
end

subgraph group_runtime["Browser runtime"]
  node_catalog_ui["Catalog controls<br/>UI surface<br/>[index.html]"]
  node_selection_ui["Product and quantity input<br/>UI surface<br/>[index.html]"]
  node_receipt_ui["Receipt and summary<br/>UI surface<br/>[index.html]"]
  node_catalog_state["Product catalog<br/>client state<br/>[app.js]"]
  node_receipt_state["Receipt history<br/>in-memory state<br/>[app.js]"]
  node_calculation["Pricing and totals<br/>calculation logic<br/>[app.js]"]
  node_local_storage[("Browser localStorage<br/>browser storage")]
  node_clipboard["Browser clipboard<br/>browser API"]
end

node_html -->|"loads"| node_app
node_html -->|"loads"| node_styles
node_styles -->|"styles"| node_catalog_ui
node_styles -->|"styles"| node_selection_ui
node_styles -->|"styles"| node_receipt_ui
node_html -->|"defines"| node_catalog_ui
node_html -->|"defines"| node_selection_ui
node_html -->|"defines"| node_receipt_ui
node_catalog_ui -->|"catalog events"| node_app
node_selection_ui -->|"selection events"| node_app
node_receipt_ui -->|"receipt actions"| node_app
node_app -->|"manages"| node_catalog_state
node_app -->|"mutates"| node_receipt_state
node_catalog_state -->|"persists"| node_local_storage
node_local_storage -.->|"restores"| node_catalog_state
node_catalog_state -->|"unit prices"| node_calculation
node_receipt_state -->|"line items"| node_calculation
node_calculation -->|"renders totals"| node_receipt_ui
node_receipt_state -->|"renders history"| node_receipt_ui
node_app -->|"copies formatted receipt"| node_clipboard

click node_html "https://github.com/kingshokha/shahboz_calculator/blob/main/index.html"
click node_styles "https://github.com/kingshokha/shahboz_calculator/blob/main/style.css"
click node_app "https://github.com/kingshokha/shahboz_calculator/blob/main/app.js"
click node_catalog_ui "https://github.com/kingshokha/shahboz_calculator/blob/main/index.html"
click node_selection_ui "https://github.com/kingshokha/shahboz_calculator/blob/main/index.html"
click node_receipt_ui "https://github.com/kingshokha/shahboz_calculator/blob/main/index.html"
click node_catalog_state "https://github.com/kingshokha/shahboz_calculator/blob/main/app.js"
click node_receipt_state "https://github.com/kingshokha/shahboz_calculator/blob/main/app.js"
click node_calculation "https://github.com/kingshokha/shahboz_calculator/blob/main/app.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_html,node_styles,node_app toneBlue
class node_catalog_ui,node_selection_ui,node_receipt_ui,node_catalog_state,node_receipt_state,node_calculation,node_local_storage,node_clipboard toneAmber
```

## Components

### Static application

Files loaded directly by the browser.

- [Application shell](https://github.com/kingshokha/shahboz_calculator/blob/main/index.html): HTML entry point · Defines calculator controls, receipt display, and actions. · `index.html`
- [Responsive theme](https://github.com/kingshokha/shahboz_calculator/blob/main/style.css): CSS presentation · Provides responsive and dark-theme styling. · `style.css`
- [Application controller](https://github.com/kingshokha/shahboz_calculator/blob/main/app.js): browser JavaScript · Binds controls and coordinates all calculator updates. · `app.js`

### Browser runtime

Client-side state and browser capabilities.

- [Catalog controls](https://github.com/kingshokha/shahboz_calculator/blob/main/index.html): UI surface · Creates, edits, and deletes products. · `index.html`
- [Product and quantity input](https://github.com/kingshokha/shahboz_calculator/blob/main/index.html): UI surface · Selects products and adjusts quantities. · `index.html`
- [Receipt and summary](https://github.com/kingshokha/shahboz_calculator/blob/main/index.html): UI surface · Displays line items, totals, copy, and clear actions. · `index.html`
- [Product catalog](https://github.com/kingshokha/shahboz_calculator/blob/main/app.js): client state · Stores product names and unit prices. · `app.js`
- [Receipt history](https://github.com/kingshokha/shahboz_calculator/blob/main/app.js): in-memory state · Stores confirmed receipt line items. · `app.js`
- [Pricing and totals](https://github.com/kingshokha/shahboz_calculator/blob/main/app.js): calculation logic · Derives line totals, item count, and receipt total. · `app.js`
- **Browser localStorage**: browser storage · Persists the catalog across reloads.
- **Browser clipboard**: browser API · Receives formatted receipt text.

## Connections

- Application shell → Application controller: loads
- Application shell → Responsive theme: loads
- Responsive theme → Catalog controls: styles
- Responsive theme → Product and quantity input: styles
- Responsive theme → Receipt and summary: styles
- Application shell → Catalog controls: defines
- Application shell → Product and quantity input: defines
- Application shell → Receipt and summary: defines
- Catalog controls → Application controller: catalog events
- Product and quantity input → Application controller: selection events
- Receipt and summary → Application controller: receipt actions
- Application controller → Product catalog: manages
- Application controller → Receipt history: mutates
- Product catalog → Browser localStorage: persists
- Browser localStorage → Product catalog: restores
- Product catalog → Pricing and totals: unit prices
- Receipt history → Pricing and totals: line items
- Pricing and totals → Receipt and summary: renders totals
- Receipt history → Receipt and summary: renders history
- Application controller → Browser clipboard: copies formatted receipt
