# r7ni/mithqalcalculator architecture

> Architecture diagram of the GitHub repository r7ni/mithqalcalculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/r7ni/mithqalcalculator
- Repository: https://github.com/r7ni/mithqalcalculator

## Overview

##### Project Type and Purpose
- The project is a static front-end web application. Its purpose is to let users perform two-way conversions between Baháʼí Mithqáls (of Gold/Silver) and monetary values in ISO 4217 currencies.
- It relies purely on HTML, CSS, and JavaScript (with TypeScript removed from this version) and integrates with external APIs to fetch live precious metal prices and currency rates.

##### File Structure and Its Implications
- Top-Level Files:
- index.html: Central page hosting the calculator interface.
- about.html, 404.html: Additional static pages (informational and error handling).
- script.js: Contains the front-end conversion logic, including API calls.
- style.css (and additional language-specific CSS like ar.css, fa.css): Styling for the user interface.
- CNAME, favicon, and other static assets: For deployment and branding.
- GitHub Directory (.github/workflows): Indicates that there are automated workflows set up (such as static analysis or deployment pipelines using GitHub Actions) even though the project itself is static.

##### Core Components of the System
a. User Interface (Frontend):
- Components: index.html (main calculator interface), about.html, 404.html, language-specific pages.
- Assets: style.css, ar.css, fa.css for styling and layout.
b. Business Logic:
- script.js holds the conversion logic and data handling for both the conversion calculations and the API calls to fetch live data.
c. External Services:
- External APIs for real-time gold and silver prices.
- External APIs for live currency conversion rates (using USD as the base value).
d. Deployment/CI (via .github/workflows):
- Integration of GitHub Actions for continuous integration and potentially for deployment validation of static content.

##### Mapping the Relationships and Data Flow
- From index.html:
- That script.js handles both the conversion process (user input calculations) and API requests.
- For API interactions:
- That these API calls are asynchronous, affecting how live data is fetched and processed.
- Infrastructure/Workflow:
- A “GitHub Actions” or “CI/CD Pipeline” block connected to the repository (with .github/workflows files) showing where static analysis, tests, or deployment processes occur.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Frontend Components
    User["User"]:::frontend

    subgraph "User Interface"
        UI_Index["index.html"]:::frontend
        UI_About["about.html"]:::frontend
        UI_404["404.html"]:::frontend
        UI_AR["ar.html"]:::frontend
        UI_AR_ABOUT["ar-about.html"]:::frontend
        UI_FA["fa.html"]:::frontend
        UI_FA_ABOUT["fa-about.html"]:::frontend
    end

    subgraph "Styling & Presentation"
        CSS_Main["style.css"]:::styles
        CSS_AR["ar.css"]:::styles
        CSS_FA["fa.css"]:::styles
        CSS_Extra["styles.css"]:::styles
    end

    Logic["Conversion Logic (script.js)"]:::logic

    subgraph "External Services"
        API_Metal["Metal Prices API"]:::external
        API_Currency["Currency Rates API"]:::external
    end

    Deploy["CI/CD Pipeline (GitHub Actions)"]:::ci

    %% Data Flow Connections
    User -->|"accesses"| UI_Index
    UI_Index -->|"triggers"| Logic
    CSS_Main -->|"applies"| UI_Index
    Logic -->|"fetchesMetal"| API_Metal
    Logic -->|"fetchesRates"| API_Currency
    API_Metal -->|"returnsData"| Logic
    API_Currency -->|"returnsData"| Logic
    Logic -->|"updates"| UI_Index
    Deploy -->|"deploys"| UI_Index

    %% Click Events for HTML Templates
    click UI_Index "https://github.com/r7ni/mithqalcalculator/blob/main/index.html"
    click UI_About "https://github.com/r7ni/mithqalcalculator/blob/main/about.html"
    click UI_404 "https://github.com/r7ni/mithqalcalculator/blob/main/404.html"
    click UI_AR "https://github.com/r7ni/mithqalcalculator/blob/main/ar.html"
    click UI_AR_ABOUT "https://github.com/r7ni/mithqalcalculator/blob/main/ar-about.html"
    click UI_FA "https://github.com/r7ni/mithqalcalculator/blob/main/fa.html"
    click UI_FA_ABOUT "https://github.com/r7ni/mithqalcalculator/blob/main/fa-about.html"

    %% Click Events for CSS Files
    click CSS_Main "https://github.com/r7ni/mithqalcalculator/blob/main/style.css"
    click CSS_AR "https://github.com/r7ni/mithqalcalculator/blob/main/ar.css"
    click CSS_FA "https://github.com/r7ni/mithqalcalculator/blob/main/fa.css"
    click CSS_Extra "https://github.com/r7ni/mithqalcalculator/blob/main/styles.css"

    %% Click Event for JavaScript
    click Logic "https://github.com/r7ni/mithqalcalculator/blob/main/script.js"

    %% Click Event for CI/CD Pipeline
    click Deploy "https://github.com/r7ni/mithqalcalculator/blob/main/.github/workflows/static.yml"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef styles fill:#ABEBC6,stroke:#196F3D,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef ci fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
