# daryllxd/x-gic-bank architecture

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

- Interactive diagram: https://gitdiagram.com/daryllxd/x-gic-bank
- Repository: https://github.com/daryllxd/x-gic-bank

## Overview

##### Project type and purpose
- X‑GIC Bank is a front‑end single‑page application (SPA) built with React and TypeScript.
- Its purpose is to simulate a simple bank account: deposit, withdraw, reset balance, and print statements. There is no separate backend service; all state lives in the browser.

##### File structure
- Top‑level files and folders:
- public/index.html + assets (static host)
- src/ – application source code
- src/features/bank/ – domain logic for bank state and commands (deposit, withdraw, print, reset)
- src/App.tsx, src/main.tsx – React entry points and root component
- src/utils/ – helper functions (formatCurrency, formatDate)
- config files: vite.config.ts, tsconfig*.json, tailwind.config.js, postcss.config.mjs, eslint.config.js
- tests/ – Playwright end‑to‑end tests
- src/**/*.test.tsx & vitest.config.ts – unit tests with Vitest
- Folder pattern: feature‑based (bank), utility modules, top‑level config for build, linting, CSS.

##### README for additional insights
- Describes dev setup (pnpm + Vite), unit tests (Vitest), E2E tests (Playwright), and deployment (Vercel demo).

##### Main components and their interactions
a. Frontend (React SPA)
- UI Layer: App.tsx & feature components (bankStatementTable, commands UI)
- Domain Layer: BankState + Command modules + Types + Utils
b. Build & Tooling
- pnpm package manager
- Vite dev server / bundler
- Tailwind CSS + PostCSS for styling
- ESLint for linting
c. Testing
- Vitest (unit tests run in Node/jsdom)
- Playwright (E2E tests running against the dev server)
d. Deployment (static site on Vercel)

##### Relationships and data flow
- Developer commits code → pnpm install → Vite builds and serves the SPA
- Browser loads index.html → main.tsx mounts React tree → App renders UI
- UI components invoke domain commands (deposit, withdraw, reset) → update BankState → UI re‑renders with new data
- Utils format data for presentation
- Vitest tests import individual modules for unit testing
- Playwright drives the live UI in the browser to test flows end‑to‑end

##### Architectural patterns & design principles
- Feature‑based modularization: all bank logic co‑located under src/features/bank
- Command pattern for domain actions (each command is its own module)
- React component hierarchy with unidirectional data flow (state lives in BankState, passed down via props or context)
- Separation of concerns: UI vs. domain vs. utilities vs. build config

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Source & Build"
        Developer["Developer / CI"]:::build
        Pnpm["pnpm install / package.json"]:::build
        Vite["Vite (build & dev server)"]:::build
        ESLint["ESLint"]:::build
        Tailwind["Tailwind CSS / PostCSS"]:::build
        TSC["TypeScript Configs"]:::build

        Developer --> Pnpm
        Pnpm --> Vite
        Pnpm --> ESLint
        Pnpm --> Tailwind
        Pnpm --> TSC

        click Pnpm "https://github.com/daryllxd/x-gic-bank/blob/main/package.json"
        click Pnpm "https://github.com/daryllxd/x-gic-bank/blob/main/pnpm-lock.yaml"
        click Vite "https://github.com/daryllxd/x-gic-bank/blob/main/vite.config.ts"
        click TSC "https://github.com/daryllxd/x-gic-bank/blob/main/tsconfig.json"
        click TSC "https://github.com/daryllxd/x-gic-bank/blob/main/tsconfig.app.json"
        click TSC "https://github.com/daryllxd/x-gic-bank/blob/main/tsconfig.node.json"
        click Tailwind "https://github.com/daryllxd/x-gic-bank/blob/main/tailwind.config.js"
        click Tailwind "https://github.com/daryllxd/x-gic-bank/blob/main/postcss.config.mjs"
        click ESLint "https://github.com/daryllxd/x-gic-bank/blob/main/eslint.config.js"
    end

    subgraph "Client-side Application"
        subgraph "Browser / React Runtime"
            IndexHTML["public/index.html"]:::runtime
            MainTS["src/main.tsx"]:::runtime
            CSS["src/index.css"]:::runtime
            ViteEnv["src/vite-env.d.ts"]:::runtime
        end

        subgraph "UI Layer"
            AppComp["src/App.tsx"]:::runtime
            AppCSS["src/App.css"]:::runtime
            BankUITable["bankStatementTable.ts"]:::runtime
        end

        subgraph "Domain Layer"
            BankState["BankState.ts"]:::runtime
            DepositCmd["deposit.ts"]:::runtime
            WithdrawCmd["withdraw.ts"]:::runtime
            ResetCmd["reset.ts"]:::runtime
            PrintCmd["print.ts"]:::runtime
            Types["types.ts"]:::runtime
            BankUtils["utils.ts"]:::runtime
        end

        subgraph "Shared Utilities"
            FormatCur["formatCurrency.ts"]:::runtime
            FormatDate["formatDate.ts"]:::runtime
            CN["cn.ts"]:::runtime
        end

        click IndexHTML "https://github.com/daryllxd/x-gic-bank/blob/main/public/index.html"
        click MainTS "https://github.com/daryllxd/x-gic-bank/blob/main/src/main.tsx"
        click CSS "https://github.com/daryllxd/x-gic-bank/blob/main/src/index.css"
        click ViteEnv "https://github.com/daryllxd/x-gic-bank/blob/main/src/vite-env.d.ts"
        click AppComp "https://github.com/daryllxd/x-gic-bank/blob/main/src/App.tsx"
        click AppCSS "https://github.com/daryllxd/x-gic-bank/blob/main/src/App.css"
        click BankUITable "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/bankStatementTable.ts"
        click BankState "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/BankState.ts"
        click DepositCmd "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/commands/deposit.ts"
        click WithdrawCmd "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/commands/withdraw.ts"
        click ResetCmd "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/commands/reset.ts"
        click PrintCmd "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/commands/print.ts"
        click Types "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/types.ts"
        click BankUtils "https://github.com/daryllxd/x-gic-bank/blob/main/src/features/bank/utils.ts"
        click FormatCur "https://github.com/daryllxd/x-gic-bank/blob/main/src/utils/formatCurrency.ts"
        click FormatDate "https://github.com/daryllxd/x-gic-bank/blob/main/src/utils/formatDate.ts"
        click CN "https://github.com/daryllxd/x-gic-bank/blob/main/src/utils/cn.ts"

        IndexHTML --> MainTS
        MainTS --> AppComp
        AppComp --> BankUITable
        BankUITable --> BankState
        BankUITable --> PrintCmd
        AppComp --> DepositCmd
        AppComp --> WithdrawCmd
        AppComp --> ResetCmd
        BankState --> Types
        DepositCmd --> BankState
        WithdrawCmd --> BankState
        ResetCmd --> BankState
        PrintCmd --> BankState
        BankUITable --> FormatCur
        BankUITable --> FormatDate
        AppComp --> CN
    end

    subgraph Testing
        Vitest["Vitest (unit tests)"]:::testing
        Playwright["Playwright (E2E)"]:::testing

        Developer --> Vitest
        Developer --> Playwright
        Vitest --> AppComp
        Playwright --> IndexHTML

        click Vitest "https://github.com/daryllxd/x-gic-bank/blob/main/vitest.config.ts"
        click Playwright "https://github.com/daryllxd/x-gic-bank/blob/main/playwright.config.ts"
    end

    subgraph "Deployment & Hosting"
        PublicFolder["public/"]:::deployment
        Vercel["Vercel (Deployment)"]:::deployment

        click PublicFolder "https://github.com/daryllxd/x-gic-bank/tree/main/public/"

        PublicFolder --> Vercel
        Vite --> PublicFolder
    end

    classDef runtime fill:#e0ffe0,stroke:#0a0,stroke-width:1px
    classDef build fill:#e0f0ff,stroke:#00a,stroke-width:1px
    classDef testing fill:#ffe0b3,stroke:#fa0,stroke-width:1px
    classDef deployment fill:#eee,stroke:#666,stroke-width:1px
```
