# sakshi107/expense-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/sakshi107/expense-tracker
- Repository: https://github.com/sakshi107/expense-tracker

## Overview

##### Project Type and Purpose
- This is a single-page React application (“Spendee”) for tracking incomes/expenses via voice commands.
- It uses the Web Speech API for speech recognition, React Context for state management, and Material-UI for styling.

##### File Structure Analysis
- public/ – static assets (index.html, manifest.json, robots.txt).
- src/
– index.js, App.js – React entry point and root component.
– components/ – UI building blocks:
- Main/Form (captures new transactions via text or speech)
- Main/List (renders transaction list)
- Details (shows aggregates: income, expense, balance)
- Snackbar (feedback UI)
- InfoCard (category-based info display)
– context/ – React Context provider and reducer (global state management).
– constants/ – transaction categories definitions.
– utils/ – helper functions (formatDate).
– useTransactions.js – custom hook for interacting with context.

##### README Insights
- Core features: speech-based entry, categorize/delete transactions, budget overview.
- Deployment: static hosting on Netlify.
- Tech stack: React, Material-UI, Web Speech API.

##### Defining Main Components
a. Client Browser (host environment)
b. React Application (inside browser)
– App Component (entry)
– Context Provider & Reducer (state layer)
– UI Components (Form, List, Details, Snackbar, InfoCard)
– Custom Hook (useTransactions)
– Constants & Utils
c. External Services/APIs
– Web Speech API (speech-to-text)
– Netlify (static asset hosting/CDN)

##### Relationships and Data Flows
- User → Browser UI: clicks “Start listening” or types →
- UI Component (Form) → Web Speech API → transcribed text →
- Form dispatches “ADD_TRANSACTION” → Context Reducer updates state →
- Updated state flows into List & Details components →
- Snackbar component listens for “success”/“error” events → shows feedback →
- Final UI update rendered in browser

##### Architectural Patterns & Principles
- Component-based design: each feature lives in its own directory/component.
- Unidirectional data flow: UI → actions → reducer → state → UI.
- Separation of concerns:
– UI (Material-UI styled components)
– State (Context + Reducer)
– Business logic (useTransactions hook, utils)

1. Browser Layer
2. State Management Layer
– Context Provider → Reducer → Custom Hook
3. UI Component Layer
– Form, List, Details, Snackbar, InfoCard
4. External Layer
– Web Speech API
– Netlify Hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Layer
    subgraph "Browser Layer"
        ReactApp["React App"]:::frame
    end

    %% React Entry
    subgraph "React Entry"
        Index["index.js"]:::ui
    end

    %% State Management Layer
    subgraph "State Management"
        CP["Context Provider"]:::state
        CR["Context Reducer"]:::state
        UH["useTransactions Hook"]:::state
        Consts["categories.js"]:::utils
        Util["formatDate.js"]:::utils
    end

    %% UI Component Layer
    subgraph "UI Components"
        AppComp["App (Entry)"]:::ui
        MainContainer["Main Container"]:::ui
        Form["Form"]:::ui
        List["List"]:::ui
        Details["Details"]:::ui
        Snackbar["Snackbar"]:::ui
        InfoCard["InfoCard"]:::ui
    end

    %% External Layer
    subgraph "External Services"
        WebSpeech["Web Speech API"]:::external
        Netlify["Netlify Hosting"]:::external
    end

    %% Connections
    Index -->|renders| AppComp
    AppComp -->|wraps| CP
    AppComp --> MainContainer
    MainContainer --> Form
    MainContainer --> List
    CP --> UH
    CP --> CR
    CR -->|state update| List
    CR -->|state update| Details
    CR -->|state update| InfoCard
    Form -->|voice input| WebSpeech
    WebSpeech -->|transcribed text| Form
    Form -->|dispatch ADD_TRANSACTION| CR
    Form -->|uses constants| Consts
    InfoCard -->|uses constants| Consts
    Form -->|uses utils| Util
    List -->|reads state via hook| UH
    Details -->|reads state via hook| UH
    Snackbar -->|listens for events| CR
    Netlify -->|serves static assets| ReactApp

    %% Click Events
    click AppComp "https://github.com/sakshi107/expense-tracker/blob/master/src/App.js"
    click Index "https://github.com/sakshi107/expense-tracker/blob/master/src/index.js"
    click CP "https://github.com/sakshi107/expense-tracker/blob/master/src/context/context.js"
    click CR "https://github.com/sakshi107/expense-tracker/blob/master/src/context/contextReducer.js"
    click UH "https://github.com/sakshi107/expense-tracker/blob/master/src/useTransactions.js"
    click Consts "https://github.com/sakshi107/expense-tracker/blob/master/src/constants/categories.js"
    click Util "https://github.com/sakshi107/expense-tracker/blob/master/src/utils/formatDate.js"
    click MainContainer "https://github.com/sakshi107/expense-tracker/blob/master/src/components/Main/Main.jsx"
    click Form "https://github.com/sakshi107/expense-tracker/blob/master/src/components/Main/Form/Form.jsx"
    click List "https://github.com/sakshi107/expense-tracker/blob/master/src/components/Main/List/List.jsx"
    click Details "https://github.com/sakshi107/expense-tracker/blob/master/src/components/Details/Details.jsx"
    click Snackbar "https://github.com/sakshi107/expense-tracker/blob/master/src/components/Snackbar/Snackbar.jsx"
    click InfoCard "https://github.com/sakshi107/expense-tracker/blob/master/src/components/InfoCard.jsx"

    %% Styles
    classDef ui fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px
    classDef state fill:#C8E6C9,stroke:#66BB6A,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#FFB74D,stroke-width:1px
    classDef utils fill:#F0F4C3,stroke:#C0CA33,stroke-width:1px
    classDef frame fill:#BBDEFB,stroke:#64B5F6,stroke-width:2px;font-weight:bold
```
