# cpmacatangay/expense architecture

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

- Interactive diagram: https://gitdiagram.com/cpmacatangay/expense
- Repository: https://github.com/cpmacatangay/expense

## Overview

Salo is a shared group-meal ledger delivered as a PWA; the Android app is explicitly archived. Members sign in, join or create a group, record an outing with attendance and item shares, then the owner finalizes it. Finalization writes shares and activity; the shared ledger derives balances and transfers, while members record and confirm settlements. History, activity, exports, recaps, and payment QR images are supporting capabilities. Edges use excerpts or README statements as evidence; several feature implementations were not sampled, so some documented links remain dashed.

Main entry points: [`src/app/App.tsx`](https://github.com/cpmacatangay/expense/blob/main/src/app/App.tsx) (PWA routes), [`src/features/outings/OutingEditorPage.tsx`](https://github.com/cpmacatangay/expense/blob/main/src/features/outings/OutingEditorPage.tsx) (Outing editor), [`src/data/supabase/client.ts`](https://github.com/cpmacatangay/expense/blob/main/src/data/supabase/client.ts) (Supabase services), [`supabase/functions/finalize-outing/index.ts`](https://github.com/cpmacatangay/expense/blob/main/supabase/functions/finalize-outing/index.ts) (Outing finalization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App and identity"]
  node_app["PWA routes<br/>[App.tsx]"]
  node_auth["Authentication<br/>[authContext.ts]"]
end

subgraph group_groups["Groups and outings"]
  node_group["Group management<br/>[SettingsPage.tsx]"]
  node_outing["Outing editor"]
  node_outingapi["Outing data<br/>[api.ts]"]
  node_finalize["Outing finalization<br/>[index.ts]"]
end

subgraph group_money["Money and settlement"]
  node_shares["Share calculation<br/>[computeShares.ts]"]
  node_moneyrules["Money rules<br/>[validate.ts]"]
  node_ledgerpage["Ledger view<br/>[LedgerPage.tsx]"]
  node_ledgerdata["Ledger loading<br/>[useLedger.ts]"]
  node_ledgercalc["Balance calculation<br/>[computeLedger.ts]"]
  node_settlements["Settlement operations<br/>[api.ts]"]
end

subgraph group_insights["History and sharing"]
  node_activity["Activity feed<br/>[ActivityPage.tsx]"]
  node_history["Filtered history<br/>[HistoryPage.tsx]"]
  node_exports["Group exports<br/>[load.ts]"]
  node_recap["Meal recaps<br/>[RecapPanel.tsx]"]
  node_paymentqr["Payment QR<br/>[qr.ts]"]
end

subgraph group_platform["Platform and services"]
  node_shell["Platform shells<br/>[PlatformShell.tsx]"]
  node_supabase[("Supabase services<br/>[client.ts]")]
  node_edge["Supabase Edge Function<br/>[index.ts]"]
end

node_member(("Group member"))

node_member -->|"uses"| node_app
node_app -->|"gates routes"| node_auth
node_app -->|"routes to"| node_group
node_app -->|"routes to"| node_outing
node_app -->|"wraps pages"| node_shell
node_member -.->|"creates or joins"| node_group
node_member -.->|"records meal"| node_outing
node_outing -->|"reads and writes"| node_outingapi
node_outing -->|"previews shares"| node_shares
node_outing -.->|"requests finalization"| node_finalize
node_finalize -->|"computes shares"| node_shares
node_finalize -.->|"writes finalized data"| node_supabase
node_ledgerpage -->|"loads ledger"| node_ledgerdata
node_ledgerdata -->|"loads records"| node_supabase
node_ledgerdata -->|"computes balances"| node_ledgercalc
node_ledgerpage -->|"records decisions"| node_settlements
node_settlements -->|"persists settlements"| node_supabase
node_member -.->|"reviews changes"| node_activity
node_member -.->|"filters outings"| node_history
node_member -.->|"exports records"| node_exports
node_member -.->|"shares recap"| node_recap
node_member -.->|"views payment QR"| node_paymentqr
node_auth -->|"authenticates"| node_supabase
node_member -.->|"chooses platform"| node_shell

click node_app "https://github.com/cpmacatangay/expense/blob/main/src/app/App.tsx"
click node_auth "https://github.com/cpmacatangay/expense/blob/main/src/features/auth/authContext.ts"
click node_group "https://github.com/cpmacatangay/expense/blob/main/src/features/groups/SettingsPage.tsx"
click node_outing "https://github.com/cpmacatangay/expense/blob/main/src/features/outings/OutingEditorPage.tsx"
click node_outingapi "https://github.com/cpmacatangay/expense/blob/main/src/features/outings/api.ts"
click node_finalize "https://github.com/cpmacatangay/expense/blob/main/supabase/functions/finalize-outing/index.ts"
click node_shares "https://github.com/cpmacatangay/expense/blob/main/src/domain/money/computeShares.ts"
click node_moneyrules "https://github.com/cpmacatangay/expense/blob/main/src/domain/money/validate.ts"
click node_ledgerpage "https://github.com/cpmacatangay/expense/blob/main/src/pages/LedgerPage.tsx"
click node_ledgerdata "https://github.com/cpmacatangay/expense/blob/main/src/features/ledger/useLedger.ts"
click node_ledgercalc "https://github.com/cpmacatangay/expense/blob/main/src/domain/ledger/computeLedger.ts"
click node_settlements "https://github.com/cpmacatangay/expense/blob/main/src/features/ledger/api.ts"
click node_activity "https://github.com/cpmacatangay/expense/blob/main/src/pages/ActivityPage.tsx"
click node_history "https://github.com/cpmacatangay/expense/blob/main/src/pages/HistoryPage.tsx"
click node_exports "https://github.com/cpmacatangay/expense/blob/main/src/features/export/load.ts"
click node_recap "https://github.com/cpmacatangay/expense/blob/main/src/features/recap/RecapPanel.tsx"
click node_paymentqr "https://github.com/cpmacatangay/expense/blob/main/src/features/payments/qr.ts"
click node_shell "https://github.com/cpmacatangay/expense/blob/main/src/platform/PlatformShell.tsx"
click node_supabase "https://github.com/cpmacatangay/expense/blob/main/src/data/supabase/client.ts"
click node_edge "https://github.com/cpmacatangay/expense/blob/main/supabase/functions/finalize-outing/index.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_auth toneBlue
class node_group,node_outing,node_outingapi,node_finalize toneAmber
class node_shares,node_moneyrules,node_ledgerpage,node_ledgerdata,node_ledgercalc,node_settlements toneMint
class node_activity,node_history,node_exports,node_recap,node_paymentqr toneRose
class node_shell,node_supabase,node_edge,node_member toneIndigo
```

## Components

### App and identity

- [PWA routes](https://github.com/cpmacatangay/expense/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Authentication](https://github.com/cpmacatangay/expense/blob/main/src/features/auth/authContext.ts): `src/features/auth/authContext.ts`

### Groups and outings

- [Group management](https://github.com/cpmacatangay/expense/blob/main/src/features/groups/SettingsPage.tsx): `src/features/groups/SettingsPage.tsx`
- [Outing editor](https://github.com/cpmacatangay/expense/blob/main/src/features/outings/OutingEditorPage.tsx): `src/features/outings/OutingEditorPage.tsx`
- [Outing data](https://github.com/cpmacatangay/expense/blob/main/src/features/outings/api.ts): `src/features/outings/api.ts`
- [Outing finalization](https://github.com/cpmacatangay/expense/blob/main/supabase/functions/finalize-outing/index.ts): `supabase/functions/finalize-outing/index.ts`

### Money and settlement

- [Share calculation](https://github.com/cpmacatangay/expense/blob/main/src/domain/money/computeShares.ts): `src/domain/money/computeShares.ts`
- [Money rules](https://github.com/cpmacatangay/expense/blob/main/src/domain/money/validate.ts): `src/domain/money/validate.ts`
- [Ledger view](https://github.com/cpmacatangay/expense/blob/main/src/pages/LedgerPage.tsx): `src/pages/LedgerPage.tsx`
- [Ledger loading](https://github.com/cpmacatangay/expense/blob/main/src/features/ledger/useLedger.ts): `src/features/ledger/useLedger.ts`
- [Balance calculation](https://github.com/cpmacatangay/expense/blob/main/src/domain/ledger/computeLedger.ts): `src/domain/ledger/computeLedger.ts`
- [Settlement operations](https://github.com/cpmacatangay/expense/blob/main/src/features/ledger/api.ts): `src/features/ledger/api.ts`

### History and sharing

- [Activity feed](https://github.com/cpmacatangay/expense/blob/main/src/pages/ActivityPage.tsx): `src/pages/ActivityPage.tsx`
- [Filtered history](https://github.com/cpmacatangay/expense/blob/main/src/pages/HistoryPage.tsx): `src/pages/HistoryPage.tsx`
- [Group exports](https://github.com/cpmacatangay/expense/blob/main/src/features/export/load.ts): `src/features/export/load.ts`
- [Meal recaps](https://github.com/cpmacatangay/expense/blob/main/src/features/recap/RecapPanel.tsx): `src/features/recap/RecapPanel.tsx`
- [Payment QR](https://github.com/cpmacatangay/expense/blob/main/src/features/payments/qr.ts): `src/features/payments/qr.ts`

### Platform and services

- [Platform shells](https://github.com/cpmacatangay/expense/blob/main/src/platform/PlatformShell.tsx): `src/platform/PlatformShell.tsx`
- [Supabase services](https://github.com/cpmacatangay/expense/blob/main/src/data/supabase/client.ts): `src/data/supabase/client.ts`
- [Supabase Edge Function](https://github.com/cpmacatangay/expense/blob/main/supabase/functions/finalize-outing/index.ts): `supabase/functions/finalize-outing/index.ts`

### Other components

- **Group member**

## Connections

- Group member → PWA routes: uses (evidence: `README.md`)
- PWA routes → Authentication: gates routes (evidence: `src/app/App.tsx`)
- PWA routes → Group management: routes to (evidence: `src/app/App.tsx`)
- PWA routes → Outing editor: routes to (evidence: `src/app/App.tsx`)
- PWA routes → Platform shells: wraps pages (evidence: `src/app/App.tsx`)
- Group member → Group management: creates or joins (evidence: `README.md`)
- Group member → Outing editor: records meal (evidence: `README.md`)
- Outing editor → Outing data: reads and writes (evidence: `src/features/outings/OutingEditorPage.tsx`)
- Outing editor → Share calculation: previews shares (evidence: `src/features/outings/OutingEditorPage.tsx`)
- Outing editor → Outing finalization: requests finalization (evidence: `README.md`)
- Outing finalization → Share calculation: computes shares (evidence: `supabase/functions/finalize-outing/index.ts`)
- Outing finalization → Supabase services: writes finalized data (evidence: `README.md`)
- Ledger view → Ledger loading: loads ledger (evidence: `src/pages/LedgerPage.tsx`)
- Ledger loading → Supabase services: loads records
- Ledger loading → Balance calculation: computes balances (evidence: `src/features/ledger/useLedger.ts`)
- Ledger view → Settlement operations: records decisions (evidence: `src/pages/LedgerPage.tsx`)
- Settlement operations → Supabase services: persists settlements (evidence: `src/features/ledger/api.ts`)
- Group member → Activity feed: reviews changes (evidence: `README.md`)
- Group member → Filtered history: filters outings (evidence: `README.md`)
- Group member → Group exports: exports records (evidence: `README.md`)
- Group member → Meal recaps: shares recap (evidence: `README.md`)
- Group member → Payment QR: views payment QR (evidence: `README.md`)
- Authentication → Supabase services: authenticates (evidence: `src/features/auth/AuthProvider.tsx`)
- Group member → Platform shells: chooses platform (evidence: `README.md`)
