# musab1010/currency-sudan architecture

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

- Interactive diagram: https://gitdiagram.com/musab1010/currency-sudan
- Repository: https://github.com/musab1010/currency-sudan

## Overview

This repository is a Sudanese currency-rates web service with separate utilities for checking bank websites and listing bank apps. The main workflow is the server launching a scraper, the scraper fetching and parsing rates, and the server reading saved rates for its API. The tree also includes visitor statistics and OCR code, but the available excerpts do not show OCR wired into the server or the bank-checking utilities exposed through its API. The README is empty, so feature links beyond the shown code are omitted.

Main entry points: [`server.js`](https://github.com/musab1010/currency-sudan/blob/master/server.js) (Express server), [`scrape-alsoug.js`](https://github.com/musab1010/currency-sudan/blob/master/scrape-alsoug.js) (Alsoug scraper), [`bank-monitor.js`](https://github.com/musab1010/currency-sudan/blob/master/bank-monitor.js) (Scheduled bank monitor), [`bank-checker.js`](https://github.com/musab1010/currency-sudan/blob/master/bank-checker.js) (On-demand bank checker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web service"]
  node_server["Express server<br/>[server.js]"]
  node_frontend["Public website<br/>[index.html]"]
  node_admin["Admin page<br/>[index.html]"]
  node_visitor_data[("Visitor records<br/>[visitors.json]")]
  node_rate_api["Rates API<br/>[server.js]"]
end

subgraph group_rates["Rate collection"]
  node_scraper["Alsoug scraper<br/>[scrape-alsoug.js]"]
  node_rates_data[("Rate records<br/>[rates.json]")]
  node_legacy_rates[("Legacy rate data<br/>[data.json]")]
end

subgraph group_status["Bank status"]
  node_bank_monitor["Scheduled bank monitor<br/>[bank-monitor.js]"]
  node_bank_checker["On-demand bank checker<br/>[bank-checker.js]"]
  node_bank_data[("Bank status records<br/>[banks-status.json]")]
  node_app_checker["Bank app checker<br/>[app-checker.js]"]
  node_app_data[("App status records<br/>[apps-status.json]")]
end

subgraph group_utilities["Standalone utilities"]
  node_ocr["Image OCR and rate parsing<br/>[ocr.js]"]
  node_ocr_models["Arabic and English OCR data<br/>[ara.traineddata]"]
  node_english_model["English OCR data<br/>[eng.traineddata]"]
end

node_visitor(("Website visitor"))
node_alsoug["Alsoug currency site"]
node_bank_sites["Bank websites"]

node_visitor -->|"requests pages and APIs"| node_server
node_server -->|"serves static site"| node_frontend
node_server -->|"launches on schedule"| node_scraper
node_scraper -->|"fetches currency table"| node_alsoug
node_scraper -->|"writes parsed rates"| node_rates_data
node_rate_api -->|"reads rates file"| node_rates_data
node_rate_api -->|"fallback reads rates"| node_legacy_rates
node_server -->|"reads and updates counts"| node_visitor_data
node_bank_monitor -->|"checks availability"| node_bank_sites
node_bank_monitor -->|"writes check results"| node_bank_data
node_bank_checker -->|"checks availability"| node_bank_sites
node_bank_checker -->|"writes check results"| node_bank_data
node_app_checker -->|"writes app status"| node_app_data
node_ocr -.->|"recognizes Arabic text"| node_ocr_models
node_ocr -.->|"recognizes English text"| node_english_model

click node_server "https://github.com/musab1010/currency-sudan/blob/master/server.js"
click node_frontend "https://github.com/musab1010/currency-sudan/blob/master/public/index.html"
click node_admin "https://github.com/musab1010/currency-sudan/blob/master/admin/index.html"
click node_visitor_data "https://github.com/musab1010/currency-sudan/blob/master/data/visitors.json"
click node_scraper "https://github.com/musab1010/currency-sudan/blob/master/scrape-alsoug.js"
click node_rates_data "https://github.com/musab1010/currency-sudan/blob/master/data/rates.json"
click node_legacy_rates "https://github.com/musab1010/currency-sudan/blob/master/data.json"
click node_rate_api "https://github.com/musab1010/currency-sudan/blob/master/server.js"
click node_bank_monitor "https://github.com/musab1010/currency-sudan/blob/master/bank-monitor.js"
click node_bank_checker "https://github.com/musab1010/currency-sudan/blob/master/bank-checker.js"
click node_bank_data "https://github.com/musab1010/currency-sudan/blob/master/data/banks-status.json"
click node_app_checker "https://github.com/musab1010/currency-sudan/blob/master/app-checker.js"
click node_app_data "https://github.com/musab1010/currency-sudan/blob/master/data/apps-status.json"
click node_ocr "https://github.com/musab1010/currency-sudan/blob/master/utils/ocr.js"
click node_ocr_models "https://github.com/musab1010/currency-sudan/blob/master/ara.traineddata"
click node_english_model "https://github.com/musab1010/currency-sudan/blob/master/eng.traineddata"

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_server,node_frontend,node_admin,node_visitor_data,node_rate_api toneBlue
class node_scraper,node_rates_data,node_legacy_rates toneAmber
class node_bank_monitor,node_bank_checker,node_bank_data,node_app_checker,node_app_data toneMint
class node_ocr,node_ocr_models,node_english_model toneRose
class node_visitor,node_alsoug,node_bank_sites toneIndigo
```

## Components

### Web service

- [Express server](https://github.com/musab1010/currency-sudan/blob/master/server.js): `server.js`
- [Public website](https://github.com/musab1010/currency-sudan/blob/master/public/index.html): `public/index.html`
- [Admin page](https://github.com/musab1010/currency-sudan/blob/master/admin/index.html): `admin/index.html`
- [Visitor records](https://github.com/musab1010/currency-sudan/blob/master/data/visitors.json): `data/visitors.json`
- [Rates API](https://github.com/musab1010/currency-sudan/blob/master/server.js): `server.js`

### Rate collection

- [Alsoug scraper](https://github.com/musab1010/currency-sudan/blob/master/scrape-alsoug.js): `scrape-alsoug.js`
- [Rate records](https://github.com/musab1010/currency-sudan/blob/master/data/rates.json): `data/rates.json`
- [Legacy rate data](https://github.com/musab1010/currency-sudan/blob/master/data.json): `data.json`

### Bank status

- [Scheduled bank monitor](https://github.com/musab1010/currency-sudan/blob/master/bank-monitor.js): `bank-monitor.js`
- [On-demand bank checker](https://github.com/musab1010/currency-sudan/blob/master/bank-checker.js): `bank-checker.js`
- [Bank status records](https://github.com/musab1010/currency-sudan/blob/master/data/banks-status.json): `data/banks-status.json`
- [Bank app checker](https://github.com/musab1010/currency-sudan/blob/master/app-checker.js): `app-checker.js`
- [App status records](https://github.com/musab1010/currency-sudan/blob/master/data/apps-status.json): `data/apps-status.json`

### Standalone utilities

- [Image OCR and rate parsing](https://github.com/musab1010/currency-sudan/blob/master/utils/ocr.js): `utils/ocr.js`
- [Arabic and English OCR data](https://github.com/musab1010/currency-sudan/blob/master/ara.traineddata): `ara.traineddata`
- [English OCR data](https://github.com/musab1010/currency-sudan/blob/master/eng.traineddata): `eng.traineddata`

### Other components

- **Website visitor**
- **Alsoug currency site**
- **Bank websites**

## Connections

- Website visitor → Express server: requests pages and APIs (evidence: `server.js`)
- Express server → Public website: serves static site (evidence: `server.js`)
- Express server → Alsoug scraper: launches on schedule (evidence: `server.js`)
- Alsoug scraper → Alsoug currency site: fetches currency table (evidence: `scrape-alsoug.js`)
- Alsoug scraper → Rate records: writes parsed rates (evidence: `scrape-alsoug.js`)
- Rates API → Rate records: reads rates file (evidence: `server.js`)
- Rates API → Legacy rate data: fallback reads rates (evidence: `server.js`)
- Express server → Visitor records: reads and updates counts (evidence: `server.js`)
- Scheduled bank monitor → Bank websites: checks availability (evidence: `bank-monitor.js`)
- Scheduled bank monitor → Bank status records: writes check results (evidence: `bank-monitor.js`)
- On-demand bank checker → Bank websites: checks availability (evidence: `bank-checker.js`)
- On-demand bank checker → Bank status records: writes check results (evidence: `bank-checker.js`)
- Bank app checker → App status records: writes app status (evidence: `app-checker.js`)
- Image OCR and rate parsing → Arabic and English OCR data: recognizes Arabic text
- Image OCR and rate parsing → English OCR data: recognizes English text
