# harshpathak11/splitwise architecture

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

- Interactive diagram: https://gitdiagram.com/harshpathak11/splitwise
- Repository: https://github.com/harshpathak11/splitwise

## Overview

FairFare is a social expense-splitting app for friends and groups. A user enters through the React application, uses friend, trip, and expense features, and the backend handles authenticated requests against MongoDB-backed domain data; users then review balances, history, and analytics. The backend also provides AI assistance and expense categorization, financial snapshots, and notifications. The graph includes documented product capabilities whose implementations were not sampled, but omits unverified links to them; some frontend-to-backend wiring is likewise not shown in the excerpts.

Main entry points: [`frontend/src/App.jsx`](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/App.jsx) (React application), [`backend/controllers/user.js`](https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/user.js) (User and friend logic), [`backend/index.js`](https://github.com/harshpathak11/splitwise/blob/main/backend/index.js) (Express server), [`backend/models/schema.js`](https://github.com/harshpathak11/splitwise/blob/main/backend/models/schema.js) (Domain records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["React application<br/>[App.jsx]"]
  node_expenseui["Expense workflows"]
  node_groupui["Trips and groups<br/>[tripDetails.jsx]"]
  node_friendui["Friend management<br/>[addFriend.jsx]"]
  node_historyui["Transaction history"]
  node_analyticsui["Spending analytics<br/>[Analytics.jsx]"]
  node_apiclient["API client<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_server["Express server<br/>[index.js]"]
  node_useroutes["User routes<br/>[user.js]"]
  node_grouproutes["Group routes<br/>[group.js]"]
  node_expenseroutes["Expense routes<br/>[expense.js]"]
  node_airoutes["AI routes<br/>[ai.js]"]
  node_auth["JWT authentication<br/>[auth.js]"]
end

subgraph group_domain["Expense domain"]
  node_userctl["User and friend logic<br/>[user.js]"]
  node_groupctl["Group expense logic<br/>[groups.js]"]
  node_expensectl["Expense endpoints<br/>[expenses.js]"]
  node_models[("Domain records<br/>[schema.js]")]
end

subgraph group_insights["Insights and AI"]
  node_snapshots["Financial snapshots<br/>[snapshots.js]"]
  node_aictl["FAIR AI assistant<br/>[ai.js]"]
  node_categorizer["Expense categorizer"]
  node_worker["AI categorization worker"]
end

subgraph group_integrations["External services"]
  node_gemini["Gemini AI"]
  node_notify["Notification service"]
  node_firebase["Firebase messaging"]
  node_mail["Mail service"]
  node_cloudinary["Cloudinary media"]
end

node_user(("FairFare user"))

node_user -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_expenseui
node_webapp -->|"routes to"| node_groupui
node_webapp -->|"routes to"| node_friendui
node_webapp -->|"routes to"| node_historyui
node_webapp -->|"routes to"| node_analyticsui
node_historyui -->|"requests data"| node_apiclient
node_server -->|"mounts"| node_useroutes
node_server -->|"mounts"| node_grouproutes
node_server -->|"mounts"| node_expenseroutes
node_server -->|"mounts"| node_airoutes
node_useroutes -->|"guards routes"| node_auth
node_grouproutes -->|"guards routes"| node_auth
node_expenseroutes -->|"guards routes"| node_auth
node_airoutes -->|"guards routes"| node_auth
node_useroutes -->|"dispatches"| node_userctl
node_useroutes -->|"dispatches"| node_aictl
node_grouproutes -->|"dispatches"| node_groupctl
node_expenseroutes -->|"dispatches"| node_expensectl
node_airoutes -->|"dispatches"| node_aictl
node_userctl -->|"reads and writes"| node_models
node_groupctl -->|"reads and writes"| node_models
node_expensectl -.->|"reads and writes"| node_models
node_aictl -->|"reads context"| node_models
node_userctl -->|"updates snapshots"| node_snapshots
node_groupctl -->|"updates snapshots"| node_snapshots
node_server -->|"starts"| node_categorizer
node_categorizer -->|"delegates"| node_worker
node_categorizer -->|"reads and writes"| node_models
node_worker -->|"reads and writes"| node_models
node_worker -->|"categorizes with"| node_gemini
node_aictl -->|"answers with"| node_gemini
node_userctl -->|"sends alerts"| node_notify
node_groupctl -->|"sends alerts"| node_notify
node_notify -->|"sends push"| node_firebase
node_userctl -->|"sends email"| node_mail
node_userctl -.->|"uploads photos"| node_cloudinary

click node_webapp "https://github.com/harshpathak11/splitwise/blob/main/frontend/src/App.jsx"
click node_expenseui "https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/PersonalExpense.jsx"
click node_groupui "https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/tripDetails.jsx"
click node_friendui "https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/addFriend.jsx"
click node_historyui "https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/TransactionHistory.jsx"
click node_analyticsui "https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/Analytics.jsx"
click node_apiclient "https://github.com/harshpathak11/splitwise/blob/main/frontend/src/utils/api.js"
click node_server "https://github.com/harshpathak11/splitwise/blob/main/backend/index.js"
click node_useroutes "https://github.com/harshpathak11/splitwise/blob/main/backend/routes/user.js"
click node_grouproutes "https://github.com/harshpathak11/splitwise/blob/main/backend/routes/group.js"
click node_expenseroutes "https://github.com/harshpathak11/splitwise/blob/main/backend/routes/expense.js"
click node_airoutes "https://github.com/harshpathak11/splitwise/blob/main/backend/routes/ai.js"
click node_auth "https://github.com/harshpathak11/splitwise/blob/main/backend/middleware/auth.js"
click node_userctl "https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/user.js"
click node_groupctl "https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/groups.js"
click node_expensectl "https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/expenses.js"
click node_models "https://github.com/harshpathak11/splitwise/blob/main/backend/models/schema.js"
click node_snapshots "https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/snapshots.js"
click node_aictl "https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/ai.js"
click node_categorizer "https://github.com/harshpathak11/splitwise/blob/main/backend/service/expenseCategorizer.js"
click node_worker "https://github.com/harshpathak11/splitwise/blob/main/backend/service/categorizerWorker.js"
click node_notify "https://github.com/harshpathak11/splitwise/blob/main/backend/service/notificationService.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_webapp,node_expenseui,node_groupui,node_friendui,node_historyui,node_analyticsui,node_apiclient,node_user toneBlue
class node_server,node_useroutes,node_grouproutes,node_expenseroutes,node_airoutes,node_auth toneAmber
class node_userctl,node_groupctl,node_expensectl,node_models toneMint
class node_snapshots,node_aictl,node_categorizer,node_worker toneRose
class node_gemini,node_notify,node_firebase,node_mail,node_cloudinary toneIndigo
```

## Components

### Web client

- [React application](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Expense workflows](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/PersonalExpense.jsx): `frontend/src/components/PersonalExpense.jsx`
- [Trips and groups](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/tripDetails.jsx): `frontend/src/components/tripDetails.jsx`
- [Friend management](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/addFriend.jsx): `frontend/src/components/addFriend.jsx`
- [Transaction history](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/TransactionHistory.jsx): `frontend/src/components/TransactionHistory.jsx`
- [Spending analytics](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/components/Analytics.jsx): `frontend/src/components/Analytics.jsx`
- [API client](https://github.com/harshpathak11/splitwise/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`

### Backend API

- [Express server](https://github.com/harshpathak11/splitwise/blob/main/backend/index.js): `backend/index.js`
- [User routes](https://github.com/harshpathak11/splitwise/blob/main/backend/routes/user.js): `backend/routes/user.js`
- [Group routes](https://github.com/harshpathak11/splitwise/blob/main/backend/routes/group.js): `backend/routes/group.js`
- [Expense routes](https://github.com/harshpathak11/splitwise/blob/main/backend/routes/expense.js): `backend/routes/expense.js`
- [AI routes](https://github.com/harshpathak11/splitwise/blob/main/backend/routes/ai.js): `backend/routes/ai.js`
- [JWT authentication](https://github.com/harshpathak11/splitwise/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`

### Expense domain

- [User and friend logic](https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/user.js): `backend/controllers/user.js`
- [Group expense logic](https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/groups.js): `backend/controllers/groups.js`
- [Expense endpoints](https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/expenses.js): `backend/controllers/expenses.js`
- [Domain records](https://github.com/harshpathak11/splitwise/blob/main/backend/models/schema.js): `backend/models/schema.js`

### Insights and AI

- [Financial snapshots](https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/snapshots.js): `backend/controllers/snapshots.js`
- [FAIR AI assistant](https://github.com/harshpathak11/splitwise/blob/main/backend/controllers/ai.js): `backend/controllers/ai.js`
- [Expense categorizer](https://github.com/harshpathak11/splitwise/blob/main/backend/service/expenseCategorizer.js): `backend/service/expenseCategorizer.js`
- [AI categorization worker](https://github.com/harshpathak11/splitwise/blob/main/backend/service/categorizerWorker.js): `backend/service/categorizerWorker.js`

### External services

- **Gemini AI**
- [Notification service](https://github.com/harshpathak11/splitwise/blob/main/backend/service/notificationService.js): `backend/service/notificationService.js`
- **Firebase messaging**
- **Mail service**
- **Cloudinary media**

### Other components

- **FairFare user**

## Connections

- FairFare user → React application: uses (evidence: `README.md`)
- React application → Expense workflows: routes to (evidence: `frontend/src/App.jsx`)
- React application → Trips and groups: routes to (evidence: `frontend/src/App.jsx`)
- React application → Friend management: routes to (evidence: `frontend/src/App.jsx`)
- React application → Transaction history: routes to (evidence: `frontend/src/App.jsx`)
- React application → Spending analytics: routes to (evidence: `frontend/src/App.jsx`)
- Transaction history → API client: requests data (evidence: `frontend/src/components/TransactionHistory.jsx`)
- Express server → User routes: mounts (evidence: `backend/index.js`)
- Express server → Group routes: mounts (evidence: `backend/index.js`)
- Express server → Expense routes: mounts (evidence: `backend/index.js`)
- Express server → AI routes: mounts (evidence: `backend/index.js`)
- User routes → JWT authentication: guards routes (evidence: `backend/routes/user.js`)
- Group routes → JWT authentication: guards routes (evidence: `backend/routes/group.js`)
- Expense routes → JWT authentication: guards routes (evidence: `backend/routes/expense.js`)
- AI routes → JWT authentication: guards routes (evidence: `backend/routes/ai.js`)
- User routes → User and friend logic: dispatches (evidence: `backend/routes/user.js`)
- User routes → FAIR AI assistant: dispatches (evidence: `backend/routes/user.js`)
- Group routes → Group expense logic: dispatches (evidence: `backend/routes/group.js`)
- Expense routes → Expense endpoints: dispatches (evidence: `backend/routes/expense.js`)
- AI routes → FAIR AI assistant: dispatches (evidence: `backend/routes/ai.js`)
- User and friend logic → Domain records: reads and writes (evidence: `backend/controllers/user.js`)
- Group expense logic → Domain records: reads and writes (evidence: `backend/controllers/groups.js`)
- Expense endpoints → Domain records: reads and writes
- FAIR AI assistant → Domain records: reads context (evidence: `backend/controllers/ai.js`)
- User and friend logic → Financial snapshots: updates snapshots (evidence: `backend/controllers/user.js`)
- Group expense logic → Financial snapshots: updates snapshots (evidence: `backend/controllers/groups.js`)
- Express server → Expense categorizer: starts (evidence: `backend/index.js`)
- Expense categorizer → AI categorization worker: delegates (evidence: `backend/service/expenseCategorizer.js`)
- Expense categorizer → Domain records: reads and writes (evidence: `backend/service/expenseCategorizer.js`)
- AI categorization worker → Domain records: reads and writes (evidence: `backend/service/categorizerWorker.js`)
- AI categorization worker → Gemini AI: categorizes with (evidence: `backend/service/categorizerWorker.js`)
- FAIR AI assistant → Gemini AI: answers with (evidence: `backend/controllers/ai.js`)
- User and friend logic → Notification service: sends alerts (evidence: `backend/controllers/user.js`)
- Group expense logic → Notification service: sends alerts (evidence: `backend/controllers/groups.js`)
- Notification service → Firebase messaging: sends push (evidence: `backend/service/notificationService.js`)
- User and friend logic → Mail service: sends email (evidence: `backend/controllers/user.js`)
- User and friend logic → Cloudinary media: uploads photos
