# ismaelmarot/cash-counter architecture

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

- Interactive diagram: https://gitdiagram.com/ismaelmarot/cash-counter
- Repository: https://github.com/ismaelmarot/cash-counter

## Overview

##### Project Type & Purpose
- This is a frontend-only, single-page web application (SPA) built with React, TypeScript, and Vite.
- Purpose: Provide a quick, responsive UI to input bill denominations, calculate totals, and optionally export to PDF.

##### High-Level Components
a. User’s Browser (Client)
b. React Application Layer
- App Shell (src/App.tsx & main.tsx)
- UI Components (BillInput, Totals, Footer, LegalModal, TermsModal)
- Shared Utilities (constants, helpers)
- Styling (styled-components)
c. Build & Bundling (Vite)
d. Static Assets (public folder, screenshots, index.html)
e. Deployment Platform (GitHub Pages)

##### Relationships & Data Flows
- User → Browser → React App (initial page load via index.html)
- BillInput component emits events (onChange) → App state (useState in App.tsx)
- App state → Totals component (props) → UI update
- App state → optional export → jsPDF library (PDF generation)
- Build process: Vite reads src/ and public/, outputs static bundle → GitHub Pages hosting

##### Architectural Patterns & Design Principles
- Component-based architecture: each UI piece is isolated (BillInput, Totals, etc.)
- Unidirectional data flow: parent (App) holds state, passes props down, child events bubble up
- Separation of concerns:
– src/components (UI logic)
– src/constants (domain data: denominations)
– src/helpers (utilities, e.g., getCurrentYear)
– Styling is managed per-component (styled-components)
- Build-time tooling: Vite for fast HMR and bundling

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["User's Browser"]:::client
    Browser -->|loads index.html| ViteBundle["Vite Bundle"]:::build

    subgraph "Runtime (Browser)"
        AppShell["App Shell (App.tsx & main.tsx)"]:::app
        BillInput["BillInput"]:::ui
        Totals["Totals"]:::ui
        Footer["Footer"]:::ui
        LegalModal["LegalModal"]:::ui
        TermsModal["TermsModal"]:::ui
        Constants["Constants"]:::utils
        Helpers["Helpers"]:::utils
        jsPDFLib["jsPDF (PDF export)"]:::util2

        AppShell --> BillInput
        AppShell --> Totals
        AppShell --> Footer
        AppShell --> LegalModal
        AppShell --> TermsModal
        AppShell --> Constants
        AppShell --> Helpers
        AppShell --> jsPDFLib

        BillInput -->|onChange| AppShell
        AppShell -->|props| Totals
    end

    subgraph "Source Code & Build"
        SRC["src/ & public/"]:::code
        SRC --> ViteBundle
        Vitest["Vitest (Tests)"]:::test
        SRC --> Vitest
    end

    ViteBundle -.->|deploy| GitHubPages["GitHub Pages"]:::infra

    click AppShell "https://github.com/ismaelmarot/cash-counter/blob/main/src/App.tsx"
    click AppShell "https://github.com/ismaelmarot/cash-counter/blob/main/src/main.tsx"
    click BillInput "https://github.com/ismaelmarot/cash-counter/blob/main/src/components/BillInput/BillInput.tsx"
    click Totals "https://github.com/ismaelmarot/cash-counter/blob/main/src/components/Totals/Totals.tsx"
    click Footer "https://github.com/ismaelmarot/cash-counter/blob/main/src/components/Footer/Footer.tsx"
    click LegalModal "https://github.com/ismaelmarot/cash-counter/blob/main/src/components/LegalModal/LegalModal.tsx"
    click TermsModal "https://github.com/ismaelmarot/cash-counter/blob/main/src/components/TermsModal/TermsModal.tsx"
    click Constants "https://github.com/ismaelmarot/cash-counter/blob/main/src/constants/denominations.ts"
    click Helpers "https://github.com/ismaelmarot/cash-counter/blob/main/src/helpers/getCurrentYear.ts"

    classDef client fill:#eef,stroke:#00f,color:#000;
    classDef app fill:#cceeff,stroke:#009, color:#000;
    classDef ui fill:#ccddee,stroke:#006, color:#000;
    classDef utils fill:#ddffdd,stroke:#0a0, color:#000;
    classDef util2 fill:#ccffcc,stroke:#080, color:#000;
    classDef build fill:#ffe4b2,stroke:#f60, color:#000;
    classDef infra fill:#ffd9b3,stroke:#f50, color:#000;
    classDef code fill:#f0f0f0,stroke:#888, color:#000;
    classDef test fill:#f8d7da,stroke:#d00, color:#000;
```
