# shivamyadav039/splitsmart architecture

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

- Interactive diagram: https://gitdiagram.com/shivamyadav039/splitsmart
- Repository: https://github.com/shivamyadav039/splitsmart

## Overview

ExpenseSync is a shared-expense management app for groups and trips. Users authenticate, manage groups and memberships, record and split expenses, review balances and settlements, and discuss or audit expenses; a separate CSV wizard scans anomalies and commits resolved rows transactionally. The React pages use a shared API client to reach Express routes, controllers, and domain services backed by PostgreSQL. The README documents product capabilities not all shown in sampled source; edges for those features cite the README, while uncertain implementation links are omitted.

Main entry points: [`server/src/services/csvImport.service.js`](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/csvImport.service.js) (CSV import), [`client/src/pages/GroupDetail.jsx`](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/GroupDetail.jsx) (Group detail), [`server/src/db/pool.js`](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/db/pool.js) (DB pool), [`client/src/pages/Dashboard.jsx`](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/Dashboard.jsx) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web app"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Auth state<br/>[AuthContext.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_groupdetail["Group detail<br/>[GroupDetail.jsx]"]
  node_importui["Import wizard<br/>[ImportCSV.jsx]"]
  node_apiclient["API client<br/>[api.js]"]
  node_auditui["Audit modal"]
  node_expenseui["Expense modal<br/>[ExpenseModal.jsx]"]
  node_settlementui["Settlement modal"]
end

subgraph group_api["API workflows"]
  node_server["Express API<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_grouproutes["Group routes<br/>[groups.routes.js]"]
  node_importroutes["Import routes<br/>[import.routes.js]"]
  node_authcontroller["Auth controller<br/>[auth.controller.js]"]
  node_expensecontroller["Expense controller"]
  node_groupcontroller["Group controller"]
  node_importcontroller["Import controller"]
end

subgraph group_domain["Domain services"]
  node_authservice["Auth service<br/>[auth.service.js]"]
  node_expenseservice["Expense service<br/>[expense.service.js]"]
  node_balanceservice["Balance service<br/>[balance.service.js]"]
  node_groupservice["Group service<br/>[group.service.js]"]
  node_paymentservice["Payment service<br/>[payment.service.js]"]
  node_commentservice["Comment service"]
  node_csvservice["CSV import"]
  node_anomalyservice["Anomaly scanner<br/>[anomaly.service.js]"]
end

subgraph group_data["Persistence"]
  node_pool[("DB pool<br/>[pool.js]")]
  node_transaction["Transaction helper<br/>[transaction.js]"]
end

node_user(("User"))
node_postgres[("PostgreSQL")]
node_google["Google token service"]

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_authui
node_dashboard -->|"requests data"| node_apiclient
node_groupdetail -->|"requests data"| node_apiclient
node_importui -->|"submits import"| node_apiclient
node_dashboard -->|"opens"| node_expenseui
node_dashboard -->|"opens"| node_settlementui
node_dashboard -->|"opens"| node_auditui
node_groupdetail -->|"opens"| node_expenseui
node_groupdetail -->|"opens"| node_settlementui
node_groupdetail -->|"opens"| node_auditui
node_authui -->|"authenticates via"| node_apiclient
node_apiclient -->|"sends REST requests"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_grouproutes
node_server -->|"mounts"| node_importroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_grouproutes -->|"dispatches"| node_groupcontroller
node_grouproutes -->|"dispatches"| node_expensecontroller
node_importroutes -->|"dispatches"| node_importcontroller
node_authcontroller -->|"calls"| node_authservice
node_expensecontroller -->|"calls"| node_expenseservice
node_expensecontroller -->|"calls"| node_balanceservice
node_groupcontroller -->|"calls"| node_groupservice
node_importcontroller -->|"calls"| node_csvservice
node_csvservice -->|"scans rows"| node_anomalyservice
node_csvservice -->|"creates expenses"| node_expenseservice
node_csvservice -->|"creates payments"| node_paymentservice
node_csvservice -->|"updates membership"| node_groupservice
node_csvservice -->|"commits atomically"| node_transaction
node_authservice -->|"queries users"| node_pool
node_expenseservice -->|"queries ledger"| node_pool
node_balanceservice -->|"queries balances"| node_pool
node_groupservice -->|"queries groups"| node_pool
node_anomalyservice -->|"checks rows"| node_pool
node_pool -->|"reads and writes"| node_postgres
node_transaction -.->|"runs transactions"| node_postgres
node_authservice -->|"verifies ID token"| node_google
node_user -.->|"reviews balances"| node_dashboard
node_user -.->|"manages group"| node_groupdetail
node_user -->|"resolves anomalies"| node_importui
node_user -.->|"comments on expenses"| node_groupdetail

click node_app "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/App.jsx"
click node_authui "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/contexts/AuthContext.jsx"
click node_dashboard "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/Dashboard.jsx"
click node_groupdetail "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/GroupDetail.jsx"
click node_importui "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/ImportCSV.jsx"
click node_apiclient "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/services/api.js"
click node_auditui "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/components/AuditTrailModal.jsx"
click node_expenseui "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/components/ExpenseModal.jsx"
click node_settlementui "https://github.com/shivamyadav039/splitsmart/blob/main/client/src/components/SettlementModal.jsx"
click node_server "https://github.com/shivamyadav039/splitsmart/blob/main/server/index.js"
click node_authroutes "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/routes/auth.routes.js"
click node_grouproutes "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/routes/groups.routes.js"
click node_importroutes "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/routes/import.routes.js"
click node_authcontroller "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/auth.controller.js"
click node_expensecontroller "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/expenses.controller.js"
click node_groupcontroller "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/groups.controller.js"
click node_importcontroller "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/import.controller.js"
click node_authservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/auth.service.js"
click node_expenseservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/expense.service.js"
click node_balanceservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/balance.service.js"
click node_groupservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/group.service.js"
click node_paymentservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/payment.service.js"
click node_commentservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/comments.service.js"
click node_csvservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/csvImport.service.js"
click node_anomalyservice "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/anomaly.service.js"
click node_pool "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/db/pool.js"
click node_transaction "https://github.com/shivamyadav039/splitsmart/blob/main/server/src/db/transaction.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_app,node_authui,node_dashboard,node_groupdetail,node_importui,node_apiclient,node_auditui,node_expenseui,node_settlementui,node_user toneBlue
class node_server,node_authroutes,node_grouproutes,node_importroutes,node_authcontroller,node_expensecontroller,node_groupcontroller,node_importcontroller,node_postgres toneAmber
class node_authservice,node_expenseservice,node_balanceservice,node_groupservice,node_paymentservice,node_commentservice,node_csvservice,node_anomalyservice toneMint
class node_pool,node_transaction toneRose
class node_google toneIndigo
```

## Components

### Web app

- [App routing](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth state](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/contexts/AuthContext.jsx): `client/src/contexts/AuthContext.jsx`
- [Dashboard](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/Dashboard.jsx): `client/src/pages/Dashboard.jsx`
- [Group detail](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/GroupDetail.jsx): `client/src/pages/GroupDetail.jsx`
- [Import wizard](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/pages/ImportCSV.jsx): `client/src/pages/ImportCSV.jsx`
- [API client](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [Audit modal](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/components/AuditTrailModal.jsx): `client/src/components/AuditTrailModal.jsx`
- [Expense modal](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/components/ExpenseModal.jsx): `client/src/components/ExpenseModal.jsx`
- [Settlement modal](https://github.com/shivamyadav039/splitsmart/blob/main/client/src/components/SettlementModal.jsx): `client/src/components/SettlementModal.jsx`

### API workflows

- [Express API](https://github.com/shivamyadav039/splitsmart/blob/main/server/index.js): `server/index.js`
- [Auth routes](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/routes/auth.routes.js): `server/src/routes/auth.routes.js`
- [Group routes](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/routes/groups.routes.js): `server/src/routes/groups.routes.js`
- [Import routes](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/routes/import.routes.js): `server/src/routes/import.routes.js`
- [Auth controller](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/auth.controller.js): `server/src/controllers/auth.controller.js`
- [Expense controller](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/expenses.controller.js): `server/src/controllers/expenses.controller.js`
- [Group controller](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/groups.controller.js): `server/src/controllers/groups.controller.js`
- [Import controller](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/controllers/import.controller.js): `server/src/controllers/import.controller.js`

### Domain services

- [Auth service](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/auth.service.js): `server/src/services/auth.service.js`
- [Expense service](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/expense.service.js): `server/src/services/expense.service.js`
- [Balance service](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/balance.service.js): `server/src/services/balance.service.js`
- [Group service](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/group.service.js): `server/src/services/group.service.js`
- [Payment service](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/payment.service.js): `server/src/services/payment.service.js`
- [Comment service](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/comments.service.js): `server/src/services/comments.service.js`
- [CSV import](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/csvImport.service.js): `server/src/services/csvImport.service.js`
- [Anomaly scanner](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/services/anomaly.service.js): `server/src/services/anomaly.service.js`

### Persistence

- [DB pool](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/db/pool.js): `server/src/db/pool.js`
- [Transaction helper](https://github.com/shivamyadav039/splitsmart/blob/main/server/src/db/transaction.js): `server/src/db/transaction.js`

### Other components

- **User**
- **PostgreSQL**
- **Google token service**

## Connections

- User → App routing: uses (evidence: `client/src/App.jsx`)
- App routing → Auth state: provides auth (evidence: `client/src/App.jsx`)
- Dashboard → API client: requests data (evidence: `client/src/pages/Dashboard.jsx`)
- Group detail → API client: requests data (evidence: `client/src/pages/GroupDetail.jsx`)
- Import wizard → API client: submits import (evidence: `client/src/pages/ImportCSV.jsx`)
- Dashboard → Expense modal: opens (evidence: `client/src/pages/Dashboard.jsx`)
- Dashboard → Settlement modal: opens (evidence: `client/src/pages/Dashboard.jsx`)
- Dashboard → Audit modal: opens (evidence: `client/src/pages/Dashboard.jsx`)
- Group detail → Expense modal: opens (evidence: `client/src/pages/GroupDetail.jsx`)
- Group detail → Settlement modal: opens (evidence: `client/src/pages/GroupDetail.jsx`)
- Group detail → Audit modal: opens (evidence: `client/src/pages/GroupDetail.jsx`)
- Auth state → API client: authenticates via (evidence: `client/src/contexts/AuthContext.jsx`)
- API client → Express API: sends REST requests (evidence: `README.md`)
- Express API → Auth routes: mounts (evidence: `server/index.js`)
- Express API → Group routes: mounts (evidence: `server/index.js`)
- Express API → Import routes: mounts (evidence: `server/index.js`)
- Auth routes → Auth controller: dispatches (evidence: `server/src/routes/auth.routes.js`)
- Group routes → Group controller: dispatches (evidence: `server/src/routes/groups.routes.js`)
- Group routes → Expense controller: dispatches (evidence: `server/src/routes/groups.routes.js`)
- Import routes → Import controller: dispatches (evidence: `server/src/routes/import.routes.js`)
- Auth controller → Auth service: calls (evidence: `server/src/controllers/auth.controller.js`)
- Expense controller → Expense service: calls (evidence: `server/src/controllers/expenses.controller.js`)
- Expense controller → Balance service: calls (evidence: `server/src/controllers/expenses.controller.js`)
- Group controller → Group service: calls (evidence: `server/src/controllers/groups.controller.js`)
- Import controller → CSV import: calls (evidence: `server/src/controllers/import.controller.js`)
- CSV import → Anomaly scanner: scans rows (evidence: `server/src/services/csvImport.service.js`)
- CSV import → Expense service: creates expenses (evidence: `server/src/services/csvImport.service.js`)
- CSV import → Payment service: creates payments (evidence: `server/src/services/csvImport.service.js`)
- CSV import → Group service: updates membership (evidence: `server/src/services/csvImport.service.js`)
- CSV import → Transaction helper: commits atomically (evidence: `server/src/services/csvImport.service.js`)
- Auth service → DB pool: queries users (evidence: `server/src/services/auth.service.js`)
- Expense service → DB pool: queries ledger (evidence: `server/src/services/expense.service.js`)
- Balance service → DB pool: queries balances (evidence: `server/src/services/balance.service.js`)
- Group service → DB pool: queries groups (evidence: `server/src/services/group.service.js`)
- Anomaly scanner → DB pool: checks rows (evidence: `server/src/services/anomaly.service.js`)
- DB pool → PostgreSQL: reads and writes (evidence: `server/src/db/pool.js`)
- Transaction helper → PostgreSQL: runs transactions
- Auth service → Google token service: verifies ID token (evidence: `server/src/services/auth.service.js`)
- User → Dashboard: reviews balances (evidence: `README.md`)
- User → Group detail: manages group (evidence: `README.md`)
- User → Import wizard: resolves anomalies (evidence: `README.md`)
- User → Group detail: comments on expenses (evidence: `README.md`)
