# sumit-chame/paisapal-money-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/sumit-chame/paisapal-money-tracker
- Repository: https://github.com/sumit-chame/paisapal-money-tracker

## Overview

PaisaPal is an offline-first personal finance PWA. Users record expenses, income, or transfers, then review daily safe-to-spend guidance, budgets, and spending insights; settings support categories, accounts, data ownership, and optional cloud accounts. The local Dexie database is the main persistence layer, with Zustand coordinating UI state. The README documents goals, subscriptions, expense splitting, voice entry, and backups, but their implementations are not all sampled; those links are therefore limited to documented capabilities rather than inferred call chains. The optional authentication service is separate from local finance data.

Main entry points: [`src/components/AddSheet.tsx`](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddSheet.tsx) (Transaction entry), [`src/lib/db.ts`](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/db.ts) (IndexedDB finance store), [`src/components/AppShell.tsx`](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AppShell.tsx) (App navigation), [`src/lib/auth/api.ts`](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/auth/api.ts) (Authentication API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_shell["App navigation<br/>[AppShell.tsx]"]
  node_home["Home and activity<br/>[HomeScreen.tsx]"]
  node_settings["Settings and backups<br/>[MeScreen.tsx]"]
end

subgraph group_transactions["Money tracking"]
  node_entry["Transaction entry<br/>[AddSheet.tsx]"]
  node_parser["Natural language parser<br/>[parser.ts]"]
  node_currency["Currency conversion<br/>[currency.ts]"]
  node_category_manager["Category management"]
  node_category_editor["Category editor"]
  node_accounts_editor["Account editor"]
  node_friends_editor["Friend editor<br/>[AddFriendModal.tsx]"]
end

subgraph group_planning["Planning and insights"]
  node_budgets["Budgets and subscriptions<br/>[BudgetsScreen.tsx]"]
  node_insights["Spending insights<br/>[InsightsScreen.tsx]"]
  node_budget_stage["Goals and renewals<br/>[BudgetsScreen.tsx]"]
  node_analytics_stage["Trends and money leaks<br/>[InsightsScreen.tsx]"]
  node_safe_calc["Safe-to-spend calculation<br/>[safeToSpend.ts]"]
end

subgraph group_local["Local data and state"]
  node_database[("IndexedDB finance store<br/>[db.ts]")]
  node_app_state["UI and settings state<br/>[index.ts]"]
  node_initialization["Local data initialization<br/>[init.ts]"]
  node_seed_data["Default categories and data<br/>[seeds.ts]"]
end

subgraph group_accounts["Optional accounts"]
  node_auth_ui["Account screens<br/>[AccountScreen.tsx]"]
  node_auth_state["Authentication state<br/>[store.ts]"]
  node_auth_client["Authentication API client<br/>[api.ts]"]
  node_api_login["Login and registration<br/>[login.ts]"]
  node_api_register["Registration endpoint<br/>[register.ts]"]
  node_api_me["Account endpoint<br/>[me.ts]"]
  node_api_logout["Logout endpoint<br/>[logout.ts]"]
  node_auth_helpers["Tokens and password security<br/>[auth.ts]"]
  node_mongo[("Cloud user database<br/>[mongodb.ts]")]
  node_local_auth_store[("Local auth fallback<br/>[localStore.ts]")]
end

node_person(("User"))
node_browser["Browser and local storage"]

node_person -->|"uses"| node_shell
node_shell -->|"shows"| node_home
node_shell -->|"shows"| node_budgets
node_shell -->|"shows"| node_insights
node_shell -->|"shows"| node_settings
node_shell -->|"opens"| node_entry
node_person -->|"records transaction"| node_entry
node_entry -->|"parses text"| node_parser
node_entry -->|"converts amount"| node_currency
node_entry -->|"writes transaction"| node_database
node_entry -->|"opens"| node_category_editor
node_entry -->|"opens"| node_accounts_editor
node_entry -->|"opens"| node_friends_editor
node_home -->|"reads activity"| node_database
node_home -->|"calculates allowance"| node_safe_calc
node_home -->|"opens entry"| node_app_state
node_budgets -->|"reads budgets"| node_database
node_budgets -.->|"tracks goals and renewals"| node_budget_stage
node_insights -->|"reads transactions"| node_database
node_insights -.->|"presents trends"| node_analytics_stage
node_settings -->|"manages local data"| node_database
node_settings -->|"opens"| node_category_manager
node_category_manager -->|"manages categories"| node_database
node_category_manager -->|"opens"| node_category_editor
node_initialization -->|"initializes"| node_database
node_initialization -->|"loads defaults"| node_seed_data
node_app_state -->|"reads and updates settings"| node_database
node_person -->|"manages account"| node_auth_ui
node_auth_ui -->|"requests account actions"| node_auth_state
node_auth_state -->|"calls"| node_auth_client
node_auth_client -.->|"requests login"| node_api_login
node_auth_client -.->|"requests registration"| node_api_register
node_auth_client -.->|"checks account"| node_api_me
node_auth_client -.->|"requests logout"| node_api_logout
node_api_login -->|"verifies credentials"| node_auth_helpers
node_api_register -->|"hashes password"| node_auth_helpers
node_api_me -->|"verifies token"| node_auth_helpers
node_api_logout -->|"clears cookie"| node_auth_helpers
node_api_login -->|"loads user data"| node_mongo
node_api_register -->|"stores user"| node_mongo
node_api_me -->|"reads user"| node_mongo
node_mongo -->|"falls back to"| node_local_auth_store
node_browser -->|"stores offline data"| node_database
node_browser -.->|"offers installable PWA"| node_person

click node_shell "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AppShell.tsx"
click node_home "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/HomeScreen.tsx"
click node_budgets "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/BudgetsScreen.tsx"
click node_insights "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/InsightsScreen.tsx"
click node_settings "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/MeScreen.tsx"
click node_entry "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddSheet.tsx"
click node_parser "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/parser.ts"
click node_currency "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/currency.ts"
click node_category_manager "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/CategoryManagerSheet.tsx"
click node_category_editor "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddCategorySheet.tsx"
click node_accounts_editor "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddAccountModal.tsx"
click node_friends_editor "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddFriendModal.tsx"
click node_budget_stage "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/BudgetsScreen.tsx"
click node_analytics_stage "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/InsightsScreen.tsx"
click node_safe_calc "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/safeToSpend.ts"
click node_database "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/db.ts"
click node_app_state "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/store/index.ts"
click node_initialization "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/init.ts"
click node_seed_data "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/seeds.ts"
click node_auth_ui "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/auth/AccountScreen.tsx"
click node_auth_state "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/auth/store.ts"
click node_auth_client "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/auth/api.ts"
click node_api_login "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/login.ts"
click node_api_register "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/register.ts"
click node_api_me "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/me.ts"
click node_api_logout "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/logout.ts"
click node_auth_helpers "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/_lib/auth.ts"
click node_mongo "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/_lib/mongodb.ts"
click node_local_auth_store "https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/_lib/localStore.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_shell,node_home,node_settings,node_person toneBlue
class node_entry,node_parser,node_currency,node_category_manager,node_category_editor,node_accounts_editor,node_friends_editor,node_browser toneAmber
class node_budgets,node_insights,node_budget_stage,node_analytics_stage,node_safe_calc toneMint
class node_database,node_app_state,node_initialization,node_seed_data toneRose
class node_auth_ui,node_auth_state,node_auth_client,node_api_login,node_api_register,node_api_me,node_api_logout,node_auth_helpers,node_mongo,node_local_auth_store toneIndigo
```

## Components

### App experience

- [App navigation](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AppShell.tsx): `src/components/AppShell.tsx`
- [Home and activity](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/HomeScreen.tsx): `src/screens/HomeScreen.tsx`
- [Settings and backups](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/MeScreen.tsx): `src/screens/MeScreen.tsx`

### Money tracking

- [Transaction entry](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddSheet.tsx): `src/components/AddSheet.tsx`
- [Natural language parser](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/parser.ts): `src/lib/parser.ts`
- [Currency conversion](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/currency.ts): `src/lib/currency.ts`
- [Category management](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/CategoryManagerSheet.tsx): `src/components/CategoryManagerSheet.tsx`
- [Category editor](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddCategorySheet.tsx): `src/components/AddCategorySheet.tsx`
- [Account editor](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddAccountModal.tsx): `src/components/AddAccountModal.tsx`
- [Friend editor](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/components/AddFriendModal.tsx): `src/components/AddFriendModal.tsx`

### Planning and insights

- [Budgets and subscriptions](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/BudgetsScreen.tsx): `src/screens/BudgetsScreen.tsx`
- [Spending insights](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/InsightsScreen.tsx): `src/screens/InsightsScreen.tsx`
- [Goals and renewals](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/BudgetsScreen.tsx): `src/screens/BudgetsScreen.tsx`
- [Trends and money leaks](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/InsightsScreen.tsx): `src/screens/InsightsScreen.tsx`
- [Safe-to-spend calculation](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/safeToSpend.ts): `src/lib/safeToSpend.ts`

### Local data and state

- [IndexedDB finance store](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [UI and settings state](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/store/index.ts): `src/store/index.ts`
- [Local data initialization](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/init.ts): `src/lib/init.ts`
- [Default categories and data](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/seeds.ts): `src/lib/seeds.ts`

### Optional accounts

- [Account screens](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/screens/auth/AccountScreen.tsx): `src/screens/auth/AccountScreen.tsx`
- [Authentication state](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/auth/store.ts): `src/lib/auth/store.ts`
- [Authentication API client](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/src/lib/auth/api.ts): `src/lib/auth/api.ts`
- [Login and registration](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/login.ts): `api/auth/login.ts`
- [Registration endpoint](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/register.ts): `api/auth/register.ts`
- [Account endpoint](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/me.ts): `api/auth/me.ts`
- [Logout endpoint](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/auth/logout.ts): `api/auth/logout.ts`
- [Tokens and password security](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/_lib/auth.ts): `api/_lib/auth.ts`
- [Cloud user database](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/_lib/mongodb.ts): `api/_lib/mongodb.ts`
- [Local auth fallback](https://github.com/sumit-chame/paisapal-money-tracker/blob/main/api/_lib/localStore.ts): `api/_lib/localStore.ts`

### Other components

- **User**
- **Browser and local storage**

## Connections

- User → App navigation: uses (evidence: `src/components/AppShell.tsx`)
- App navigation → Home and activity: shows (evidence: `src/components/AppShell.tsx`)
- App navigation → Budgets and subscriptions: shows (evidence: `src/components/AppShell.tsx`)
- App navigation → Spending insights: shows (evidence: `src/components/AppShell.tsx`)
- App navigation → Settings and backups: shows (evidence: `src/components/AppShell.tsx`)
- App navigation → Transaction entry: opens (evidence: `src/components/AppShell.tsx`)
- User → Transaction entry: records transaction (evidence: `src/components/AddSheet.tsx`)
- Transaction entry → Natural language parser: parses text (evidence: `src/components/AddSheet.tsx`)
- Transaction entry → Currency conversion: converts amount (evidence: `src/components/AddSheet.tsx`)
- Transaction entry → IndexedDB finance store: writes transaction (evidence: `src/components/AddSheet.tsx`)
- Transaction entry → Category editor: opens (evidence: `src/components/AddSheet.tsx`)
- Transaction entry → Account editor: opens (evidence: `src/components/AddSheet.tsx`)
- Transaction entry → Friend editor: opens (evidence: `src/components/AddSheet.tsx`)
- Home and activity → IndexedDB finance store: reads activity (evidence: `src/screens/HomeScreen.tsx`)
- Home and activity → Safe-to-spend calculation: calculates allowance (evidence: `src/screens/HomeScreen.tsx`)
- Home and activity → UI and settings state: opens entry (evidence: `src/screens/HomeScreen.tsx`)
- Budgets and subscriptions → IndexedDB finance store: reads budgets (evidence: `src/screens/BudgetsScreen.tsx`)
- Budgets and subscriptions → Goals and renewals: tracks goals and renewals (evidence: `README.md`)
- Spending insights → IndexedDB finance store: reads transactions (evidence: `src/screens/InsightsScreen.tsx`)
- Spending insights → Trends and money leaks: presents trends (evidence: `README.md`)
- Settings and backups → IndexedDB finance store: manages local data (evidence: `src/screens/MeScreen.tsx`)
- Settings and backups → Category management: opens (evidence: `src/screens/MeScreen.tsx`)
- Category management → IndexedDB finance store: manages categories (evidence: `src/components/CategoryManagerSheet.tsx`)
- Category management → Category editor: opens (evidence: `src/components/CategoryManagerSheet.tsx`)
- Local data initialization → IndexedDB finance store: initializes (evidence: `src/lib/init.ts`)
- Local data initialization → Default categories and data: loads defaults (evidence: `src/lib/init.ts`)
- UI and settings state → IndexedDB finance store: reads and updates settings (evidence: `src/store/index.ts`)
- User → Account screens: manages account
- Account screens → Authentication state: requests account actions (evidence: `src/screens/auth/AccountScreen.tsx`)
- Authentication state → Authentication API client: calls (evidence: `src/lib/auth/store.ts`)
- Authentication API client → Login and registration: requests login (evidence: `README.md`)
- Authentication API client → Registration endpoint: requests registration (evidence: `README.md`)
- Authentication API client → Account endpoint: checks account (evidence: `README.md`)
- Authentication API client → Logout endpoint: requests logout (evidence: `README.md`)
- Login and registration → Tokens and password security: verifies credentials (evidence: `api/auth/login.ts`)
- Registration endpoint → Tokens and password security: hashes password (evidence: `api/auth/register.ts`)
- Account endpoint → Tokens and password security: verifies token (evidence: `api/auth/me.ts`)
- Logout endpoint → Tokens and password security: clears cookie (evidence: `api/auth/logout.ts`)
- Login and registration → Cloud user database: loads user data (evidence: `api/auth/login.ts`)
- Registration endpoint → Cloud user database: stores user (evidence: `api/auth/register.ts`)
- Account endpoint → Cloud user database: reads user (evidence: `api/auth/me.ts`)
- Cloud user database → Local auth fallback: falls back to (evidence: `api/_lib/mongodb.ts`)
- Browser and local storage → IndexedDB finance store: stores offline data (evidence: `README.md`)
- Browser and local storage → User: offers installable PWA (evidence: `README.md`)
