# gauravkesh/expense-tracker architecture

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

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

## Overview

##### Project type and purpose
- This is a modern, full-stack Personal Finance Tracker.
- Frontend: Next.js (App Router + legacy pages), React, TypeScript, Tailwind CSS and shadcn/ui.
- Backend: Separate Node.js REST API (hosted on Render).
- Database: MongoDB (likely Atlas).
- Purpose: allow users to create and manage transactions, budgets, categories, and view analytics via charts.

##### File structure
- Top-level Next.js app directory:
– `/app`: App Router pages (dashboard, settings, transactions)
– `/pages`: legacy page-based routing for BudgetsPage, CategoriesPage, etc.
– `/components`: atomic and composite UI (cards, charts, forms, layout, modules, and shadcn/ui primitives)
– `/lib`: utility functions and API‐endpoint helpers (`piendpoint.ts`)
– Configuration: `next.config.js`, `postcss.config.js`, `tailwind.config.ts`, `tsconfig.json`, `.eslintrc.json`
- No local “api” folder—frontend calls out to the separate Node.js API on Render.
- The presence of modular UI components (forms, charts, modals) indicates a clear component-driven architecture.

##### README for additional insights
- Confirms tech stack, features, API endpoints (transactions, budgets, categories).
- Backend API URL: `https://personal-expense-backend.onrender.com/api/...`.
- Emphasis on charts (Recharts), state management via React hooks, shadcn/dialogs for modals.

##### Essential architectural elements
- Separation of concerns: UI vs. business logic vs. data layer.
- CRUD flows for transactions, budgets, categories.
- Where styling (Tailwind), charts (Recharts), dialogs (Radix) fit into the frontend.
- Do not over-complicate—focus on the core components and their interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Layer
    Browser["User's Browser"]:::external

    subgraph "Frontend"
        direction TB
        NextServer["Next.js Server\n(SSR & CSR)"]:::frontend

        subgraph "App Router Pages"
            direction TB
            DashboardApp["Dashboard"]:::frontend
            TransactionsApp["Transactions"]:::frontend
            SettingsBudgetApp["Settings→Budgets"]:::frontend
            SettingsCategoryApp["Settings→Categories"]:::frontend
            RootLayout["Root Layout"]:::frontend
            GlobalsCSS["Global Styles"]:::frontend
            AppRootPage["App Root Page"]:::frontend
        end

        subgraph "Legacy Pages"
            direction TB
            DashboardPage["Dashboard (Legacy)"]:::frontend
            TransactionsPage["Transactions (Legacy)"]:::frontend
            BudgetsPage["Budgets (Legacy)"]:::frontend
            CategoriesPage["Categories (Legacy)"]:::frontend
        end

        subgraph "UI Components"
            direction TB
            SummaryCard["SummaryCard"]:::frontend
            BudgetChart["BudgetChart"]:::frontend
            CategoryChart["CategoryChart"]:::frontend
            MonthlyChart["MonthlyChart"]:::frontend
            TransactionForm["TransactionForm"]:::frontend
            BudgetForm["BudgetForm"]:::frontend
            CategoryForm["CategoryForm"]:::frontend
            Navbar["Navbar"]:::frontend
            RenderInfoPopup["RenderInfoPopup"]:::frontend
        end

        State["State Management\n(React Hooks)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend API"
        direction TB
        API["Node.js REST API"]:::backend
        Controllers["Business Logic\n(Transactions, Budgets, Categories)"]:::backend
        DAL["Data Access Layer\n(MongoDB Client)"]:::backend
    end

    %% Database
    DB["MongoDB Atlas"]:::database

    %% Data Flows
    Browser -->|"interacts via UI"| NextServer
    NextServer -->|renders| DashboardApp
    NextServer -->|renders| TransactionsApp
    NextServer -->|renders| SettingsBudgetApp
    NextServer -->|renders| SettingsCategoryApp
    NextServer -->|renders| RootLayout
    NextServer -->|loads| GlobalsCSS
    NextServer -->|renders| AppRootPage

    NextServer -->|renders| DashboardPage
    NextServer -->|renders| TransactionsPage
    NextServer -->|renders| BudgetsPage
    NextServer -->|renders| CategoriesPage

    NextServer -->|uses| SummaryCard
    NextServer -->|uses| BudgetChart
    NextServer -->|uses| CategoryChart
    NextServer -->|uses| MonthlyChart
    NextServer -->|uses| TransactionForm
    NextServer -->|uses| BudgetForm
    NextServer -->|uses| CategoryForm
    NextServer -->|uses| Navbar
    NextServer -->|uses| RenderInfoPopup
    NextServer -->|manages state with| State

    State -->|"calls API"| API
    TransactionForm -->|POST/PUT/DELETE| API
    BudgetForm -->|POST/PUT/DELETE| API
    CategoryForm -->|POST/PUT/DELETE| API
    BudgetChart -->|GET data| API
    CategoryChart -->|GET data| API
    MonthlyChart -->|GET data| API

    API -->|routes to| Controllers
    Controllers -->|queries| DAL
    DAL -->|reads/writes| DB
    DB -->|responds| DAL
    DAL -->|returns data| Controllers
    Controllers -->|formats JSON| API
    API -->|HTTP response| NextServer
    NextServer -->|updates view| Browser

    %% Click Events for Frontend Files
    click DashboardApp "https://github.com/gauravkesh/expense-tracker/blob/main/app/dashboard/page.tsx"
    click TransactionsApp "https://github.com/gauravkesh/expense-tracker/blob/main/app/transactions/page.tsx"
    click SettingsBudgetApp "https://github.com/gauravkesh/expense-tracker/blob/main/app/settings/budget/page.tsx"
    click SettingsCategoryApp "https://github.com/gauravkesh/expense-tracker/blob/main/app/settings/category/page.tsx"
    click RootLayout "https://github.com/gauravkesh/expense-tracker/blob/main/app/layout.tsx"
    click GlobalsCSS "https://github.com/gauravkesh/expense-tracker/blob/main/app/globals.css"
    click AppRootPage "https://github.com/gauravkesh/expense-tracker/blob/main/app/page.tsx"

    click DashboardPage "https://github.com/gauravkesh/expense-tracker/blob/main/pages/Dashboard.tsx"
    click TransactionsPage "https://github.com/gauravkesh/expense-tracker/blob/main/pages/TransactionsPage.tsx"
    click BudgetsPage "https://github.com/gauravkesh/expense-tracker/blob/main/pages/BudgetsPage.tsx"
    click CategoriesPage "https://github.com/gauravkesh/expense-tracker/blob/main/pages/CategoriesPage.tsx"

    click SummaryCard "https://github.com/gauravkesh/expense-tracker/blob/main/components/cards/SummaryCard.tsx"
    click BudgetChart "https://github.com/gauravkesh/expense-tracker/blob/main/components/charts/BudgetChart.tsx"
    click CategoryChart "https://github.com/gauravkesh/expense-tracker/blob/main/components/charts/CategoryChart.tsx"
    click MonthlyChart "https://github.com/gauravkesh/expense-tracker/blob/main/components/charts/MonthlyChart.tsx"
    click TransactionForm "https://github.com/gauravkesh/expense-tracker/blob/main/components/forms/TransactionForm.tsx"
    click BudgetForm "https://github.com/gauravkesh/expense-tracker/blob/main/components/forms/BudgetForm.tsx"
    click CategoryForm "https://github.com/gauravkesh/expense-tracker/blob/main/components/forms/CategoryForm.tsx"
    click Navbar "https://github.com/gauravkesh/expense-tracker/blob/main/components/layout/Navbar.tsx"
    click RenderInfoPopup "https://github.com/gauravkesh/expense-tracker/blob/main/components/layout/RenderInfoPopup.tsx"

    %% Click Events for Utility & Config
    click lib_piendpoint "https://github.com/gauravkesh/expense-tracker/blob/main/lib/piendpoint.ts"
    click lib_utils "https://github.com/gauravkesh/expense-tracker/blob/main/lib/utils.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#155724,color:#155724,stroke-width:1px
    classDef database fill:#fff3cd,stroke:#856404,color:#856404,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d,stroke-width:1px
```
