# vikydealewen/coin-bank-system architecture

> Architecture diagram of the GitHub repository vikydealewen/coin-bank-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vikydealewen/coin-bank-system
- Repository: https://github.com/vikydealewen/coin-bank-system

## Overview

##### Project type and purpose
- This is a full-stack web application consisting of:
- A front-end SPA (“Coin Bank”) built with vanilla JS, Webpack, Babel, SCSS, Navigo for routing, Chart.js for charts, Choices.js for custom selects, and Yandex.Maps for ATM display.
- A backend Node.js/Express service (in `backend/`) that exposes REST-style endpoints and serves static JSON data (`public/data.json`).
- End-to-end testing via Cypress.

##### File structure
Top-level directories:
- `src/` – SPA code, subdivided into:
– `modules/` (API client, routing, utilities)
– `components/` (reusable widgets: header, select, spinner toggle)
– `pages/` (feature pages: login, accounts list, account details, history, currency exchange, ATM map)
– `main.js` + `main.html` (SPA entry point)

- `backend/` – Node.js service with `src/index.js` (server entry), `cards.js` (controllers), `utils.js`, and a `public/` folder for static JSON.
- `cypress/` – E2E tests, fixtures, support files.
- Configs: Webpack (`webpack.config.js`), ESLint/Prettier/Stylelint, Cypress config.

##### README for additional insights
- SPA features: login, account creation, transaction history, transfers, currency exchange, ATM map.
- Requires the backend service running.
- Dev server runs on port 4000, builds to `dist/` for production.
- Test runner: Cypress uses the SPA + backend.

##### Detail
- Sub-domains: routing layer vs feature pages vs shared modules
- Build pipeline if relevant (Webpack → bundle → served)
- Port numbers (Dev: 4000 for frontend, backend port from backend/README)
- User flows: Login → fetch accounts → view history → perform transfer → update UI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend swimlane
    subgraph "Frontend" 
        direction TB
        EntryHTML["index.html"]:::frontend
        MainJS["main.js"]:::frontend
        Webpack["Webpack Dev Server (port 4000)"]:::frontend
        subgraph "Modules"
            direction TB
            APIClient["api.js"]:::frontend
            Router["routes.js"]:::frontend
            ErrorMod["createError.js"]:::frontend
            DateUtil["dateUtils.js"]:::frontend
            SessionUtil["sessionStorageUtils.js"]:::frontend
            SpinnerMod["toggleSpinnerOnBtn.js"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            HeaderComp["header.js"]:::frontend
            SelectComp["createCustomSelect.js"]:::frontend
            ChartComp["chartSettings.js"]:::frontend
        end
        subgraph "Pages"
            direction TB
            LoginPage["login.js"]:::frontend
            AccountsPage["accounts.js"]:::frontend
            AccountMain["account.js"]:::frontend
            AccountHistory["history.js"]:::frontend
            CurrencyPage["currency.js"]:::frontend
            AtmPage["atms.js"]:::frontend
        end
        Assets["assets & styles"]:::frontend
    end

    %% Backend swimlane
    subgraph "Backend" 
        direction TB
        Express["index.js"]:::backend
        CardsCtrl["cards.js"]:::backend
        UtilsBE["utils.js"]:::backend
        JSONStore["data.json"]:::backend
    end

    %% External services
    Yandex["Yandex.Maps API"]:::external
    ChartJS["Chart.js"]:::external
    ChoicesJS["Choices.js"]:::external
    Cypress["Cypress E2E"]:::test

    %% Connections
    EntryHTML --> MainJS
    MainJS --> Webpack
    Webpack -->|"serves bundle"| EntryHTML
    EntryHTML -->|"loads in browser"| Router
    Router --> APIClient
    APIClient -->|"/cards, /transactions, /currency, /atms"| Express
    Express --> CardsCtrl
    CardsCtrl --> UtilsBE
    CardsCtrl --> JSONStore
    Router --> LoginPage
    Router --> AccountsPage
    Router --> AccountMain
    Router --> AccountHistory
    Router --> CurrencyPage
    Router --> AtmPage
    UIComponents --- Pages
    Pages --- Modules
    LoginPage --> ErrorMod
    AccountHistory --> DateUtil
    CurrencyPage --> SpinnerMod
    AccountMain --> SessionUtil
    Pages --> HeaderComp
    Pages --> SelectComp
    Pages --> ChartComp
    Pages --> Assets

    APIClient --> ChartJS:::dotted
    APIClient --> ChoicesJS:::dotted
    AtmPage --> Yandex:::dotted
    Cypress -.->|drives UI| EntryHTML

    %% Click events
    click EntryHTML "https://github.com/vikydealewen/coin-bank-system/blob/main/src/main.html"
    click MainJS "https://github.com/vikydealewen/coin-bank-system/blob/main/src/main.js"
    click APIClient "https://github.com/vikydealewen/coin-bank-system/blob/main/src/modules/api.js"
    click Router "https://github.com/vikydealewen/coin-bank-system/blob/main/src/modules/routes.js"
    click ErrorMod "https://github.com/vikydealewen/coin-bank-system/blob/main/src/modules/createError.js"
    click DateUtil "https://github.com/vikydealewen/coin-bank-system/blob/main/src/modules/dateUtils.js"
    click SessionUtil "https://github.com/vikydealewen/coin-bank-system/blob/main/src/modules/sessionStorageUtils.js"
    click SpinnerMod "https://github.com/vikydealewen/coin-bank-system/blob/main/src/modules/toggleSpinnerOnBtn.js"
    click HeaderComp "https://github.com/vikydealewen/coin-bank-system/blob/main/src/components/header.js"
    click SelectComp "https://github.com/vikydealewen/coin-bank-system/blob/main/src/components/createCustomSelect.js"
    click ChartComp "https://github.com/vikydealewen/coin-bank-system/blob/main/src/components/chartSettings.js"
    click LoginPage "https://github.com/vikydealewen/coin-bank-system/blob/main/src/pages/login/login.js"
    click AccountsPage "https://github.com/vikydealewen/coin-bank-system/blob/main/src/pages/accounts/accounts.js"
    click AccountMain "https://github.com/vikydealewen/coin-bank-system/blob/main/src/pages/account/main/account.js"
    click AccountHistory "https://github.com/vikydealewen/coin-bank-system/blob/main/src/pages/account/history/history.js"
    click CurrencyPage "https://github.com/vikydealewen/coin-bank-system/blob/main/src/pages/currency/currency.js"
    click AtmPage "https://github.com/vikydealewen/coin-bank-system/blob/main/src/pages/atms/atms.js"
    click Express "https://github.com/vikydealewen/coin-bank-system/blob/main/backend/src/index.js"
    click CardsCtrl "https://github.com/vikydealewen/coin-bank-system/blob/main/backend/src/cards.js"
    click UtilsBE "https://github.com/vikydealewen/coin-bank-system/blob/main/backend/src/utils.js"
    click JSONStore "https://github.com/vikydealewen/coin-bank-system/blob/main/backend/public/data.json"
    click Cypress "https://github.com/vikydealewen/coin-bank-system/blob/main/cypress/e2e/coin.cy.js"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#DFFFE0,stroke:#28a745,color:#28a745
    classDef external fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00
    classDef test fill:#E8D0FF,stroke:#6f42c1,color:#6f42c1
```
