# trimulia02/kasbon architecture

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

- Interactive diagram: https://gitdiagram.com/trimulia02/kasbon
- Repository: https://github.com/trimulia02/kasbon

## Overview

Kasbon is a personal debt-tracking app. Users sign up or log in, then manage debts from a dashboard: add/edit, settle, delete, filter, search, sort, and view outstanding totals and a two-bar comparison chart. The dashboard loads list and summary data through separate API requests; API handlers validate input, authenticate the user, and read or mutate Supabase rows. The README documents user-scoped row-level security. Some wiring is supported only by the README or SOURCE INDEX; unsampled implementation details are not inferred.

Main entry points: [`src/components/dashboard/DashboardClient.tsx`](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DashboardClient.tsx) (Dashboard controller), [`src/app/api/debts/route.ts`](https://github.com/trimulia02/kasbon/blob/main/src/app/api/debts/route.ts) (List and create), [`src/app/api/debts/[id]/route.ts`](https://github.com/trimulia02/kasbon/blob/main/src/app/api/debts/%5Bid%5D/route.ts) (Update and delete), [`src/lib/supabase/server.ts`](https://github.com/trimulia02/kasbon/blob/main/src/lib/supabase/server.ts) (Server client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Authentication"]
  node_authform["Auth form<br/>[AuthForm.tsx]"]
  node_authactions["Auth actions<br/>[actions.ts]"]
end

subgraph group_dashboard["Dashboard"]
  node_header["Dashboard header<br/>[Header.tsx]"]
  node_dashboardclient["Dashboard controller"]
  node_debtform["Debt form<br/>[DebtFormModal.tsx]"]
  node_debtlist["Debt list<br/>[DebtList.tsx]"]
  node_debthrow["Debt row<br/>[DebtRow.tsx]"]
  node_filterbar["Filters and sort<br/>[FilterBar.tsx]"]
  node_summarycards["Summary cards<br/>[SummaryCards.tsx]"]
  node_debtschart["Debt chart<br/>[DebtsChart.tsx]"]
  node_confirmdialog["Delete confirmation<br/>[ConfirmDialog.tsx]"]
  node_modal["Modal shell<br/>[Modal.tsx]"]
  node_debthook["Debt list hook<br/>[useDebts.ts]"]
  node_summaryhook["Summary hook<br/>[useDebtSummary.ts]"]
end

subgraph group_api["Debt API"]
  node_debtsapi["List and create<br/>[route.ts]"]
  node_debtitemapi["Update and delete<br/>[route.ts]"]
end

subgraph group_services["Data and security"]
  node_supabaseserver["Server client<br/>[server.ts]"]
  node_sessionproxy["Session refresh<br/>[middleware.ts]"]
  node_proxy["Request gate<br/>[proxy.ts]"]
end

subgraph group_shared["Shared domain"]
  node_validation["Input schemas<br/>[validation.ts]"]
  node_debtmodel["Debt mapping<br/>[debt.ts]"]
  node_format["Date and currency<br/>[format.ts]"]
end

node_visitor(("User"))
node_supabase[("Supabase Auth and PostgreSQL")]

node_visitor -->|"enters credentials"| node_authform
node_authform -->|"submits form"| node_authactions
node_authactions -->|"creates client"| node_supabaseserver
node_supabaseserver -.->|"authenticates"| node_supabase
node_visitor -->|"opens dashboard"| node_dashboardclient
node_dashboardclient -->|"renders"| node_header
node_dashboardclient -->|"renders"| node_filterbar
node_dashboardclient -->|"renders"| node_debtlist
node_dashboardclient -->|"renders"| node_debtform
node_dashboardclient -->|"renders"| node_confirmdialog
node_dashboardclient -->|"renders"| node_summarycards
node_dashboardclient -->|"renders"| node_debtschart
node_debtform -->|"uses shell"| node_modal
node_confirmdialog -->|"uses shell"| node_modal
node_debtlist -->|"renders rows"| node_debthrow
node_dashboardclient -->|"loads debts"| node_debthook
node_dashboardclient -->|"loads totals"| node_summaryhook
node_summaryhook -->|"loads unsettled"| node_debthook
node_debthook -->|"fetches list"| node_debtsapi
node_dashboardclient -->|"creates debt"| node_debtsapi
node_dashboardclient -->|"updates or deletes"| node_debtitemapi
node_debtsapi -->|"validates input"| node_validation
node_debtitemapi -->|"validates updates"| node_validation
node_debtsapi -->|"creates client"| node_supabaseserver
node_debtitemapi -->|"creates client"| node_supabaseserver
node_debtsapi -->|"reads and inserts"| node_supabase
node_debtitemapi -->|"updates and deletes"| node_supabase
node_debtsapi -->|"maps rows"| node_debtmodel
node_debtitemapi -->|"maps rows"| node_debtmodel
node_proxy -->|"refreshes session"| node_sessionproxy
node_sessionproxy -.->|"refreshes auth session"| node_supabase
node_supabase -.->|"authenticates session"| node_visitor
node_debtmodel -.->|"formats display values"| node_format
node_dashboardclient -->|"formats delete amount"| node_format

click node_authform "https://github.com/trimulia02/kasbon/blob/main/src/components/auth/AuthForm.tsx"
click node_authactions "https://github.com/trimulia02/kasbon/blob/main/src/lib/auth/actions.ts"
click node_header "https://github.com/trimulia02/kasbon/blob/main/src/components/layout/Header.tsx"
click node_dashboardclient "https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DashboardClient.tsx"
click node_debtform "https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtFormModal.tsx"
click node_debtlist "https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtList.tsx"
click node_debthrow "https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtRow.tsx"
click node_filterbar "https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/FilterBar.tsx"
click node_summarycards "https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/SummaryCards.tsx"
click node_debtschart "https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtsChart.tsx"
click node_confirmdialog "https://github.com/trimulia02/kasbon/blob/main/src/components/ui/ConfirmDialog.tsx"
click node_modal "https://github.com/trimulia02/kasbon/blob/main/src/components/ui/Modal.tsx"
click node_debthook "https://github.com/trimulia02/kasbon/blob/main/src/hooks/useDebts.ts"
click node_summaryhook "https://github.com/trimulia02/kasbon/blob/main/src/hooks/useDebtSummary.ts"
click node_debtsapi "https://github.com/trimulia02/kasbon/blob/main/src/app/api/debts/route.ts"
click node_debtitemapi "https://github.com/trimulia02/kasbon/blob/main/src/app/api/debts/%5Bid%5D/route.ts"
click node_validation "https://github.com/trimulia02/kasbon/blob/main/src/lib/validation.ts"
click node_debtmodel "https://github.com/trimulia02/kasbon/blob/main/src/types/debt.ts"
click node_format "https://github.com/trimulia02/kasbon/blob/main/src/lib/format.ts"
click node_supabaseserver "https://github.com/trimulia02/kasbon/blob/main/src/lib/supabase/server.ts"
click node_sessionproxy "https://github.com/trimulia02/kasbon/blob/main/src/lib/supabase/middleware.ts"
click node_proxy "https://github.com/trimulia02/kasbon/blob/main/src/proxy.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_authform,node_authactions,node_visitor toneBlue
class node_header,node_dashboardclient,node_debtform,node_debtlist,node_debthrow,node_filterbar,node_summarycards,node_debtschart,node_confirmdialog,node_modal,node_debthook,node_summaryhook,node_supabase toneAmber
class node_debtsapi,node_debtitemapi toneMint
class node_supabaseserver,node_sessionproxy,node_proxy toneRose
class node_validation,node_debtmodel,node_format toneIndigo
```

## Components

### Authentication

- [Auth form](https://github.com/trimulia02/kasbon/blob/main/src/components/auth/AuthForm.tsx): `src/components/auth/AuthForm.tsx`
- [Auth actions](https://github.com/trimulia02/kasbon/blob/main/src/lib/auth/actions.ts): `src/lib/auth/actions.ts`

### Dashboard

- [Dashboard header](https://github.com/trimulia02/kasbon/blob/main/src/components/layout/Header.tsx): `src/components/layout/Header.tsx`
- [Dashboard controller](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DashboardClient.tsx): `src/components/dashboard/DashboardClient.tsx`
- [Debt form](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtFormModal.tsx): `src/components/dashboard/DebtFormModal.tsx`
- [Debt list](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtList.tsx): `src/components/dashboard/DebtList.tsx`
- [Debt row](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtRow.tsx): `src/components/dashboard/DebtRow.tsx`
- [Filters and sort](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/FilterBar.tsx): `src/components/dashboard/FilterBar.tsx`
- [Summary cards](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/SummaryCards.tsx): `src/components/dashboard/SummaryCards.tsx`
- [Debt chart](https://github.com/trimulia02/kasbon/blob/main/src/components/dashboard/DebtsChart.tsx): `src/components/dashboard/DebtsChart.tsx`
- [Delete confirmation](https://github.com/trimulia02/kasbon/blob/main/src/components/ui/ConfirmDialog.tsx): `src/components/ui/ConfirmDialog.tsx`
- [Modal shell](https://github.com/trimulia02/kasbon/blob/main/src/components/ui/Modal.tsx): `src/components/ui/Modal.tsx`
- [Debt list hook](https://github.com/trimulia02/kasbon/blob/main/src/hooks/useDebts.ts): `src/hooks/useDebts.ts`
- [Summary hook](https://github.com/trimulia02/kasbon/blob/main/src/hooks/useDebtSummary.ts): `src/hooks/useDebtSummary.ts`

### Debt API

- [List and create](https://github.com/trimulia02/kasbon/blob/main/src/app/api/debts/route.ts): `src/app/api/debts/route.ts`
- [Update and delete](https://github.com/trimulia02/kasbon/blob/main/src/app/api/debts/%5Bid%5D/route.ts): `src/app/api/debts/[id]/route.ts`

### Data and security

- [Server client](https://github.com/trimulia02/kasbon/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Session refresh](https://github.com/trimulia02/kasbon/blob/main/src/lib/supabase/middleware.ts): `src/lib/supabase/middleware.ts`
- [Request gate](https://github.com/trimulia02/kasbon/blob/main/src/proxy.ts): `src/proxy.ts`

### Shared domain

- [Input schemas](https://github.com/trimulia02/kasbon/blob/main/src/lib/validation.ts): `src/lib/validation.ts`
- [Debt mapping](https://github.com/trimulia02/kasbon/blob/main/src/types/debt.ts): `src/types/debt.ts`
- [Date and currency](https://github.com/trimulia02/kasbon/blob/main/src/lib/format.ts): `src/lib/format.ts`

### Other components

- **User**
- **Supabase Auth and PostgreSQL**

## Connections

- User → Auth form: enters credentials (evidence: `README.md`)
- Auth form → Auth actions: submits form (evidence: `src/components/auth/AuthForm.tsx`)
- Auth actions → Server client: creates client (evidence: `src/lib/auth/actions.ts`)
- Server client → Supabase Auth and PostgreSQL: authenticates
- User → Dashboard controller: opens dashboard (evidence: `README.md`)
- Dashboard controller → Dashboard header: renders (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Filters and sort: renders (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Debt list: renders (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Debt form: renders (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Delete confirmation: renders (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Summary cards: renders (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Debt chart: renders (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Debt form → Modal shell: uses shell (evidence: `src/components/dashboard/DebtFormModal.tsx`)
- Delete confirmation → Modal shell: uses shell (evidence: `src/components/ui/ConfirmDialog.tsx`)
- Debt list → Debt row: renders rows (evidence: `src/components/dashboard/DebtList.tsx`)
- Dashboard controller → Debt list hook: loads debts (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Summary hook: loads totals (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Summary hook → Debt list hook: loads unsettled (evidence: `src/hooks/useDebtSummary.ts`)
- Debt list hook → List and create: fetches list (evidence: `src/hooks/useDebts.ts`)
- Dashboard controller → List and create: creates debt (evidence: `src/components/dashboard/DashboardClient.tsx`)
- Dashboard controller → Update and delete: updates or deletes (evidence: `src/components/dashboard/DashboardClient.tsx`)
- List and create → Input schemas: validates input (evidence: `src/app/api/debts/route.ts`)
- Update and delete → Input schemas: validates updates (evidence: `src/app/api/debts/[id]/route.ts`)
- List and create → Server client: creates client (evidence: `src/app/api/debts/route.ts`)
- Update and delete → Server client: creates client (evidence: `src/app/api/debts/[id]/route.ts`)
- List and create → Supabase Auth and PostgreSQL: reads and inserts (evidence: `src/app/api/debts/route.ts`)
- Update and delete → Supabase Auth and PostgreSQL: updates and deletes (evidence: `src/app/api/debts/[id]/route.ts`)
- List and create → Debt mapping: maps rows (evidence: `src/app/api/debts/route.ts`)
- Update and delete → Debt mapping: maps rows (evidence: `src/app/api/debts/[id]/route.ts`)
- Request gate → Session refresh: refreshes session (evidence: `src/proxy.ts`)
- Session refresh → Supabase Auth and PostgreSQL: refreshes auth session
- Supabase Auth and PostgreSQL → User: authenticates session
- Debt mapping → Date and currency: formats display values
- Dashboard controller → Date and currency: formats delete amount (evidence: `src/components/dashboard/DashboardClient.tsx`)
