# sumit-chame/currancy_converter architecture

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

- Interactive diagram: https://gitdiagram.com/sumit-chame/currancy_converter
- Repository: https://github.com/sumit-chame/currancy_converter

## Overview

This is a browser-based currency converter. Users choose currencies and an amount, then the app fetches rates, applies any fee/spread, and displays the converted result; they can also inspect historical rates and export chart data. The modular app delegates rate retrieval to a tiered API layer and keeps rate data in a versioned local cache. The README documents URL sharing and PWA support. The sampled excerpts show the main module’s wiring, but some feature details and the worker-to-app request are documented rather than directly sampled.

Main entry points: [`src/main.js`](https://github.com/sumit-chame/currancy_converter/blob/main/src/main.js) (App bootstrap), [`src/api.js`](https://github.com/sumit-chame/currancy_converter/blob/main/src/api.js) (Rate API orchestration), [`worker/src/index.js`](https://github.com/sumit-chame/currancy_converter/blob/main/worker/src/index.js) (Live rates proxy), [`src/cache.js`](https://github.com/sumit-chame/currancy_converter/blob/main/src/cache.js) (Versioned rate cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Conversion experience"]
  node_bootstrap["App bootstrap<br/>[main.js]"]
  node_conversion["Conversion and fees<br/>[main.js]"]
  node_preferences["Preferences and sharing<br/>[main.js]"]
  node_formatting["Currency formatting<br/>[ui.js]"]
  node_appstate["App state<br/>[state.js]"]
  node_standalone["Standalone app engine<br/>[index.js]"]
end

subgraph group_data["Rates and cache"]
  node_api["Rate API orchestration<br/>[api.js]"]
  node_worker["Live rates proxy<br/>[index.js]"]
  node_providers["Rate providers"]
  node_ratecache["Versioned rate cache<br/>[cache.js]"]
  node_browserstorage[("Browser storage")]
end

subgraph group_analytics["History analytics"]
  node_historical["Historical lookup<br/>[api.js]"]
  node_chart["Chart and statistics<br/>[chart.js]"]
  node_exports["CSV and PNG export<br/>[chart.js]"]
end

subgraph group_platform["Offline platform"]
  node_pwa["Offline service worker<br/>[service-worker.js]"]
  node_appassets[("Cached app assets")]
end

node_user(("Currency user"))

node_user -->|"uses"| node_bootstrap
node_bootstrap -->|"wires events"| node_conversion
node_bootstrap -->|"loads currencies"| node_api
node_conversion -->|"fetches rates"| node_api
node_conversion -->|"updates"| node_appstate
node_conversion -->|"formats results"| node_formatting
node_bootstrap -->|"wires events"| node_preferences
node_preferences -->|"updates"| node_appstate
node_preferences -->|"stores preferences"| node_browserstorage
node_api -.->|"requests live rates"| node_worker
node_api -->|"fetches rates"| node_providers
node_api -->|"reads and writes"| node_ratecache
node_ratecache -->|"persists rates"| node_browserstorage
node_worker -->|"fetches live rates"| node_providers
node_worker -->|"uses edge cache"| node_providers
node_bootstrap -->|"requests history"| node_historical
node_historical -->|"fetches history"| node_providers
node_bootstrap -->|"renders analytics"| node_chart
node_chart -->|"formats values"| node_formatting
node_bootstrap -->|"wires exports"| node_exports
node_user -->|"selects date"| node_historical
node_user -->|"downloads data"| node_exports
node_bootstrap -.->|"enables offline app"| node_pwa
node_pwa -->|"caches assets"| node_appassets

click node_bootstrap "https://github.com/sumit-chame/currancy_converter/blob/main/src/main.js"
click node_conversion "https://github.com/sumit-chame/currancy_converter/blob/main/src/main.js"
click node_preferences "https://github.com/sumit-chame/currancy_converter/blob/main/src/main.js"
click node_formatting "https://github.com/sumit-chame/currancy_converter/blob/main/src/ui.js"
click node_appstate "https://github.com/sumit-chame/currancy_converter/blob/main/src/state.js"
click node_api "https://github.com/sumit-chame/currancy_converter/blob/main/src/api.js"
click node_worker "https://github.com/sumit-chame/currancy_converter/blob/main/worker/src/index.js"
click node_ratecache "https://github.com/sumit-chame/currancy_converter/blob/main/src/cache.js"
click node_historical "https://github.com/sumit-chame/currancy_converter/blob/main/src/api.js"
click node_chart "https://github.com/sumit-chame/currancy_converter/blob/main/src/chart.js"
click node_exports "https://github.com/sumit-chame/currancy_converter/blob/main/src/chart.js"
click node_pwa "https://github.com/sumit-chame/currancy_converter/blob/main/service-worker.js"
click node_standalone "https://github.com/sumit-chame/currancy_converter/blob/main/index.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_bootstrap,node_conversion,node_preferences,node_formatting,node_appstate,node_standalone,node_user toneBlue
class node_api,node_worker,node_providers,node_ratecache,node_browserstorage toneAmber
class node_historical,node_chart,node_exports toneMint
class node_pwa,node_appassets toneRose
```

## Components

### Conversion experience

- [App bootstrap](https://github.com/sumit-chame/currancy_converter/blob/main/src/main.js): `src/main.js`
- [Conversion and fees](https://github.com/sumit-chame/currancy_converter/blob/main/src/main.js): `src/main.js`
- [Preferences and sharing](https://github.com/sumit-chame/currancy_converter/blob/main/src/main.js): `src/main.js`
- [Currency formatting](https://github.com/sumit-chame/currancy_converter/blob/main/src/ui.js): `src/ui.js`
- [App state](https://github.com/sumit-chame/currancy_converter/blob/main/src/state.js): `src/state.js`
- [Standalone app engine](https://github.com/sumit-chame/currancy_converter/blob/main/index.js): `index.js`

### Rates and cache

- [Rate API orchestration](https://github.com/sumit-chame/currancy_converter/blob/main/src/api.js): `src/api.js`
- [Live rates proxy](https://github.com/sumit-chame/currancy_converter/blob/main/worker/src/index.js): `worker/src/index.js`
- **Rate providers**
- [Versioned rate cache](https://github.com/sumit-chame/currancy_converter/blob/main/src/cache.js): `src/cache.js`
- **Browser storage**

### History analytics

- [Historical lookup](https://github.com/sumit-chame/currancy_converter/blob/main/src/api.js): `src/api.js`
- [Chart and statistics](https://github.com/sumit-chame/currancy_converter/blob/main/src/chart.js): `src/chart.js`
- [CSV and PNG export](https://github.com/sumit-chame/currancy_converter/blob/main/src/chart.js): `src/chart.js`

### Offline platform

- [Offline service worker](https://github.com/sumit-chame/currancy_converter/blob/main/service-worker.js): `service-worker.js`
- **Cached app assets**

### Other components

- **Currency user**

## Connections

- Currency user → App bootstrap: uses (evidence: `README.md`)
- App bootstrap → Conversion and fees: wires events (evidence: `src/main.js`)
- App bootstrap → Rate API orchestration: loads currencies (evidence: `src/main.js`)
- Conversion and fees → Rate API orchestration: fetches rates (evidence: `src/main.js`)
- Conversion and fees → App state: updates (evidence: `src/main.js`)
- Conversion and fees → Currency formatting: formats results (evidence: `src/main.js`)
- App bootstrap → Preferences and sharing: wires events (evidence: `src/main.js`)
- Preferences and sharing → App state: updates (evidence: `src/main.js`)
- Preferences and sharing → Browser storage: stores preferences (evidence: `src/main.js`)
- Rate API orchestration → Live rates proxy: requests live rates (evidence: `README.md`)
- Rate API orchestration → Rate providers: fetches rates (evidence: `src/api.js`)
- Rate API orchestration → Versioned rate cache: reads and writes (evidence: `src/api.js`)
- Versioned rate cache → Browser storage: persists rates (evidence: `src/cache.js`)
- Live rates proxy → Rate providers: fetches live rates (evidence: `worker/src/index.js`)
- Live rates proxy → Rate providers: uses edge cache (evidence: `worker/src/index.js`)
- App bootstrap → Historical lookup: requests history (evidence: `src/main.js`)
- Historical lookup → Rate providers: fetches history (evidence: `src/api.js`)
- App bootstrap → Chart and statistics: renders analytics (evidence: `src/main.js`)
- Chart and statistics → Currency formatting: formats values (evidence: `src/chart.js`)
- App bootstrap → CSV and PNG export: wires exports (evidence: `src/main.js`)
- Currency user → Historical lookup: selects date (evidence: `README.md`)
- Currency user → CSV and PNG export: downloads data (evidence: `README.md`)
- App bootstrap → Offline service worker: enables offline app (evidence: `README.md`)
- Offline service worker → Cached app assets: caches assets (evidence: `service-worker.js`)
