# baloo8721/web3-real-estate-calculator architecture

> Architecture diagram of the GitHub repository baloo8721/web3-real-estate-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/baloo8721/web3-real-estate-calculator
- Repository: https://github.com/baloo8721/web3-real-estate-calculator

## Overview

##### Project type and purpose
- This is a static, single-page “full-stack” application in the sense that it has a frontend plus a tiny automated data-refresh backend task, but it is really a client-only web app hosted on GitHub Pages.
- Purpose: perform various real-estate and crypto-currency calculations (mortgage, seller, investor, crypto) with multilingual UI and Web3 integrations.

##### File structure
- Top-level web assets:
- index.html, test.html – entry points
- styles.css – stylesheet
- script.js, cryptoCalculator.js, walletSearch.js – main UI logic
- images/ – static images
- wallet.json, rates.json – local JSON data stores
- Automated data fetch:
- scripts/fetch-rates.js – Node script to retrieve live crypto rates
- .github/workflows/update-rates.yml – scheduled GitHub Action that runs fetch-rates.js and commits a new rates.json
- Deployment:
- .github/workflows/deploy.yml – CI pipeline to push the site to GitHub Pages
- Configuration:
- package.json, package-lock.json – Node dependencies (for the fetch script)
- .gitignore – ignored files

##### Extract insights from the README
- Static web app with mortgage/investor/crypto calculators
- Live on GitHub Pages
- Multilingual, responsive, Web3 enabled

##### Main components
a. Frontend (Client)
- index.html + CSS + images
- JavaScript modules:
– script.js (UI initialization, event handling, language switching)
– cryptoCalculator.js (crypto-related calculation logic)
– walletSearch.js (load and search wallet.json)
- Local data stores (JSON files): rates.json, wallet.json
b. Data Update Service (Backend Task)
- scripts/fetch-rates.js fetches live crypto rates from an external API
- Runs on schedule via GitHub Actions (update-rates.yml)
- Commits updated rates.json back into the repo
c. Hosting / CI/CD
- GitHub Actions (deploy.yml) builds and publishes to GitHub Pages
- Live URL on baloo8721.github.io
d. External Dependencies
- Crypto-rates API (e.g., CoinGecko)
- GitHub Pages for static hosting

##### Relationships & interactions
- On push or schedule: update-rates.yml → run fetch-rates.js → external API → new rates.json → commit
- On any commit to main: deploy.yml → publish index.html + assets to GitHub Pages
- At runtime in user’s browser: index.html loads → script.js pulls rates.json & wallet.json → cryptoCalculator.js & walletSearch.js execute calculations → UI updates

##### Architectural patterns and design principles
- “Jamstack” style: pre-built markup (HTML), APIs (static JSON), and client JS
- CI as backend: GitHub Actions replace a traditional server
- Separation of concerns:
- Data acquisition (fetch-rates)
- Presentation and logic (script.js + calculator modules)
- Static content (HTML/CSS/images)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Services
    CryptoAPI["External Crypto API"]:::external

    %% CI / Automation
    subgraph "CI / Automation"
        UpdateWorkflow[".github/workflows/update-rates.yml"]:::ci
        FetchScript["scripts/fetch-rates.js"]:::ci
        DeployWorkflow[".github/workflows/deploy.yml"]:::ci
        NodeDeps["package.json / package-lock.json"]:::ci
    end

    %% Hosting
    GitHubPages["GitHub Pages Hosting"]:::hosting

    %% Frontend (Client-side)
    subgraph "Frontend Assets"
        Index["index.html"]:::client
        TestPage["test.html"]:::client
        Styles["styles.css"]:::client
        Images["images/"]:::client
        ScriptJS["script.js"]:::client
        CryptoCalc["cryptoCalculator.js"]:::client
        WalletSearch["walletSearch.js"]:::client
        RatesJSON["rates.json"]:::data
        WalletJSON["wallet.json"]:::data
    end

    %% Relationships
    UpdateWorkflow -->|"runs fetch-script"| FetchScript
    FetchScript -->|"GET rates from API"| CryptoAPI
    CryptoAPI -->|"returns rates data"| FetchScript
    FetchScript -->|"updates rates.json"| RatesJSON
    FetchScript -->|"commits changes"| UpdateWorkflow

    DeployWorkflow -->|"on push to main"| GitHubPages

    UpdateWorkflow -->|"on schedule (cron)"| UpdateWorkflow

    GitHubPages -->|"serves static site"| Index
    GitHubPages -->|"serves static site"| TestPage
    GitHubPages -->|"serves static site"| Styles
    GitHubPages -->|"serves static site"| Images
    GitHubPages -->|"serves static site"| ScriptJS
    GitHubPages -->|"serves static site"| CryptoCalc
    GitHubPages -->|"serves static site"| WalletSearch
    GitHubPages -->|"serves static site"| RatesJSON
    GitHubPages -->|"serves static site"| WalletJSON

    Index -->|"loads modules"| ScriptJS
    ScriptJS -->|"uses"| CryptoCalc
    ScriptJS -->|"uses"| WalletSearch
    ScriptJS -->|"loads data"| RatesJSON
    ScriptJS -->|"loads data"| WalletJSON

    %% Click Events
    click Index "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/index.html"
    click TestPage "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/test.html"
    click Styles "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/styles.css"
    click Images "https://github.com/baloo8721/web3-real-estate-calculator/tree/main/images/"
    click ScriptJS "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/script.js"
    click CryptoCalc "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/cryptoCalculator.js"
    click WalletSearch "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/walletSearch.js"
    click RatesJSON "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/rates.json"
    click WalletJSON "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/wallet.json"
    click FetchScript "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/scripts/fetch-rates.js"
    click UpdateWorkflow "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/.github/workflows/update-rates.yml"
    click DeployWorkflow "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/.github/workflows/deploy.yml"
    click NodeDeps "https://github.com/baloo8721/web3-real-estate-calculator/blob/main/package.json"

    %% Styles
    classDef client fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1
    classDef ci fill:#E8F5E9,stroke:#43A047,color:#1B5E20
    classDef external fill:#FFEBEE,stroke:#E53935,color:#B71C1C
    classDef hosting fill:#FFF8E1,stroke:#FFB300,color:#E65100
    classDef data fill:#ECEFF1,stroke:#78909C,color:#455A64
```
