# amornthip66/petcosttrack architecture

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

- Interactive diagram: https://gitdiagram.com/amornthip66/petcosttrack
- Repository: https://github.com/amornthip66/petcosttrack

## Overview

PetCostTrack is a shared pet-care expense web app. Owners and co-caretakers sign in, manage pets and shared access, record expenses (including hidden costs, multi-pet allocation and receipts), and review dashboards and budgets; reminders and invitations support ongoing care. The static browser UI talks directly to Supabase Auth, REST and Storage, with database policies enforcing access. The graph preserves documented features whose precise frontend wiring was not sampled; those links are left unasserted. Email delivery is an optional Edge Function and requires a configured provider key.

Main entry points: [`js/api.js`](https://github.com/amornthip66/petcosttrack/blob/main/js/api.js) (Supabase API client), [`js/history.js`](https://github.com/amornthip66/petcosttrack/blob/main/js/history.js) (Expense history), [`js/auth.js`](https://github.com/amornthip66/petcosttrack/blob/main/js/auth.js) (Auth & profile), [`js/pets.js`](https://github.com/amornthip66/petcosttrack/blob/main/js/pets.js) (Pet profiles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; access"]
  node_login["Sign-in flow<br/>[login.js]"]
  node_auth["Auth &amp; profile<br/>[auth.js]"]
  node_users[("User records")]
end

subgraph group_care["Pet &amp; family care"]
  node_pets["Pet profiles<br/>[pets.js]"]
  node_family["Family access<br/>[profile.js]"]
  node_invitations["Care invitations<br/>[reminders.js]"]
end

subgraph group_finance["Expense management"]
  node_expense["Expense history<br/>[history.js]"]
  node_allocation["Pet cost shares"]
  node_receipts["Receipt files<br/>[history.js]"]
  node_categories["Expense categories<br/>[history.js]"]
end

subgraph group_insights["Planning &amp; insights"]
  node_dashboard["Spending dashboard<br/>[dashboard.js]"]
  node_budgets["Monthly budgets<br/>[budgets.js]"]
  node_reminders["Care reminders<br/>[reminders.js]"]
  node_alerts["In-app alerts<br/>[notifications.js]"]
end

subgraph group_platform["Backend services"]
  node_web["PetCostTrack UI<br/>[index.html]"]
  node_sharedui["Shared interface<br/>[components.js]"]
  node_api["Supabase API client<br/>[api.js]"]
  node_authservice["Supabase Auth"]
  node_database[("PostgreSQL &amp; RLS")]
  node_storage[("Supabase Storage")]
  node_emailfn["Reminder email function<br/>[index.ts]"]
end

node_owner(("Pet carers"))
node_emailprovider["Resend email service"]

node_owner -->|"uses"| node_web
node_web -.->|"opens"| node_login
node_login -->|"signs in"| node_auth
node_auth -->|"authenticates"| node_authservice
node_auth -->|"loads profile"| node_api
node_api -->|"queries"| node_database
node_auth -->|"links account"| node_users
node_web -.->|"renders shared UI"| node_sharedui
node_pets -->|"loads pet access"| node_api
node_pets -->|"stores pet photos"| node_storage
node_pets -->|"creates pet with owner"| node_database
node_family -->|"manages family access"| node_api
node_invitations -->|"accepts invitations"| node_api
node_expense -->|"saves expenses"| node_api
node_expense -.->|"allocates costs"| node_allocation
node_expense -->|"creates categories"| node_categories
node_expense -->|"uploads receipts"| node_storage
node_dashboard -->|"queries spending"| node_api
node_budgets -->|"reads budgets"| node_api
node_budgets -.->|"compares spending"| node_expense
node_reminders -->|"loads reminders"| node_api
node_reminders -.->|"shows due alerts"| node_alerts
node_emailfn -->|"reads due reminders"| node_database
node_emailfn -->|"sends email"| node_emailprovider

click node_web "https://github.com/amornthip66/petcosttrack/blob/main/index.html"
click node_login "https://github.com/amornthip66/petcosttrack/blob/main/js/login.js"
click node_auth "https://github.com/amornthip66/petcosttrack/blob/main/js/auth.js"
click node_users "https://github.com/amornthip66/petcosttrack/blob/main/supabase/migrations/20260831000000_remote_schema.sql"
click node_pets "https://github.com/amornthip66/petcosttrack/blob/main/js/pets.js"
click node_family "https://github.com/amornthip66/petcosttrack/blob/main/js/profile.js"
click node_invitations "https://github.com/amornthip66/petcosttrack/blob/main/js/reminders.js"
click node_expense "https://github.com/amornthip66/petcosttrack/blob/main/js/history.js"
click node_allocation "https://github.com/amornthip66/petcosttrack/blob/main/js/expense-allocation.js"
click node_receipts "https://github.com/amornthip66/petcosttrack/blob/main/js/history.js"
click node_categories "https://github.com/amornthip66/petcosttrack/blob/main/js/history.js"
click node_dashboard "https://github.com/amornthip66/petcosttrack/blob/main/js/dashboard.js"
click node_budgets "https://github.com/amornthip66/petcosttrack/blob/main/js/budgets.js"
click node_reminders "https://github.com/amornthip66/petcosttrack/blob/main/js/reminders.js"
click node_alerts "https://github.com/amornthip66/petcosttrack/blob/main/js/notifications.js"
click node_sharedui "https://github.com/amornthip66/petcosttrack/blob/main/js/components.js"
click node_api "https://github.com/amornthip66/petcosttrack/blob/main/js/api.js"
click node_database "https://github.com/amornthip66/petcosttrack/blob/main/supabase/migrations/20260904000000_enforce_strict_rls.sql"
click node_storage "https://github.com/amornthip66/petcosttrack/blob/main/supabase/migrations/20260910000000_receipts_pdf_and_rls.sql"
click node_emailfn "https://github.com/amornthip66/petcosttrack/blob/main/supabase/functions/send-reminder-emails/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_login,node_auth,node_users toneBlue
class node_pets,node_family,node_invitations toneAmber
class node_expense,node_allocation,node_receipts,node_categories toneMint
class node_dashboard,node_budgets,node_reminders,node_alerts toneRose
class node_web,node_sharedui,node_api,node_authservice,node_database,node_storage,node_emailfn,node_owner,node_emailprovider toneIndigo
```

## Components

### Identity & access

- [Sign-in flow](https://github.com/amornthip66/petcosttrack/blob/main/js/login.js): `js/login.js`
- [Auth & profile](https://github.com/amornthip66/petcosttrack/blob/main/js/auth.js): `js/auth.js`
- [User records](https://github.com/amornthip66/petcosttrack/blob/main/supabase/migrations/20260831000000_remote_schema.sql): `supabase/migrations/20260831000000_remote_schema.sql`

### Pet & family care

- [Pet profiles](https://github.com/amornthip66/petcosttrack/blob/main/js/pets.js): `js/pets.js`
- [Family access](https://github.com/amornthip66/petcosttrack/blob/main/js/profile.js): `js/profile.js`
- [Care invitations](https://github.com/amornthip66/petcosttrack/blob/main/js/reminders.js): `js/reminders.js`

### Expense management

- [Expense history](https://github.com/amornthip66/petcosttrack/blob/main/js/history.js): `js/history.js`
- [Pet cost shares](https://github.com/amornthip66/petcosttrack/blob/main/js/expense-allocation.js): `js/expense-allocation.js`
- [Receipt files](https://github.com/amornthip66/petcosttrack/blob/main/js/history.js): `js/history.js`
- [Expense categories](https://github.com/amornthip66/petcosttrack/blob/main/js/history.js): `js/history.js`

### Planning & insights

- [Spending dashboard](https://github.com/amornthip66/petcosttrack/blob/main/js/dashboard.js): `js/dashboard.js`
- [Monthly budgets](https://github.com/amornthip66/petcosttrack/blob/main/js/budgets.js): `js/budgets.js`
- [Care reminders](https://github.com/amornthip66/petcosttrack/blob/main/js/reminders.js): `js/reminders.js`
- [In-app alerts](https://github.com/amornthip66/petcosttrack/blob/main/js/notifications.js): `js/notifications.js`

### Backend services

- [PetCostTrack UI](https://github.com/amornthip66/petcosttrack/blob/main/index.html): `index.html`
- [Shared interface](https://github.com/amornthip66/petcosttrack/blob/main/js/components.js): `js/components.js`
- [Supabase API client](https://github.com/amornthip66/petcosttrack/blob/main/js/api.js): `js/api.js`
- **Supabase Auth**
- [PostgreSQL & RLS](https://github.com/amornthip66/petcosttrack/blob/main/supabase/migrations/20260904000000_enforce_strict_rls.sql): `supabase/migrations/20260904000000_enforce_strict_rls.sql`
- [Supabase Storage](https://github.com/amornthip66/petcosttrack/blob/main/supabase/migrations/20260910000000_receipts_pdf_and_rls.sql): `supabase/migrations/20260910000000_receipts_pdf_and_rls.sql`
- [Reminder email function](https://github.com/amornthip66/petcosttrack/blob/main/supabase/functions/send-reminder-emails/index.ts): `supabase/functions/send-reminder-emails/index.ts`

### Other components

- **Pet carers**
- **Resend email service**

## Connections

- Pet carers → PetCostTrack UI: uses (evidence: `README.md`)
- PetCostTrack UI → Sign-in flow: opens
- Sign-in flow → Auth & profile: signs in (evidence: `js/login.js`)
- Auth & profile → Supabase Auth: authenticates (evidence: `js/auth.js`)
- Auth & profile → Supabase API client: loads profile (evidence: `js/auth.js`)
- Supabase API client → PostgreSQL & RLS: queries (evidence: `README.md`)
- Auth & profile → User records: links account (evidence: `js/auth.js`)
- PetCostTrack UI → Shared interface: renders shared UI
- Pet profiles → Supabase API client: loads pet access (evidence: `js/pets.js`)
- Pet profiles → Supabase Storage: stores pet photos (evidence: `README.md`)
- Pet profiles → PostgreSQL & RLS: creates pet with owner (evidence: `js/pets.js`)
- Family access → Supabase API client: manages family access (evidence: `js/profile.js`)
- Care invitations → Supabase API client: accepts invitations (evidence: `js/reminders.js`)
- Expense history → Supabase API client: saves expenses (evidence: `js/history.js`)
- Expense history → Pet cost shares: allocates costs
- Expense history → Expense categories: creates categories (evidence: `js/history.js`)
- Expense history → Supabase Storage: uploads receipts (evidence: `README.md`)
- Spending dashboard → Supabase API client: queries spending (evidence: `js/dashboard.js`)
- Monthly budgets → Supabase API client: reads budgets (evidence: `js/budgets.js`)
- Monthly budgets → Expense history: compares spending
- Care reminders → Supabase API client: loads reminders (evidence: `js/reminders.js`)
- Care reminders → In-app alerts: shows due alerts
- Reminder email function → PostgreSQL & RLS: reads due reminders (evidence: `supabase/functions/send-reminder-emails/index.ts`)
- Reminder email function → Resend email service: sends email (evidence: `supabase/functions/send-reminder-emails/index.ts`)
