# vj-ashwin/the_good_treasurer architecture

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

- Interactive diagram: https://gitdiagram.com/vj-ashwin/the_good_treasurer
- Repository: https://github.com/vj-ashwin/the_good_treasurer

## Overview

The tree and sampled code describe a trip-based expense-sharing app: a signed-in user creates or selects a trip, manages people and expenses, then reviews history or reports. The README instead describes an earlier personal-ledger feature set, so the map follows the richer trip workflow evidenced by the source index and excerpts. Firestore provides persistence and live subscriptions; the money layer handles paise, taxes, splits, balances, settlements, and reports. Some panel and storage internals were not excerpted, so their connections are limited to visible imports and documented capabilities.

Main entry points: [`src/pages/TripDetailPage.tsx`](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/pages/TripDetailPage.tsx) (Trip detail), [`src/App.tsx`](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/App.tsx) (App routing), [`src/components/ReportPanel.tsx`](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/ReportPanel.tsx) (Reporting), [`src/lib/money/index.ts`](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/index.ts) (Money calculations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and navigation"]
  node_app["App routing<br/>[App.tsx]"]
  node_signin["Sign-in page<br/>[SignInPage.tsx]"]
  node_auth["Auth state<br/>[useAuth.ts]"]
end

subgraph group_trip["Trip workspace"]
  node_triplist["Trip list<br/>[TripListPage.tsx]"]
  node_shell["Workspace shell<br/>[AppShell.tsx]"]
  node_create["Trip creation"]
  node_detail["Trip detail<br/>[TripDetailPage.tsx]"]
  node_people["People management<br/>[PeoplePanel.tsx]"]
  node_expenses["Expense ledger<br/>[ExpensesPanel.tsx]"]
  node_history["Trip history<br/>[HistoryPanel.tsx]"]
end

subgraph group_data["Firestore data"]
  node_hooks["Trip data hooks<br/>[useTrips.ts]"]
  node_tripdata["Trip and people storage<br/>[trips.ts]"]
  node_peopledb["People storage<br/>[people.ts]"]
  node_expensedb["Expense and history storage<br/>[expenses.ts]"]
  node_firestore[("Firestore database<br/>[firebase.ts]")]
end

subgraph group_money["Expense calculations"]
  node_input["Expense input parsing<br/>[expenseInput.ts]"]
  node_money["Money calculations<br/>[index.ts]"]
  node_paise["Paise and formatting<br/>[paise.ts]"]
  node_split["Splits and tax<br/>[split.ts]"]
  node_tax["Tax calculation<br/>[tax.ts]"]
end

subgraph group_exports["Reports and exports"]
  node_reports["Reporting<br/>[ReportPanel.tsx]"]
  node_backup["Data backup<br/>[backup.ts]"]
  node_pdf["PDF report export<br/>[reportPdf.tsx]"]
  node_png["PNG report export<br/>[reportPng.ts]"]
end

node_user(("Treasurer"))
node_google{{"Google sign-in"}}
node_firebase{{"Firebase services"}}

node_user -->|"uses"| node_app
node_app -->|"checks sign-in"| node_auth
node_app -->|"routes to"| node_signin
node_app -->|"routes to"| node_triplist
node_app -->|"routes to"| node_detail
node_signin -->|"signs in"| node_auth
node_auth -->|"authenticates with"| node_google
node_auth -->|"tracks session"| node_firebase
node_triplist -->|"renders"| node_shell
node_shell -->|"loads trips"| node_hooks
node_shell -->|"opens"| node_create
node_create -->|"creates trips"| node_tripdata
node_detail -->|"renders"| node_shell
node_detail -->|"shows people"| node_people
node_detail -->|"shows expenses"| node_expenses
node_detail -->|"shows history"| node_history
node_detail -->|"shows reports"| node_reports
node_hooks -.->|"watches trips"| node_tripdata
node_hooks -.->|"uses database"| node_firestore
node_people -.->|"manages people"| node_peopledb
node_expenses -->|"writes expenses"| node_expensedb
node_expenses -->|"parses entries"| node_input
node_expenses -->|"uses calculations"| node_money
node_history -.->|"loads history"| node_expensedb
node_reports -->|"exports backup"| node_backup
node_reports -->|"exports PDF"| node_pdf
node_reports -->|"exports image"| node_png
node_reports -->|"builds summaries"| node_money
node_money -->|"exports helpers"| node_paise
node_money -->|"exports helpers"| node_split
node_money -->|"exports helpers"| node_tax
node_firestore -.->|"connects to"| node_firebase

click node_app "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/App.tsx"
click node_signin "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/pages/SignInPage.tsx"
click node_auth "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/hooks/useAuth.ts"
click node_triplist "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/pages/TripListPage.tsx"
click node_shell "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/AppShell.tsx"
click node_create "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/CreateTripDialog.tsx"
click node_detail "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/pages/TripDetailPage.tsx"
click node_people "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/PeoplePanel.tsx"
click node_expenses "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/ExpensesPanel.tsx"
click node_history "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/HistoryPanel.tsx"
click node_reports "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/ReportPanel.tsx"
click node_hooks "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/hooks/useTrips.ts"
click node_tripdata "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firestore/trips.ts"
click node_peopledb "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firestore/people.ts"
click node_expensedb "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firestore/expenses.ts"
click node_firestore "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firebase.ts"
click node_input "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/expenseInput.ts"
click node_money "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/index.ts"
click node_paise "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/paise.ts"
click node_split "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/split.ts"
click node_tax "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/tax.ts"
click node_backup "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/export/backup.ts"
click node_pdf "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/export/reportPdf.tsx"
click node_png "https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/export/reportPng.ts"

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_signin,node_auth toneBlue
class node_triplist,node_shell,node_create,node_detail,node_people,node_expenses,node_history toneAmber
class node_hooks,node_tripdata,node_peopledb,node_expensedb,node_firestore toneMint
class node_input,node_money,node_paise,node_split,node_tax toneRose
class node_reports,node_backup,node_pdf,node_png,node_user,node_google,node_firebase toneIndigo
```

## Components

### App and navigation

- [App routing](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in page](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/pages/SignInPage.tsx): `src/pages/SignInPage.tsx`
- [Auth state](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/hooks/useAuth.ts): `src/hooks/useAuth.ts`

### Trip workspace

- [Trip list](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/pages/TripListPage.tsx): `src/pages/TripListPage.tsx`
- [Workspace shell](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/AppShell.tsx): `src/components/AppShell.tsx`
- [Trip creation](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/CreateTripDialog.tsx): `src/components/CreateTripDialog.tsx`
- [Trip detail](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/pages/TripDetailPage.tsx): `src/pages/TripDetailPage.tsx`
- [People management](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/PeoplePanel.tsx): `src/components/PeoplePanel.tsx`
- [Expense ledger](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/ExpensesPanel.tsx): `src/components/ExpensesPanel.tsx`
- [Trip history](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/HistoryPanel.tsx): `src/components/HistoryPanel.tsx`

### Firestore data

- [Trip data hooks](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/hooks/useTrips.ts): `src/hooks/useTrips.ts`
- [Trip and people storage](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firestore/trips.ts): `src/lib/firestore/trips.ts`
- [People storage](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firestore/people.ts): `src/lib/firestore/people.ts`
- [Expense and history storage](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firestore/expenses.ts): `src/lib/firestore/expenses.ts`
- [Firestore database](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`

### Expense calculations

- [Expense input parsing](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/expenseInput.ts): `src/lib/expenseInput.ts`
- [Money calculations](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/index.ts): `src/lib/money/index.ts`
- [Paise and formatting](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/paise.ts): `src/lib/money/paise.ts`
- [Splits and tax](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/split.ts): `src/lib/money/split.ts`
- [Tax calculation](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/money/tax.ts): `src/lib/money/tax.ts`

### Reports and exports

- [Reporting](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/components/ReportPanel.tsx): `src/components/ReportPanel.tsx`
- [Data backup](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/export/backup.ts): `src/lib/export/backup.ts`
- [PDF report export](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/export/reportPdf.tsx): `src/lib/export/reportPdf.tsx`
- [PNG report export](https://github.com/vj-ashwin/the_good_treasurer/blob/main/src/lib/export/reportPng.ts): `src/lib/export/reportPng.ts`

### Other components

- **Treasurer**
- **Google sign-in**
- **Firebase services**

## Connections

- Treasurer → App routing: uses (evidence: `src/App.tsx`)
- App routing → Auth state: checks sign-in (evidence: `src/App.tsx`)
- App routing → Sign-in page: routes to (evidence: `src/App.tsx`)
- App routing → Trip list: routes to (evidence: `src/App.tsx`)
- App routing → Trip detail: routes to (evidence: `src/App.tsx`)
- Sign-in page → Auth state: signs in (evidence: `src/pages/SignInPage.tsx`)
- Auth state → Google sign-in: authenticates with (evidence: `src/hooks/useAuth.ts`)
- Auth state → Firebase services: tracks session (evidence: `src/hooks/useAuth.ts`)
- Trip list → Workspace shell: renders (evidence: `src/pages/TripListPage.tsx`)
- Workspace shell → Trip data hooks: loads trips (evidence: `src/components/AppShell.tsx`)
- Workspace shell → Trip creation: opens (evidence: `src/components/AppShell.tsx`)
- Trip creation → Trip and people storage: creates trips (evidence: `src/components/CreateTripDialog.tsx`)
- Trip detail → Workspace shell: renders (evidence: `src/pages/TripDetailPage.tsx`)
- Trip detail → People management: shows people (evidence: `src/pages/TripDetailPage.tsx`)
- Trip detail → Expense ledger: shows expenses (evidence: `src/pages/TripDetailPage.tsx`)
- Trip detail → Trip history: shows history (evidence: `src/pages/TripDetailPage.tsx`)
- Trip detail → Reporting: shows reports (evidence: `src/pages/TripDetailPage.tsx`)
- Trip data hooks → Trip and people storage: watches trips
- Trip data hooks → Firestore database: uses database (evidence: `src/hooks/useTrips.ts`)
- People management → People storage: manages people
- Expense ledger → Expense and history storage: writes expenses (evidence: `src/components/ExpensesPanel.tsx`)
- Expense ledger → Expense input parsing: parses entries (evidence: `src/components/ExpensesPanel.tsx`)
- Expense ledger → Money calculations: uses calculations (evidence: `src/components/ExpensesPanel.tsx`)
- Trip history → Expense and history storage: loads history
- Reporting → Data backup: exports backup (evidence: `src/components/ReportPanel.tsx`)
- Reporting → PDF report export: exports PDF (evidence: `src/components/ReportPanel.tsx`)
- Reporting → PNG report export: exports image (evidence: `src/components/ReportPanel.tsx`)
- Reporting → Money calculations: builds summaries (evidence: `src/components/ReportPanel.tsx`)
- Money calculations → Paise and formatting: exports helpers (evidence: `src/lib/money/index.ts`)
- Money calculations → Splits and tax: exports helpers (evidence: `src/lib/money/index.ts`)
- Money calculations → Tax calculation: exports helpers (evidence: `src/lib/money/index.ts`)
- Firestore database → Firebase services: connects to
