# ko3ak81/currencywatcher architecture

> Architecture diagram of the GitHub repository ko3ak81/currencywatcher, 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/ko3ak81/currencywatcher
- Repository: https://github.com/ko3ak81/currencywatcher

## Overview

CurrencyWatcher monitors configured ILS/THB rates, logs each successful reading, compares it with alert thresholds, and dispatches notifications. The principal workflow starts immediately and repeats on a configured interval; the optional Express server also exposes configuration, log, and manual-check routes. Rate-history analysis is a separate capability. The sampled source shows the monitoring and server wiring; notification destinations and scraping are documented, while the static page’s behavior is not established by the excerpts.

Main entry points: [`app.js`](https://github.com/ko3ak81/currencywatcher/blob/main/app.js) (Rate fetch and retry), [`server.js`](https://github.com/ko3ak81/currencywatcher/blob/main/server.js) (Express routes), [`exchange_rate_log.csv`](https://github.com/ko3ak81/currencywatcher/blob/main/exchange_rate_log.csv) (Rate history), [`config.json`](https://github.com/ko3ak81/currencywatcher/blob/main/config.json) (Rate configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitoring["Rate monitoring"]
  node_scheduler["Monitoring scheduler<br/>[app.js]"]
  node_fetch["Rate fetch and retry<br/>[app.js]"]
  node_config["Rate configuration<br/>[config.json]"]
  node_thresholds["Threshold check<br/>[app.js]"]
end

subgraph group_web["Web controls"]
  node_static_page["Static page<br/>[index.html]"]
  node_server["Express routes<br/>[server.js]"]
end

subgraph group_outputs["Alerts and history"]
  node_logger["CSV logger<br/>[app.js]"]
  node_csv["Rate history"]
  node_analyzer["Trend analysis<br/>[app.js]"]
  node_dispatch["Channel dispatch<br/>[app.js]"]
  node_pushover["Pushover sender<br/>[app.js]"]
  node_email["Email sender<br/>[app.js]"]
  node_slack["Slack sender<br/>[app.js]"]
end

node_google["Google Finance"]
node_pushover_service["Pushover API"]
node_email_service["Email service"]
node_slack_service["Slack API"]
node_browser(("Web user"))

node_scheduler -->|"starts and schedules"| node_fetch
node_fetch -->|"reads settings"| node_config
node_fetch -.->|"scrapes rate"| node_google
node_fetch -->|"checks rate"| node_thresholds
node_fetch -->|"logs rate"| node_logger
node_logger -->|"appends readings"| node_csv
node_analyzer -->|"reads history"| node_csv
node_thresholds -->|"dispatches alerts"| node_dispatch
node_dispatch -->|"selects channel"| node_pushover
node_dispatch -->|"selects channel"| node_email
node_dispatch -->|"selects channel"| node_slack
node_pushover -->|"posts notification"| node_pushover_service
node_email -->|"sends email"| node_email_service
node_slack -->|"posts message"| node_slack_service
node_browser -.->|"uses routes"| node_server
node_server -->|"serves files"| node_static_page
node_server -->|"reads and writes"| node_config
node_server -->|"reads logs"| node_csv
node_server -->|"triggers check"| node_fetch

click node_scheduler "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_fetch "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_config "https://github.com/ko3ak81/currencywatcher/blob/main/config.json"
click node_thresholds "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_logger "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_csv "https://github.com/ko3ak81/currencywatcher/blob/main/exchange_rate_log.csv"
click node_analyzer "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_dispatch "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_pushover "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_email "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_slack "https://github.com/ko3ak81/currencywatcher/blob/main/app.js"
click node_static_page "https://github.com/ko3ak81/currencywatcher/blob/main/public/index.html"
click node_server "https://github.com/ko3ak81/currencywatcher/blob/main/server.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_scheduler,node_fetch,node_config,node_thresholds,node_browser toneBlue
class node_static_page,node_server toneAmber
class node_logger,node_csv,node_analyzer,node_dispatch,node_pushover,node_email,node_slack,node_pushover_service,node_slack_service toneMint
class node_google,node_email_service toneIndigo
```

## Components

### Rate monitoring

- [Monitoring scheduler](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`
- [Rate fetch and retry](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`
- [Rate configuration](https://github.com/ko3ak81/currencywatcher/blob/main/config.json): `config.json`
- [Threshold check](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`

### Web controls

- [Static page](https://github.com/ko3ak81/currencywatcher/blob/main/public/index.html): `public/index.html`
- [Express routes](https://github.com/ko3ak81/currencywatcher/blob/main/server.js): `server.js`

### Alerts and history

- [CSV logger](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`
- [Rate history](https://github.com/ko3ak81/currencywatcher/blob/main/exchange_rate_log.csv): `exchange_rate_log.csv`
- [Trend analysis](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`
- [Channel dispatch](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`
- [Pushover sender](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`
- [Email sender](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`
- [Slack sender](https://github.com/ko3ak81/currencywatcher/blob/main/app.js): `app.js`

### Other components

- **Google Finance**
- **Pushover API**
- **Email service**
- **Slack API**
- **Web user**

## Connections

- Monitoring scheduler → Rate fetch and retry: starts and schedules (evidence: `app.js`)
- Rate fetch and retry → Rate configuration: reads settings (evidence: `app.js`)
- Rate fetch and retry → Google Finance: scrapes rate (evidence: `README.md`)
- Rate fetch and retry → Threshold check: checks rate (evidence: `app.js`)
- Rate fetch and retry → CSV logger: logs rate (evidence: `app.js`)
- CSV logger → Rate history: appends readings (evidence: `app.js`)
- Trend analysis → Rate history: reads history (evidence: `app.js`)
- Threshold check → Channel dispatch: dispatches alerts (evidence: `app.js`)
- Channel dispatch → Pushover sender: selects channel (evidence: `app.js`)
- Channel dispatch → Email sender: selects channel (evidence: `app.js`)
- Channel dispatch → Slack sender: selects channel (evidence: `app.js`)
- Pushover sender → Pushover API: posts notification (evidence: `app.js`)
- Email sender → Email service: sends email (evidence: `app.js`)
- Slack sender → Slack API: posts message (evidence: `app.js`)
- Web user → Express routes: uses routes
- Express routes → Static page: serves files (evidence: `server.js`)
- Express routes → Rate configuration: reads and writes (evidence: `server.js`)
- Express routes → Rate history: reads logs (evidence: `server.js`)
- Express routes → Rate fetch and retry: triggers check (evidence: `server.js`)
