Calculator is a browser-first application built from static assets and vanilla JavaScript modules.
The app renders a single shell from app.html, persists user state in the browser, and keeps
mode-specific UI code isolated under scripts/Views and styles/Views.
The web app has four top-level entry points:
index.htmlserves the public landing page, links the manifest, and registers the service worker so PWA install flows can begin thereapp.htmlloads the CSS and JavaScript bundles used by the browser shell and remains the installed app start surfacemanifest.jsondefines install metadata for the PWAservice-worker.jskeeps the app installable as a PWA without caching network responses
The page boot sequence is:
app.htmlloads the shared styles andscripts/startup.jsstartup.jsloads startup dependencies, registers the service worker, and starts the appscripts/app.jsreads URL state, hydrates persisted data, wires events, and triggers the first render
The landing page boot sequence is:
index.htmlloads the marketing layout and links the web app manifestscripts/landing.jsregistersservice-worker.jsso supported browsers can offer installation- The manifest start URL launches
app.html?page=standard, so installed launches open the calculator app rather than the public page
Application state is centralized in scripts/state.js.
That module is responsible for:
- restoring history, memory, navigation, and theme settings from local storage
- exposing the mutable state object used by render and event flows
- persisting state updates after user actions
The storage keys are defined in scripts/config.js so the rest of the app can stay consistent
about how browser persistence is handled.
Business logic lives primarily in scripts/logic.js.
That module handles:
- calculator evaluation and operator workflows
- programmer mode behavior and base conversions
- date calculation logic
- unit conversion transforms
- graphing-related calculations shared with the graphing view
Static configuration for modes, buttons, converter categories, and metadata lives in
scripts/config.js.
The UI is assembled from small rendering modules rather than a framework runtime.
Key view files include:
scripts/Views/MainPage.jsfor the shared shell and navigation layoutscripts/Views/Calculator.jsfor standard, scientific, and programmer surfacesscripts/Views/DateCalculator.jsfor date workflowsscripts/Views/UnitConverter.jsfor converter layoutsscripts/Views/GraphingCalculator/GraphingCalculator.jsfor graphing modescripts/Views/HistoryList.js,Memory.js, andSettings.jsfor side panels and support surfaces
Each view returns HTML strings that are inserted into the main shell and then bound to the relevant
event handlers from scripts/app.js.
The visual system is split between shared tokens and view-specific styles:
styles/theme.cssdefines tokens, color roles, and base element stylingstyles/Views/contains one stylesheet per feature areastyles/responsive.csshandles viewport-specific layout changes
The app is expected to work across phone, tablet, and desktop widths without changing the runtime architecture. Responsive behavior is implemented with CSS layout rules and view-aware rendering decisions, not separate builds.
service-worker.js exists to satisfy the PWA install requirement, but it does not pre-cache app
assets or intercept fetches. Network requests still go directly to the server for the latest files.
The repository is intentionally lightweight:
- no bundler is required for local development
- no server-side runtime is required for the app itself
- validation is currently centered on
npm run checkplus manual browser testing
When adding new features, prefer extending the existing module boundaries instead of creating a new application layer. Most changes should fit into one or more of these buckets: config, state, logic, view rendering, and styling.