# afrit-bagani/expense-tracker-app architecture

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

- Interactive diagram: https://gitdiagram.com/afrit-bagani/expense-tracker-app
- Repository: https://github.com/afrit-bagani/expense-tracker-app

## Overview

##### Project type and purpose
- This is a single‑page React application (built with Vite) that runs entirely in the browser.
- Purpose: Track budgets, incomes, and expenses, persisting data in the browser’s local storage.

##### File structure
- Top‑level files and folders:
- index.html / public : static shell and assets.
- src : source code for the React SPA.
- src/main.jsx: application entry point.
- src/App.jsx: top‑level component (router, layout wrapper).
- src/pages: route views (Dashboard, BudgetPage, ExpensesPage, Error).
- src/components: reusable UI pieces (forms, items, table, nav bar, intro).
- src/actions: functions that encapsulate business logic (add/delete budgets/expenses, logout).
- src/helper.js: utility routines (e.g., Local Storage wrappers).
- Configuration for bundling: vite.config.js, eslint.config.js.

##### Key architectural insights from the README
- No backend service—data persisted via browser local storage.
- Pure front‑end SPA using HTML, CSS, JavaScript (React).

##### Main components
a. User Interface (Browser)
- index.html + bundled JS/CSS delivered by Vite
- React runtime rendering App, Layouts, Pages, Components
b. Business Logic Layer
- src/actions functions (deleteBudget, logout, etc.)
- src/helper.js (localStorage handlers)
c. Data Store
- Browser local storage (persistent key‑value store)
d. Build/Dev Tooling (optional to include)
- Vite dev server / bundler

##### Relationships and interactions
- User clicks or submits in React Components → calls an action → action uses helper to read/write browser local storage → updates component state → React re‑renders UI.
- Navigation between pages handled by React Router (implied in App.jsx).
- index.html loads the compiled JS/CSS bundle produced by Vite.

##### Architectural patterns/design principles
- Single‑Page Application (SPA)
- Separation of concerns:
- Presentation: components under src/components & src/pages
- Business logic: src/actions
- Data persistence: src/helper.js interacting with local storage
- Unidirectional data flow: user events → actions → storage → state → UI

##### Elements
- Labels: “App Entry (main.jsx)”, “Router (App.jsx)”, “Pages”, “UI Components”
- Action modules: “deleteBudget.js”, “logout.js”, etc.
- Helper module: “helper.js (localStorage API)”
- User → UI
- UI → Actions
- Actions ↔ Local Storage
- Updated data → UI

##### Putting it all together
- Start at the browser loading index.html
- Branch into:
- Page Rendering (Dashboard, BudgetPage, ExpensesPage)
- Common Layout (Nav, Intro)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser UI Layer
    subgraph "Browser UI" 
        direction TB
        IDX["index.html"]:::ui
        MAIN["App Entry (src/main.jsx)"]:::ui
        APP["Router & Top-Level (src/App.jsx)"]:::ui
        LAYOUT["Layout Wrapper (src/layouts/Main.jsx)"]:::ui
        subgraph "Pages & Components"
            direction TB
            DASH["Dashboard Page"]:::ui
            BUDPAGE["Budget Page"]:::ui
            EXPPAGE["Expenses Page"]:::ui
            ERRPAGE["Error Page"]:::ui
            ADDB["AddBudgetForm"]:::ui
            ADDE["AddExpenseForm"]:::ui
            BUDI["BudgetItem"]:::ui
            EXPI["ExpenseItem"]:::ui
            INTRO["Intro Section"]:::ui
            NAV["Navigation Bar"]:::ui
            TABLE["Data Table"]:::ui
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic" 
        direction TB
        DELB["deleteBudget action"]:::logic
        LOGOUT["logout action"]:::logic
        HELPER["helper.js (LocalStorage API)"]:::logic
    end

    %% Data Persistence
    subgraph "Data Store"
        direction TB
        LOCALSTG["Browser Local Storage"]:::data
    end

    %% Build & Dev Tools
    subgraph "Build & Dev Tools"
        direction TB
        VITE["vite.config.js"]:::tools
        ESLINT["eslint.config.js"]:::tools
    end

    %% Static Assets
    subgraph "Static Assets"
        direction TB
        PUBLIC["public/"]:::tools
        ASSETS["src/assets/"]:::tools
    end

    %% Connections
    VITE -->|"build bundle"| IDX
    ESLINT --> IDX

    IDX -->|"loads bundle"| MAIN
    MAIN -->|"renders App"| APP
    APP -->|"uses layout"| LAYOUT
    LAYOUT -->|"renders pages/components"| DASH
    LAYOUT --> BUDPAGE
    LAYOUT --> EXPPAGE
    LAYOUT --> ERRPAGE
    LAYOUT --> INTRO
    LAYOUT --> NAV
    LAYOUT --> TABLE

    DASH -->|"contains"| ADDB
    DASH --> ADDE
    DASH --> BUDI
    DASH --> EXPI

    BUDPAGE --> ADDB
    EXPPAGE --> ADDE

    %% User events to actions
    ADDB -->|"submit add budget"| DELB
    ADDE -->|"submit add expense"| DELB
    NAV -->|"click logout"| LOGOUT

    %% Actions to helper and storage
    DELB -->|"write/read"| HELPER
    LOGOUT -->|"invoke"| HELPER
    HELPER -->|"persist/retrieve"| LOCALSTG

    %% Data flow back to UI
    LOCALSTG -->|"return data"| HELPER
    HELPER -->|"update state"| APP

    %% Static assets usage
    IDX --> PUBLIC
    IDX --> ASSETS

    %% Click Events
    click IDX "https://github.com/afrit-bagani/expense-tracker-app/blob/main/index.html"
    click MAIN "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/main.jsx"
    click APP "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/App.jsx"
    click LAYOUT "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/layouts/Main.jsx"
    click DASH "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/pages/Dashboard.jsx"
    click BUDPAGE "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/pages/BudgetPage.jsx"
    click EXPPAGE "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/pages/ExpensesPage.jsx"
    click ERRPAGE "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/pages/Error.jsx"
    click ADDB "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/components/AddBudgetForm.jsx"
    click ADDE "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/components/AddExpenseForm.jsx"
    click BUDI "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/components/BudgetItem.jsx"
    click EXPI "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/components/ExpenseItem.jsx"
    click INTRO "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/components/Intro.jsx"
    click NAV "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/components/Nav.jsx"
    click TABLE "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/components/Table.jsx"
    click DELB "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/actions/deleteBudget.js"
    click LOGOUT "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/actions/logout.js"
    click HELPER "https://github.com/afrit-bagani/expense-tracker-app/blob/main/src/helper.js"
    click PUBLIC "https://github.com/afrit-bagani/expense-tracker-app/tree/main/public/"
    click ASSETS "https://github.com/afrit-bagani/expense-tracker-app/tree/main/src/assets/"
    click VITE "https://github.com/afrit-bagani/expense-tracker-app/blob/main/vite.config.js"
    click ESLINT "https://github.com/afrit-bagani/expense-tracker-app/blob/main/eslint.config.js"

    %% Styles
    classDef ui fill:#B3E5FC,stroke:#0288D1,stroke-width:1px
    classDef logic fill:#C8E6C9,stroke:#2E7D32,stroke-width:1px
    classDef data fill:#FFF9C4,stroke:#F9A825,stroke-width:1px
    classDef tools fill:#E1BEE7,stroke:#6A1B9A,stroke-width:1px
```
