# mubashirtech56/expense-tracker architecture

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

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

## Overview

Friends Expense Manager is a collaborative expense-splitting web app for friends and groups. Users sign in, manage shared expenses and settlements, and view personal or group balances; administrators also manage members, group settings, and audit activity. The browser controller coordinates the UI, authentication, and data access, while Supabase provides persistence and authentication. The README documents realtime sync and PWA/offline support. Some feature implementations were not sampled, so those documented capabilities are shown without speculative internal call paths.

Main entry points: [`js/script.js`](https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js) (App controller), [`js/api.js`](https://github.com/mubashirtech56/expense-tracker/blob/main/js/api.js) (Data access and sync), [`js/auth.js`](https://github.com/mubashirtech56/expense-tracker/blob/main/js/auth.js) (Authentication), [`supabase/functions/create-friend/index.ts`](https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/functions/create-friend/index.ts) (Create member function)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_ui["App interface<br/>[index.html]"]
  node_controller["App controller<br/>[script.js]"]
  node_pwa["Offline shell<br/>[sw.js]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Authentication<br/>[auth.js]"]
  node_loginid["Login ID normalization<br/>[slugify.js]"]
  node_clientconfig["Supabase client setup<br/>[supabase.js]"]
end

subgraph group_expenses["Expense management"]
  node_dataaccess["Data access and sync<br/>[api.js]"]
  node_localcache[("Offline state cache<br/>[api.js]")]
  node_expenseflows["Expenses and settlements<br/>[script.js]"]
  node_memberadmin["Member administration<br/>[script.js]"]
  node_groupadmin["Group settings and audit<br/>[script.js]"]
  node_backups["Data backups<br/>[script.js]"]
end

subgraph group_backend["Supabase services"]
  node_database[("PostgreSQL with RLS<br/>[schema.sql]")]
  node_supabaseauth["Supabase Auth<br/>[supabase.js]"]
  node_edgecreate["Create member function<br/>[index.ts]"]
  node_edgedelete["Delete member function<br/>[index.ts]"]
  node_edgereset["Reset password function<br/>[index.ts]"]
  node_realtime["Supabase Realtime"]
end

node_user(("Friend or admin"))

node_user -->|"uses"| node_ui
node_ui -->|"renders"| node_controller
node_controller -->|"uses"| node_auth
node_controller -->|"calls"| node_dataaccess
node_controller -->|"coordinates"| node_expenseflows
node_controller -->|"provides"| node_memberadmin
node_controller -->|"provides"| node_groupadmin
node_controller -->|"provides"| node_backups
node_auth -->|"uses"| node_clientconfig
node_auth -->|"normalizes IDs"| node_loginid
node_auth -->|"authenticates"| node_supabaseauth
node_dataaccess -->|"uses"| node_clientconfig
node_dataaccess -->|"caches state"| node_localcache
node_dataaccess -->|"reads and writes"| node_database
node_dataaccess -->|"invokes"| node_edgecreate
node_edgecreate -->|"creates users"| node_supabaseauth
node_edgecreate -->|"inserts profiles"| node_database
node_edgedelete -->|"updates profiles"| node_database
node_controller -.->|"admin actions"| node_edgedelete
node_controller -.->|"admin actions"| node_edgereset
node_realtime -->|"syncs changes"| node_dataaccess
node_pwa -->|"serves offline shell"| node_ui

click node_ui "https://github.com/mubashirtech56/expense-tracker/blob/main/index.html"
click node_controller "https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js"
click node_pwa "https://github.com/mubashirtech56/expense-tracker/blob/main/public/sw.js"
click node_auth "https://github.com/mubashirtech56/expense-tracker/blob/main/js/auth.js"
click node_loginid "https://github.com/mubashirtech56/expense-tracker/blob/main/js/slugify.js"
click node_clientconfig "https://github.com/mubashirtech56/expense-tracker/blob/main/js/supabase.js"
click node_dataaccess "https://github.com/mubashirtech56/expense-tracker/blob/main/js/api.js"
click node_localcache "https://github.com/mubashirtech56/expense-tracker/blob/main/js/api.js"
click node_expenseflows "https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js"
click node_memberadmin "https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js"
click node_groupadmin "https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js"
click node_backups "https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js"
click node_database "https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/schema.sql"
click node_supabaseauth "https://github.com/mubashirtech56/expense-tracker/blob/main/js/supabase.js"
click node_edgecreate "https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/functions/create-friend/index.ts"
click node_edgedelete "https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/functions/delete-friend/index.ts"
click node_edgereset "https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/functions/reset-password/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_ui,node_controller,node_pwa toneBlue
class node_auth,node_loginid,node_clientconfig toneAmber
class node_dataaccess,node_localcache,node_expenseflows,node_memberadmin,node_groupadmin,node_backups toneMint
class node_database,node_supabaseauth,node_edgecreate,node_edgedelete,node_edgereset,node_realtime toneRose
class node_user toneIndigo
```

## Components

### Web application

- [App interface](https://github.com/mubashirtech56/expense-tracker/blob/main/index.html): `index.html`
- [App controller](https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js): `js/script.js`
- [Offline shell](https://github.com/mubashirtech56/expense-tracker/blob/main/public/sw.js): `public/sw.js`

### Identity and access

- [Authentication](https://github.com/mubashirtech56/expense-tracker/blob/main/js/auth.js): `js/auth.js`
- [Login ID normalization](https://github.com/mubashirtech56/expense-tracker/blob/main/js/slugify.js): `js/slugify.js`
- [Supabase client setup](https://github.com/mubashirtech56/expense-tracker/blob/main/js/supabase.js): `js/supabase.js`

### Expense management

- [Data access and sync](https://github.com/mubashirtech56/expense-tracker/blob/main/js/api.js): `js/api.js`
- [Offline state cache](https://github.com/mubashirtech56/expense-tracker/blob/main/js/api.js): `js/api.js`
- [Expenses and settlements](https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js): `js/script.js`
- [Member administration](https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js): `js/script.js`
- [Group settings and audit](https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js): `js/script.js`
- [Data backups](https://github.com/mubashirtech56/expense-tracker/blob/main/js/script.js): `js/script.js`

### Supabase services

- [PostgreSQL with RLS](https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/schema.sql): `supabase/schema.sql`
- [Supabase Auth](https://github.com/mubashirtech56/expense-tracker/blob/main/js/supabase.js): `js/supabase.js`
- [Create member function](https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/functions/create-friend/index.ts): `supabase/functions/create-friend/index.ts`
- [Delete member function](https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/functions/delete-friend/index.ts): `supabase/functions/delete-friend/index.ts`
- [Reset password function](https://github.com/mubashirtech56/expense-tracker/blob/main/supabase/functions/reset-password/index.ts): `supabase/functions/reset-password/index.ts`
- **Supabase Realtime**

### Other components

- **Friend or admin**

## Connections

- Friend or admin → App interface: uses (evidence: `README.md`)
- App interface → App controller: renders (evidence: `README.md`)
- App controller → Authentication: uses (evidence: `js/script.js`)
- App controller → Data access and sync: calls (evidence: `js/script.js`)
- App controller → Expenses and settlements: coordinates (evidence: `README.md`)
- App controller → Member administration: provides (evidence: `README.md`)
- App controller → Group settings and audit: provides (evidence: `README.md`)
- App controller → Data backups: provides (evidence: `README.md`)
- Authentication → Supabase client setup: uses (evidence: `js/auth.js`)
- Authentication → Login ID normalization: normalizes IDs (evidence: `js/auth.js`)
- Authentication → Supabase Auth: authenticates (evidence: `js/auth.js`)
- Data access and sync → Supabase client setup: uses (evidence: `js/api.js`)
- Data access and sync → Offline state cache: caches state (evidence: `js/api.js`)
- Data access and sync → PostgreSQL with RLS: reads and writes (evidence: `README.md`)
- Data access and sync → Create member function: invokes (evidence: `js/api.js`)
- Create member function → Supabase Auth: creates users (evidence: `supabase/functions/create-friend/index.ts`)
- Create member function → PostgreSQL with RLS: inserts profiles (evidence: `supabase/functions/create-friend/index.ts`)
- Delete member function → PostgreSQL with RLS: updates profiles (evidence: `supabase/functions/delete-friend/index.ts`)
- App controller → Delete member function: admin actions
- App controller → Reset password function: admin actions
- Supabase Realtime → Data access and sync: syncs changes (evidence: `README.md`)
- Offline shell → App interface: serves offline shell (evidence: `public/sw.js`)
