# softwareverde/pos-cash architecture

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

- Interactive diagram: https://gitdiagram.com/softwareverde/pos-cash
- Repository: https://github.com/softwareverde/pos-cash

## Overview

##### Project type and purpose
- This is a purely client-side, single-page web application (“Bitcoin Cash Point of Sale”) for accepting BCH payments without any custom backend.
- It runs entirely in the browser, fetching static assets (HTML, JS, CSS, images, audio) from a static file host and talking only to external payment-alert services.

##### File structure
- Top-level:
- scripts/ — build helper (make-libauth.sh)
- www/ — all runtime assets
- Under www/:
- index.html — SPA entry point
- css/, js/, img/, dat/ — static assets
- js/widget/ & css/widget/ — modular UI screens (checkout, payment, settings, etc.)
- api/v1/*.json — static reference data (countries, currency symbols, strings)
- No backend directory or server code.

##### README for additional insights
- No server code required—only simple HTTP(S) hosting.
- Uses localStorage for user configurations.
- Integrates with bitcoin.com, blockchain.info, bitcoinverde.org for “payment alerts.”

##### Main components and interactions
a. Static File Server (any HTTP(S) host)
- Serves index.html and all assets on request.
b. Browser Client
- Loads index.html → initializes core.js, init.js.
- Dynamically loads widget modules (checkout-screen.js, payment-screen.js, etc.) and corresponding CSS.
- Reads/writes user settings to localStorage.
- Renders UI and handles user input (QR-scanner, on-screen keyboard).
c. LocalStorage
- Persists merchant configuration (payment currency, UI preferences).
d. External Payment-Alert Services
- Polls or subscribes to bitcoin.com, blockchain.info, bitcoinverde.org endpoints.
- Receives callbacks/notifications when BCH payments arrive.
e. Static Reference Data
- Loaded from www/api/v1 JSON files (country list, currency symbols, UI strings).

##### Architectural patterns and design principles
- Modular widget architecture: each screen is a self-contained JS/CSS module.
- “Static Single-Page App” pattern: no server logic, assets + code run in browser.
- Separation of concerns:
- UI layers (HTML/CSS)
- Logic layers (core.js, widget scripts)
- Data storage (localStorage)
- External integrations (HTTP API modules).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static File Host
    FileHost["Static File Server"]:::host
    click FileHost "https://github.com/softwareverde/pos-cash/tree/master/www/"

    %% Browser Client
    Browser["Web Browser (Client)"]:::client

    FileHost -->|"HTTP GET assets"| Browser

    %% SPA Entry Point
    Index["index.html"]:::client
    click Index "https://github.com/softwareverde/pos-cash/blob/master/www/index.html"
    FileHost --> Index
    Index --> Browser

    %% Core Engine
    subgraph "Core Engine"
        CoreJS["core.js"]:::client
        InitJS["init.js"]:::client
        HTTPJS["http.js"]:::client
        LibAuthJS["libauth.js"]:::client
    end
    click CoreJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/core.js"
    click InitJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/init.js"
    click HTTPJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/http.js"
    click LibAuthJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/libauth.js"
    Browser --> CoreJS
    Browser --> InitJS
    Browser --> HTTPJS
    Browser --> LibAuthJS

    %% QR Scanner Service
    subgraph "QR Scanner Service"
        JSQR["jsqr.js"]:::client
        QRScanner["qr-code-scanner.js"]:::client
        QRCode["qr-code.js"]:::client
    end
    click JSQR "https://github.com/softwareverde/pos-cash/blob/master/www/js/jsqr.js"
    click QRScanner "https://github.com/softwareverde/pos-cash/blob/master/www/js/qr-code-scanner.js"
    click QRCode "https://github.com/softwareverde/pos-cash/blob/master/www/js/qr-code.js"
    CoreJS --> JSQR
    CoreJS --> QRScanner
    CoreJS --> QRCode

    %% Datepicker Module
    subgraph "Datepicker Module"
        DateJS["datepicker.js"]:::client
        DateCSS["datepicker.css"]:::client
    end
    click DateJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/datepicker.js"
    click DateCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/datepicker.css"
    CoreJS --> DateJS
    Browser --> DateCSS

    %% UI Widgets JS
    subgraph "UI Widgets (JS)"
        CheckoutJS["checkout-screen.js"]:::client
        PaymentJS["payment-screen.js"]:::client
        ReceivedJS["payment-received-screen.js"]:::client
        SettingsJS["settings-screen.js"]:::client
        TransactionsJS["transactions-screen.js"]:::client
        PinScreenJS["pin-screen.js"]:::client
        MenuJS["menu.js"]:::client
        KeyboardJS["keyboard.js"]:::client
        SettingJS["setting.js"]:::client
        PinJS["pin.js"]:::client
    end
    click CheckoutJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/checkout-screen.js"
    click PaymentJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/payment-screen.js"
    click ReceivedJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/payment-received-screen.js"
    click SettingsJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/settings-screen.js"
    click TransactionsJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/transactions-screen.js"
    click PinScreenJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/pin-screen.js"
    click MenuJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/menu.js"
    click KeyboardJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/keyboard.js"
    click SettingJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/setting.js"
    click PinJS "https://github.com/softwareverde/pos-cash/blob/master/www/js/widget/pin.js"
    CoreJS --> CheckoutJS
    CoreJS --> PaymentJS
    CoreJS --> ReceivedJS
    CoreJS --> SettingsJS
    CoreJS --> TransactionsJS
    CoreJS --> PinScreenJS
    CoreJS --> MenuJS
    CoreJS --> KeyboardJS
    CoreJS --> SettingJS
    CoreJS --> PinJS

    %% UI Widgets CSS
    subgraph "UI Widgets (CSS)"
        CheckoutCSS["checkout-screen.css"]:::client
        PaymentCSS["payment-screen.css"]:::client
        ReceivedCSS["payment-received-screen.css"]:::client
        SettingsCSS["settings-screen.css"]:::client
        TransactionsCSS["transactions-screen.css"]:::client
        PinScreenCSS["pin-screen.css"]:::client
        MenuCSS["menu.css"]:::client
        KeyboardCSS["keyboard.css"]:::client
        SettingCSS["setting.css"]:::client
        PinCSS["pin.css"]:::client
    end
    click CheckoutCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/checkout-screen.css"
    click PaymentCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/payment-screen.css"
    click ReceivedCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/payment-received-screen.css"
    click SettingsCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/settings-screen.css"
    click TransactionsCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/transactions-screen.css"
    click PinScreenCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/pin-screen.css"
    click MenuCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/menu.css"
    click KeyboardCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/keyboard.css"
    click SettingCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/setting.css"
    click PinCSS "https://github.com/softwareverde/pos-cash/blob/master/www/css/widget/pin.css"
    Browser --> CheckoutCSS
    Browser --> PaymentCSS
    Browser --> ReceivedCSS
    Browser --> SettingsCSS
    Browser --> TransactionsCSS
    Browser --> PinScreenCSS
    Browser --> MenuCSS
    Browser --> KeyboardCSS
    Browser --> SettingCSS
    Browser --> PinCSS

    %% LocalStorage
    LocalStorage[/"localStorage"/]:::storage
    Browser <-->|"localStorage API"| LocalStorage

    %% Static Reference Data
    subgraph "Static Reference Data"
        Countries["countries.json"]:::data
        CurrencySymbols["currency-symbols.json"]:::data
        Strings["strings.json"]:::data
    end
    click Countries "https://github.com/softwareverde/pos-cash/blob/master/www/api/v1/countries.json"
    click CurrencySymbols "https://github.com/softwareverde/pos-cash/blob/master/www/api/v1/currency-symbols.json"
    click Strings "https://github.com/softwareverde/pos-cash/blob/master/www/api/v1/strings.json"
    Browser -->|HTTP GET| Countries
    Browser -->|HTTP GET| CurrencySymbols
    Browser -->|HTTP GET| Strings

    %% Audio Asset
    Audio["payment.mp3"]:::asset
    click Audio "https://github.com/softwareverde/pos-cash/blob/master/www/dat/payment.mp3"
    Browser -->|HTTP GET| Audio

    %% Images
    Images["Images Directory"]:::asset
    click Images "https://github.com/softwareverde/pos-cash/tree/master/www/img/"
    Browser -->|HTTP GET| Images

    %% External Payment-Alert Services
    subgraph "External Payment-Alert Services"
        BitcoinCom["bitcoin.com alerts API"]:::external
        BlockchainInfo["blockchain.info alerts API"]:::external
        BitcoinVerde["bitcoinverde.org alerts API"]:::external
    end
    Browser -->|poll/subscriptions| BitcoinCom
    Browser -->|poll/subscriptions| BlockchainInfo
    Browser -->|poll/subscriptions| BitcoinVerde

    %% Styling
    classDef client fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef host fill:#e0e0e0,stroke:#999999,color:#000;
    classDef storage fill:#d4edda,stroke:#28a745,color:#000;
    classDef external fill:#ffe5cc,stroke:#ff9933,color:#000;
    classDef data fill:#f0f0f0,stroke:#666666,color:#000;
    classDef asset fill:#f8f0ff,stroke:#aa66cc,color:#000;
```
