# piyushtanwani/spendwise architecture

> Architecture diagram of the GitHub repository piyushtanwani/spendwise, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/piyushtanwani/spendwise
- Repository: https://github.com/piyushtanwani/spendwise

## Overview

Spendwise is a personal-finance tracker with a friend-to-friend expense-splitting product. Users authenticate, then manage transactions, categories and budgets or use the Split area to manage friends, record shared expenses and settle balances; the dashboard summarizes personal and shared finances. The graph follows the React page-to-API flow into Express routes, controllers and MongoDB models. Several feature modules are represented at their exact source paths, but their internal calls were not sampled; edges are limited to README statements and relationships listed in the SOURCE INDEX.

Main entry points: [`server/server.js`](https://github.com/piyushtanwani/spendwise/blob/main/server/server.js) (Express app), [`client/src/services/api.js`](https://github.com/piyushtanwani/spendwise/blob/main/client/src/services/api.js) (Axios API client), [`server/models`](https://github.com/piyushtanwani/spendwise/tree/main/server/models) (MongoDB models), [`server/controllers/authController.js`](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/authController.js) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React application"]
  node_authui["Auth screens"]
  node_authcontext["Session state<br/>[AuthContext.jsx]"]
  node_dashboard["Finance dashboard<br/>[Dashboard.jsx]"]
  node_transactionsui["Transactions screen<br/>[Transactions.jsx]"]
  node_categoriesui["Categories screen<br/>[Categories.jsx]"]
  node_budgetsui["Budgets screen<br/>[Budgets.jsx]"]
  node_splitui["Split workspace<br/>[Split.jsx]"]
  node_api["Axios API client<br/>[api.js]"]
end

subgraph group_api["Express API"]
  node_server["Express app<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authcontroller["Authentication<br/>[authController.js]"]
  node_models[("MongoDB models")]
  node_email["SMTP email<br/>[emailService.js]"]
end

subgraph group_finance["Personal finance"]
  node_analytics["Analytics"]
  node_transaction["Transactions"]
  node_category["Categories"]
  node_budget["Budgets"]
end

subgraph group_splitting["Expense splitting"]
  node_friend["Friend management"]
  node_split["Shared expenses<br/>[splitController.js]"]
end

node_user(("User"))
node_google["Google Identity"]
node_mongodb[("MongoDB")]

node_user -->|"signs in"| node_authui
node_authui -->|"submits credentials"| node_authcontext
node_authcontext -->|"calls endpoints"| node_api
node_api -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_authroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_models
node_authcontroller -->|"sends OTP"| node_email
node_authcontroller -->|"verifies credential"| node_google
node_dashboard -->|"fetches summaries"| node_api
node_transactionsui -->|"manages transactions"| node_api
node_categoriesui -->|"manages categories"| node_api
node_budgetsui -->|"manages budgets"| node_api
node_splitui -->|"uses split endpoints"| node_api
node_server -->|"routes requests"| node_transaction
node_server -->|"routes requests"| node_category
node_server -->|"routes requests"| node_budget
node_server -->|"routes requests"| node_analytics
node_server -->|"routes requests"| node_friend
node_server -->|"routes requests"| node_split
node_transaction -->|"reads and writes"| node_models
node_category -->|"reads and writes"| node_models
node_budget -->|"reads and writes"| node_models
node_analytics -.->|"queries data"| node_models
node_friend -->|"reads and writes"| node_models
node_split -->|"reads and writes"| node_models
node_friend -->|"computes balances"| node_split
node_server -->|"connects"| node_mongodb

click node_authui "https://github.com/piyushtanwani/spendwise/tree/main/client/src/pages"
click node_authcontext "https://github.com/piyushtanwani/spendwise/blob/main/client/src/context/AuthContext.jsx"
click node_dashboard "https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Dashboard.jsx"
click node_transactionsui "https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Transactions.jsx"
click node_categoriesui "https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Categories.jsx"
click node_budgetsui "https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Budgets.jsx"
click node_splitui "https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Split.jsx"
click node_api "https://github.com/piyushtanwani/spendwise/blob/main/client/src/services/api.js"
click node_server "https://github.com/piyushtanwani/spendwise/blob/main/server/server.js"
click node_authroutes "https://github.com/piyushtanwani/spendwise/blob/main/server/routes/authRoutes.js"
click node_authcontroller "https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/authController.js"
click node_analytics "https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/analyticsController.js"
click node_transaction "https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/transactionController.js"
click node_category "https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/categoryController.js"
click node_budget "https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/budgetController.js"
click node_friend "https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/friendController.js"
click node_split "https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/splitController.js"
click node_models "https://github.com/piyushtanwani/spendwise/tree/main/server/models"
click node_email "https://github.com/piyushtanwani/spendwise/blob/main/server/utils/emailService.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_authui,node_authcontext,node_dashboard,node_transactionsui,node_categoriesui,node_budgetsui,node_splitui,node_api,node_user toneBlue
class node_server,node_authroutes,node_authcontroller,node_models,node_email,node_mongodb toneAmber
class node_analytics,node_transaction,node_category,node_budget toneMint
class node_friend,node_split toneRose
class node_google toneIndigo
```

## Components

### React application

- [Auth screens](https://github.com/piyushtanwani/spendwise/tree/main/client/src/pages): `client/src/pages`
- [Session state](https://github.com/piyushtanwani/spendwise/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Finance dashboard](https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Dashboard.jsx): `client/src/pages/Dashboard.jsx`
- [Transactions screen](https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Transactions.jsx): `client/src/pages/Transactions.jsx`
- [Categories screen](https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Categories.jsx): `client/src/pages/Categories.jsx`
- [Budgets screen](https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Budgets.jsx): `client/src/pages/Budgets.jsx`
- [Split workspace](https://github.com/piyushtanwani/spendwise/blob/main/client/src/pages/Split.jsx): `client/src/pages/Split.jsx`
- [Axios API client](https://github.com/piyushtanwani/spendwise/blob/main/client/src/services/api.js): `client/src/services/api.js`

### Express API

- [Express app](https://github.com/piyushtanwani/spendwise/blob/main/server/server.js): `server/server.js`
- [Auth routes](https://github.com/piyushtanwani/spendwise/blob/main/server/routes/authRoutes.js): `server/routes/authRoutes.js`
- [Authentication](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/authController.js): `server/controllers/authController.js`
- [MongoDB models](https://github.com/piyushtanwani/spendwise/tree/main/server/models): `server/models`
- [SMTP email](https://github.com/piyushtanwani/spendwise/blob/main/server/utils/emailService.js): `server/utils/emailService.js`

### Personal finance

- [Analytics](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/analyticsController.js): `server/controllers/analyticsController.js`
- [Transactions](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/transactionController.js): `server/controllers/transactionController.js`
- [Categories](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/categoryController.js): `server/controllers/categoryController.js`
- [Budgets](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/budgetController.js): `server/controllers/budgetController.js`

### Expense splitting

- [Friend management](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/friendController.js): `server/controllers/friendController.js`
- [Shared expenses](https://github.com/piyushtanwani/spendwise/blob/main/server/controllers/splitController.js): `server/controllers/splitController.js`

### Other components

- **User**
- **Google Identity**
- **MongoDB**

## Connections

- User → Auth screens: signs in
- Auth screens → Session state: submits credentials (evidence: `client/src/pages/Register.jsx`)
- Session state → Axios API client: calls endpoints (evidence: `client/src/context/AuthContext.jsx`)
- Axios API client → Express app: sends requests
- Express app → Auth routes: mounts routes (evidence: `server/server.js`)
- Auth routes → Authentication: dispatches (evidence: `server/routes/authRoutes.js`)
- Authentication → MongoDB models: reads and writes (evidence: `server/controllers/authController.js`)
- Authentication → SMTP email: sends OTP (evidence: `server/controllers/authController.js`)
- Authentication → Google Identity: verifies credential (evidence: `server/controllers/authController.js`)
- Finance dashboard → Axios API client: fetches summaries (evidence: `client/src/pages/Dashboard.jsx`)
- Transactions screen → Axios API client: manages transactions
- Categories screen → Axios API client: manages categories (evidence: `client/src/pages/Categories.jsx`)
- Budgets screen → Axios API client: manages budgets (evidence: `client/src/pages/Budgets.jsx`)
- Split workspace → Axios API client: uses split endpoints (evidence: `client/src/pages/Split.jsx`)
- Express app → Transactions: routes requests (evidence: `server/server.js`)
- Express app → Categories: routes requests (evidence: `server/server.js`)
- Express app → Budgets: routes requests (evidence: `server/server.js`)
- Express app → Analytics: routes requests (evidence: `server/server.js`)
- Express app → Friend management: routes requests (evidence: `server/server.js`)
- Express app → Shared expenses: routes requests (evidence: `server/server.js`)
- Transactions → MongoDB models: reads and writes (evidence: `server/controllers/transactionController.js`)
- Categories → MongoDB models: reads and writes (evidence: `server/controllers/categoryController.js`)
- Budgets → MongoDB models: reads and writes (evidence: `server/controllers/budgetController.js`)
- Analytics → MongoDB models: queries data
- Friend management → MongoDB models: reads and writes (evidence: `server/controllers/friendController.js`)
- Shared expenses → MongoDB models: reads and writes (evidence: `server/controllers/splitController.js`)
- Friend management → Shared expenses: computes balances (evidence: `server/controllers/friendController.js`)
- Express app → MongoDB: connects (evidence: `server/server.js`)
