How daryllxd/x-gic-bank works
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