# sankarapubalaji/expensive-tracker-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/sankarapubalaji/expensive-tracker-frontend
- Repository: https://github.com/sankarapubalaji/expensive-tracker-frontend

## Overview

##### Project type and purpose
- This is a Single-Page Application (SPA) built with React (Create React App).
- It serves as a personal finance dashboard: users can register/login, track budgets and transactions, and view reports.
- There is no embedded backend code here—network calls go out to external HTTP APIs for auth, budgeting and reporting.

##### File structure
Top level:
– public/ → static HTML, manifest, robots.txt
– src/ → all client-side logic
- components/ (UI components grouped by feature: budgets, transactions, reports, common)
- pages/ (route-level containers for each screen)
- context/ (React Context providers: AuthContext, BudgetContext, TransactionContext, ThemeContext, FinanceCoordinator)
- services/ (API abstraction layers: api.js, auth.js)
- utils/, styles/ (helpers and styling)
– root package.json, build scripts for webpack, Babel, etc.

##### Readme insights
- Bootstrapped with CRA; no custom architecture notes.
- Assumes standard React build → deploy pipeline.

##### Main components and relationships
a. Browser / Frontend
- Entry point: index.js / App.js
- Routes: ProtectedRoute wraps pages (Home, Dashboard, BudgetsPage, TransactionsPage, ReportsPage, Profile, Settings, Login, Register, ForgotPassword)
- UI component tree: pages → skeleton components → feature components → common controls (Button, Input, Modal, Loader, Navbar)
b. State management layer
- Context providers wrap App:
– AuthContext handles login state & tokens
– BudgetContext manages budgets data cache
– TransactionContext manages transaction list & operations
– ThemeContext controls theming
– FinanceCoordinator can orchestrate cross-slice operations
c. Service / API layer
- src/services/api.js sets up Axios/fetch base URL, interceptors
- auth.js exposes login/register/forgot-password endpoints
- other endpoints implied (budgets, transactions, reports)
d. External systems
- Authentication & data REST API server (hosted elsewhere)
- Optionally: third-party charting or analytics (if used)

##### Architectural patterns & principles
- Component-based UI (React)
- Context API for global state (avoiding Redux)
- Separation of concerns:
– UI layer (components/pages)
– State layer (contexts)
– Data layer (services)
- Protected routes for auth gating
- Modals handled at component and utils level

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    subgraph "Browser / UI"
        Browser("Browser (User)"):::external
    end

    subgraph "React Application"
        subgraph "Entry & Routing"
            Index["index.js"]:::ui
            App["App.js"]:::ui
            ProtectedRoute["ProtectedRoute.jsx"]:::ui
        end

        subgraph "Pages & Routing"
            HomePage["HomePage.jsx"]:::ui
            DashboardPage["DashboardPage.jsx"]:::ui
            BudgetsPage["BudgetsPage.jsx"]:::ui
            TransactionsPage["TransactionsPage.jsx"]:::ui
            ReportsPage["ReportsPage.jsx"]:::ui
            ProfilePage["ProfilePage.jsx"]:::ui
            SettingsPage["SettingsPage.jsx"]:::ui
            LoginPage["LoginPage.jsx"]:::ui
            RegisterPage["RegisterPage.jsx"]:::ui
            ForgotPasswordPage["ForgotPasswordPage.jsx"]:::ui
        end

        subgraph "UI Components"
            subgraph "Budgets"
                AddBudgetModal["AddBudgetModal.jsx"]:::ui
                BudgetList["BudgetList.jsx"]:::ui
                BudgetSummary["BudgetSummary.jsx"]:::ui
            end
            subgraph "Transactions"
                AddTransactionModal["AddTransactionModal.jsx"]:::ui
                EditTransactionModal["EditTransactionModal.jsx"]:::ui
                DeleteConfirmationModal["DeleteConfirmationModal.jsx"]:::ui
                TransactionList["TransactionList.jsx"]:::ui
            end
            subgraph "Reports"
                ExpenseChartReports["ExpenseChart.jsx"]:::ui
                IncomeVsExpenseChart["IncomeVsExpenseChart.jsx"]:::ui
                ReportFilters["ReportFilters.jsx"]:::ui
            end
            subgraph "Dashboard"
                ExpenseChartDashboard["ExpenseChart.jsx"]:::ui
            end
            subgraph "Common Controls"
                Button["Button.jsx"]:::ui
                Input["Input.jsx"]:::ui
                Loader["Loader.jsx"]:::ui
                Modal["Modal.jsx"]:::ui
                Navbar["Navbar.jsx"]:::ui
            end
        end

        subgraph "Context Providers"
            AuthContext["AuthContext.jsx"]:::state
            BudgetContext["BudgetContext.jsx"]:::state
            TransactionContext["TransactionContext.jsx"]:::state
            ThemeContext["ThemeContext.jsx"]:::state
            FinanceCoordinator["FinanceCoordinator.jsx"]:::state
        end
    end

    subgraph "Service / API Layer"
        API["api.js"]:::service
        AuthService["auth.js"]:::service
    end

    subgraph "External API & DB"
        RestAPI["REST API Server"]:::external
        Database["Database"]:::external
    end

    %% Data Flows
    Browser -->|visits| Index
    Index -->|renders| App
    App -->|uses| ProtectedRoute
    ProtectedRoute -->|routes to| HomePage
    ProtectedRoute --> DashboardPage
    ProtectedRoute --> BudgetsPage
    ProtectedRoute --> TransactionsPage
    ProtectedRoute --> ReportsPage
    ProtectedRoute --> ProfilePage
    ProtectedRoute --> SettingsPage
    ProtectedRoute --> LoginPage
    ProtectedRoute --> RegisterPage
    ProtectedRoute --> ForgotPasswordPage

    HomePage -->|contains| Navbar
    DashboardPage -->|uses| ExpenseChartDashboard
    BudgetsPage -->|uses| AddBudgetModal
    BudgetsPage --> BudgetList
    BudgetsPage --> BudgetSummary
    TransactionsPage --> AddTransactionModal
    TransactionsPage --> EditTransactionModal
    TransactionsPage --> DeleteConfirmationModal
    TransactionsPage --> TransactionList
    ReportsPage --> ExpenseChartReports
    ReportsPage --> IncomeVsExpenseChart
    ReportsPage --> ReportFilters

    %% Common Controls used by all components
    HomePage --> Button
    HomePage --> Input
    HomePage --> Loader
    HomePage --> Modal
    HomePage --> Navbar

    %% State Layer interactions
    App --> AuthContext
    App --> BudgetContext
    App --> TransactionContext
    App --> ThemeContext
    App --> FinanceCoordinator

    AddBudgetModal --> AuthContext
    BudgetList --> BudgetContext
    BudgetSummary --> BudgetContext
    AddTransactionModal --> TransactionContext
    EditTransactionModal --> TransactionContext
    DeleteConfirmationModal --> TransactionContext
    TransactionList --> TransactionContext
    ExpenseChartReports --> FinanceCoordinator
    IncomeVsExpenseChart --> FinanceCoordinator
    ExpenseChartDashboard --> FinanceCoordinator

    %% Service calls
    AuthContext -->|HTTP POST /auth/login| AuthService
    AuthContext -->|HTTP POST /auth/register| AuthService
    AuthContext -->|HTTP POST /auth/forgot-password| AuthService
    BudgetContext -->|HTTP GET/POST /budgets| API
    TransactionContext -->|HTTP GET/POST /transactions| API
    FinanceCoordinator -->|HTTP GET /reports| API

    API -->|requests| RestAPI
    AuthService -->|auth requests| RestAPI
    RestAPI -->|reads/writes| Database

    %% Click Events
    click Index "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/index.js"
    click App "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/App.js"
    click ProtectedRoute "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/common/ProtectedRoute.jsx"
    click HomePage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/HomePage.jsx"
    click DashboardPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/DashboardPage.jsx"
    click BudgetsPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/BudgetsPage.jsx"
    click TransactionsPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/TransactionsPage.jsx"
    click ReportsPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/ReportsPage.jsx"
    click ProfilePage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/ProfilePage.jsx"
    click SettingsPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/SettingsPage.jsx"
    click LoginPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/LoginPage.jsx"
    click RegisterPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/RegisterPage.jsx"
    click ForgotPasswordPage "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/pages/ForgotPasswordPage.jsx"
    click AddBudgetModal "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/budgets/AddBudgetModal.jsx"
    click BudgetList "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/budgets/BudgetList.jsx"
    click BudgetSummary "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/budgets/BudgetSummary.jsx"
    click AddTransactionModal "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/transactions/AddTransactionModal.jsx"
    click EditTransactionModal "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/transactions/EditTransactionModal.jsx"
    click DeleteConfirmationModal "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/transactions/DeleteConfirmationModal.jsx"
    click TransactionList "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/transactions/TransactionList.jsx"
    click ExpenseChartReports "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/reports/ExpenseChart.jsx"
    click IncomeVsExpenseChart "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/reports/IncomeVsExpenseChart.jsx"
    click ReportFilters "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/reports/ReportFilters.jsx"
    click ExpenseChartDashboard "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/dashboard/ExpenseChart.jsx"
    click Button "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/common/Button.jsx"
    click Input "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/common/Input.jsx"
    click Loader "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/common/Loader.jsx"
    click Modal "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/common/Modal.jsx"
    click Navbar "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/components/common/Navbar.jsx"
    click AuthContext "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/context/AuthContext.jsx"
    click BudgetContext "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/context/BudgetContext.jsx"
    click TransactionContext "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/context/TransactionContext.jsx"
    click ThemeContext "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/context/ThemeContext.jsx"
    click FinanceCoordinator "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/context/FinanceCoordinator.jsx"
    click API "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/services/api.js"
    click AuthService "https://github.com/sankarapubalaji/expensive-tracker-frontend/blob/main/src/services/auth.js"
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#000
    classDef state fill:#DFF5D8,stroke:#28a745,color:#000
    classDef service fill:#FFE5B4,stroke:#ff8c00,color:#000
    classDef external fill:#EEEEEE,stroke:#666666,color:#000
```
