# anmolpandeyy/expense-cal architecture

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

- Interactive diagram: https://gitdiagram.com/anmolpandeyy/expense-cal
- Repository: https://github.com/anmolpandeyy/expense-cal

## Overview

##### Project type and purpose
- ExpenseCal is a single‐page, mobile‐first web application built with Next.js (React) and TypeScript.
- It has no separate backend service; all data is managed client-side via a Zustand store persisted in Local Storage.
- It delivers static assets (HTML/CSS/JS) through Next.js, with CI/CD (GitHub Actions) handling build and deploy.

##### File structure
- Top-level directories:
- app/ – Next.js App Router files (layout.tsx, page.tsx)
- components/ – React UI components subdivided into ui/, forms/, shared/
- lib/ – application core logic: store (Zustand), types (TypeScript interfaces), utils (helpers like CSV import/export)
- styles/ – Tailwind global CSS
- Config/build files: next.config.js, tsconfig.json, tailwind.config.js, postcss.config.js, GitHub Actions workflow (.github/workflows/deploy.yml).

##### README for additional insights
- Tech stack: Next.js 14, TypeScript, Tailwind CSS, Zustand (persist middleware), Shadcn/ui, react-chartjs-2 (Chart.js), Lucide React, date-fns.
- Core features: transaction CRUD, monthly summaries, charts, export/import JSON, offline Local Storage.
- No external APIs in MVP; future enhancements plan for authentication and cloud sync.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["Browser / Client"]

    %% Next.js App Router
    subgraph "Next.js App Router"
        direction TB
        Page["page.tsx"]:::frontend
        Layout["layout.tsx"]:::frontend
    end

    Browser -->|"render App"| Page
    Page -->|"wraps UI"| Layout

    %% UI Components
    subgraph "UI Layer"
        direction TB
        AddForm["AddTransactionForm"]:::frontend
        ExportForm["ExportForm"]:::frontend
        DataMgmt["DataManagement"]:::frontend
        Drawer["Drawer"]:::frontend
        ChartComp["ExpenseChart"]:::frontend
        MonthSel["MonthSelector"]:::frontend
        Summary["Summary"]:::frontend
        TransDetails["TransactionDetails"]:::frontend
        TransList["TransactionList"]:::frontend
        Button["Button"]:::frontend
    end

    Layout -->|"uses component"| AddForm
    Layout -->|"uses component"| ExportForm
    Layout -->|"uses component"| DataMgmt
    Layout -->|"uses component"| Drawer
    Layout -->|"uses component"| ChartComp
    Layout -->|"uses component"| MonthSel
    Layout -->|"uses component"| Summary
    Layout -->|"uses component"| TransDetails
    Layout -->|"uses component"| TransList
    Layout -->|"uses primitive"| Button

    %% State & Persistence
    subgraph "State & Persistence"
        direction TB
        Zustand["Zustand Store"]:::state
        Types["Type Definitions"]:::state
        Utils["Utilities"]:::state
        LocalStorage["Local Storage"]:::state
    end

    AddForm -->|"dispatch action"| Zustand
    ExportForm -->|"dispatch action"| Zustand
    DataMgmt -->|"dispatch action"| Zustand
    Drawer -->|"dispatch action"| Zustand
    ChartComp -->|"subscribe state"| Zustand
    MonthSel -->|"subscribe state"| Zustand
    Summary -->|"subscribe state"| Zustand
    TransDetails -->|"subscribe state"| Zustand
    TransList -->|"subscribe state"| Zustand
    Button -->|"dispatch action"| Zustand

    Zustand -->|"persist state"| LocalStorage
    LocalStorage -->|"rehydrate state"| Zustand
    Zustand -->|"uses types"| Types
    Zustand -->|"uses utils"| Utils

    %% Static Assets
    subgraph "Static Assets"
        direction TB
        Icons["icons/"]:::assets
        Manifest["manifest.json"]:::assets
    end

    Layout -->|"HTTP GET static assets"| Icons
    Layout -->|"HTTP GET static assets"| Manifest
    Utils -->|"generate icons"| Icons

    %% Build & Deploy
    subgraph "Build & Deploy Pipeline"
        direction TB
        GHActions["GitHub Actions"]:::deploy
        Scripts["Build-time Scripts"]:::deploy
        Hosting["Hosting (e.g., Vercel)"]:::deploy
    end

    GHActions -->|"run scripts"| Scripts
    Scripts -->|"generate icons"| Icons
    GHActions -->|"build Next.js"| Page
    GHActions -->|"deploy build"| Hosting

    %% Click Events
    click Page "https://github.com/anmolpandeyy/expense-cal/blob/main/app/page.tsx"
    click Layout "https://github.com/anmolpandeyy/expense-cal/blob/main/app/layout.tsx"
    click AddForm "https://github.com/anmolpandeyy/expense-cal/blob/main/components/forms/AddTransactionForm.tsx"
    click ExportForm "https://github.com/anmolpandeyy/expense-cal/blob/main/components/forms/ExportForm.tsx"
    click DataMgmt "https://github.com/anmolpandeyy/expense-cal/blob/main/components/shared/DataManagement.tsx"
    click Drawer "https://github.com/anmolpandeyy/expense-cal/blob/main/components/shared/Drawer.tsx"
    click ChartComp "https://github.com/anmolpandeyy/expense-cal/blob/main/components/shared/ExpenseChart.tsx"
    click MonthSel "https://github.com/anmolpandeyy/expense-cal/blob/main/components/shared/MonthSelector.tsx"
    click Summary "https://github.com/anmolpandeyy/expense-cal/blob/main/components/shared/Summary.tsx"
    click TransDetails "https://github.com/anmolpandeyy/expense-cal/blob/main/components/shared/TransactionDetails.tsx"
    click TransList "https://github.com/anmolpandeyy/expense-cal/blob/main/components/shared/TransactionList.tsx"
    click Button "https://github.com/anmolpandeyy/expense-cal/blob/main/components/ui/button.tsx"
    click Zustand "https://github.com/anmolpandeyy/expense-cal/blob/main/lib/store/index.ts"
    click Types "https://github.com/anmolpandeyy/expense-cal/blob/main/lib/types/index.ts"
    click Utils "https://github.com/anmolpandeyy/expense-cal/blob/main/lib/utils/index.ts"
    click Icons "https://github.com/anmolpandeyy/expense-cal/tree/main/public/icons/"
    click Manifest "https://github.com/anmolpandeyy/expense-cal/blob/main/public/manifest.json"
    click Scripts "https://github.com/anmolpandeyy/expense-cal/blob/main/scripts/generate-icons.js"
    click Scripts "https://github.com/anmolpandeyy/expense-cal/blob/main/scripts/test-csv-import.js"
    click GHActions "https://github.com/anmolpandeyy/expense-cal/blob/main/.github/workflows/deploy.yml"

    %% Styles (not clickable)
    Styles["styles/globals.css"]:::assets
    TailwindConfig["tailwind.config.js"]:::assets
    PostCSSConfig["postcss.config.js"]:::assets

    %% Styles integration
    Layout -->|"imports CSS"| Styles
    Layout -->|"imports config"| TailwindConfig
    Layout -->|"imports config"| PostCSSConfig

    %% Classes
    classDef frontend fill:#cfe2ff,stroke:#0275d8,color:#000
    classDef state fill:#d1e7dd,stroke:#0f5132,color:#000
    classDef assets fill:#f0f0f0,stroke:#6c757d,color:#000
    classDef deploy fill:#ffe5b4,stroke:#ff8c00,color:#000
```
