# kartoff-an/co-split architecture

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

- Interactive diagram: https://gitdiagram.com/kartoff-an/co-split
- Repository: https://github.com/kartoff-an/co-split

## Overview

Co-Split is a collaborative group expense ledger. Users enter through the routed React app, authenticate, create or join a workspace, manage members and expenses, then review balances and settle debts. Workspace and expense hooks coordinate feature services, which use Supabase for persistence and authentication. The README describes a database-side greedy settlement engine; its implementation is not in the supplied tree, so only its typed RPC surface is represented. Unsampled UI and integration details are shown only where documented or referenced by the source index.

Main entry points: [`src/lib/supabase.ts`](https://github.com/kartoff-an/co-split/blob/main/src/lib/supabase.ts) (Supabase client), [`src/features/workspaces/workspaceService.ts`](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/workspaceService.ts) (Workspace service), [`src/App.tsx`](https://github.com/kartoff-an/co-split/blob/main/src/App.tsx) (App routes), [`src/features/workspaces/WorkspacePage.tsx`](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/WorkspacePage.tsx) (Workspace view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App and identity"]
  node_router["App routes<br/>[App.tsx]"]
  node_auth["Auth provider<br/>[AuthProvider.tsx]"]
  node_auth_service["Auth service<br/>[authService.ts]"]
  node_login["Google login<br/>[GoogleLogin.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_dashboard_hook["Dashboard data<br/>[useDashboard.ts]"]
end

subgraph group_workspace["Workspaces"]
  node_workspace_page["Workspace view<br/>[WorkspacePage.tsx]"]
  node_join_page["Join workspace<br/>[JoinPage.tsx]"]
  node_workspace_hook["Workspace state<br/>[useWorkspace.ts]"]
  node_workspace_service["Workspace service"]
  node_membership["Member operations<br/>[members.ts]"]
  node_workspace_records["Workspace records<br/>[workspaces.ts]"]
end

subgraph group_ledger["Expense ledger"]
  node_expense_ui["Expense screens<br/>[ExpenseList.tsx]"]
  node_balance_ui["Balance and settlement UI<br/>[BalanceSummary.tsx]"]
  node_expense_hook_service["Expense service<br/>[expenseService.ts]"]
  node_expense_data["Expense data access<br/>[expenses.ts]"]
  node_balance_data["Balance calculations<br/>[useBalance.ts]"]
  node_settlement_rpc["Settlement RPC types<br/>[database.types.ts]"]
end

subgraph group_platform["Persistence and shared state"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_supabase[("Supabase")]
  node_theme["Theme provider<br/>[ThemeProvider.tsx]"]
  node_typed_models["Domain models<br/>[index.ts]"]
end

node_user(("Ledger user"))

node_user -->|"opens app"| node_router
node_router -->|"wraps routes"| node_auth
node_router -->|"routes to"| node_dashboard
node_router -->|"routes to"| node_workspace_page
node_router -->|"routes to"| node_join_page
node_auth -->|"uses"| node_auth_service
node_login -.->|"signs in"| node_auth_service
node_dashboard -->|"loads overview"| node_dashboard_hook
node_dashboard_hook -->|"fetches workspaces"| node_workspace_service
node_workspace_page -->|"loads workspace"| node_workspace_hook
node_workspace_page -->|"loads balances"| node_balance_data
node_workspace_page -->|"renders expenses"| node_expense_ui
node_workspace_page -->|"renders balances"| node_balance_ui
node_join_page -->|"joins workspace"| node_workspace_service
node_workspace_hook -->|"loads and updates"| node_workspace_service
node_workspace_hook -->|"changes expenses"| node_expense_hook_service
node_workspace_service -->|"delegates membership"| node_membership
node_workspace_service -->|"delegates workspace data"| node_workspace_records
node_expense_hook_service -->|"delegates expense data"| node_expense_data
node_workspace_service -->|"calls RPC"| node_supabase_client
node_membership -->|"reads and writes"| node_supabase_client
node_workspace_records -->|"reads and writes"| node_supabase_client
node_expense_data -->|"reads and writes"| node_supabase_client
node_balance_data -->|"queries balances"| node_supabase_client
node_auth_service -->|"uses auth"| node_supabase_client
node_supabase_client -->|"connects"| node_supabase
node_supabase -.->|"exposes settlement function"| node_settlement_rpc
node_workspace_service -->|"maps domain data"| node_typed_models
node_supabase_client -->|"uses database types"| node_typed_models

click node_router "https://github.com/kartoff-an/co-split/blob/main/src/App.tsx"
click node_auth "https://github.com/kartoff-an/co-split/blob/main/src/features/auth/AuthProvider.tsx"
click node_auth_service "https://github.com/kartoff-an/co-split/blob/main/src/features/auth/authService.ts"
click node_login "https://github.com/kartoff-an/co-split/blob/main/src/features/auth/GoogleLogin.tsx"
click node_dashboard "https://github.com/kartoff-an/co-split/blob/main/src/features/dashboard/Dashboard.tsx"
click node_dashboard_hook "https://github.com/kartoff-an/co-split/blob/main/src/features/dashboard/useDashboard.ts"
click node_workspace_page "https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/WorkspacePage.tsx"
click node_join_page "https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/JoinPage.tsx"
click node_workspace_hook "https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/useWorkspace.ts"
click node_workspace_service "https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/workspaceService.ts"
click node_membership "https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/members.ts"
click node_workspace_records "https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/workspaces.ts"
click node_expense_ui "https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/ExpenseList.tsx"
click node_balance_ui "https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/BalanceSummary.tsx"
click node_expense_hook_service "https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/expenseService.ts"
click node_expense_data "https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/expenses.ts"
click node_balance_data "https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/useBalance.ts"
click node_settlement_rpc "https://github.com/kartoff-an/co-split/blob/main/src/types/database.types.ts"
click node_supabase_client "https://github.com/kartoff-an/co-split/blob/main/src/lib/supabase.ts"
click node_theme "https://github.com/kartoff-an/co-split/blob/main/src/features/theme/ThemeProvider.tsx"
click node_typed_models "https://github.com/kartoff-an/co-split/blob/main/src/types/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_router,node_auth,node_auth_service,node_login,node_dashboard,node_dashboard_hook,node_user toneBlue
class node_workspace_page,node_join_page,node_workspace_hook,node_workspace_service,node_membership,node_workspace_records toneAmber
class node_expense_ui,node_balance_ui,node_expense_hook_service,node_expense_data,node_balance_data,node_settlement_rpc toneMint
class node_supabase_client,node_supabase,node_theme,node_typed_models toneRose
```

## Components

### App and identity

- [App routes](https://github.com/kartoff-an/co-split/blob/main/src/App.tsx): `src/App.tsx`
- [Auth provider](https://github.com/kartoff-an/co-split/blob/main/src/features/auth/AuthProvider.tsx): `src/features/auth/AuthProvider.tsx`
- [Auth service](https://github.com/kartoff-an/co-split/blob/main/src/features/auth/authService.ts): `src/features/auth/authService.ts`
- [Google login](https://github.com/kartoff-an/co-split/blob/main/src/features/auth/GoogleLogin.tsx): `src/features/auth/GoogleLogin.tsx`
- [Dashboard](https://github.com/kartoff-an/co-split/blob/main/src/features/dashboard/Dashboard.tsx): `src/features/dashboard/Dashboard.tsx`
- [Dashboard data](https://github.com/kartoff-an/co-split/blob/main/src/features/dashboard/useDashboard.ts): `src/features/dashboard/useDashboard.ts`

### Workspaces

- [Workspace view](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/WorkspacePage.tsx): `src/features/workspaces/WorkspacePage.tsx`
- [Join workspace](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/JoinPage.tsx): `src/features/workspaces/JoinPage.tsx`
- [Workspace state](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/useWorkspace.ts): `src/features/workspaces/useWorkspace.ts`
- [Workspace service](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/workspaceService.ts): `src/features/workspaces/workspaceService.ts`
- [Member operations](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/members.ts): `src/features/workspaces/members.ts`
- [Workspace records](https://github.com/kartoff-an/co-split/blob/main/src/features/workspaces/workspaces.ts): `src/features/workspaces/workspaces.ts`

### Expense ledger

- [Expense screens](https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/ExpenseList.tsx): `src/features/expenses/ExpenseList.tsx`
- [Balance and settlement UI](https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/BalanceSummary.tsx): `src/features/expenses/BalanceSummary.tsx`
- [Expense service](https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/expenseService.ts): `src/features/expenses/expenseService.ts`
- [Expense data access](https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/expenses.ts): `src/features/expenses/expenses.ts`
- [Balance calculations](https://github.com/kartoff-an/co-split/blob/main/src/features/expenses/useBalance.ts): `src/features/expenses/useBalance.ts`
- [Settlement RPC types](https://github.com/kartoff-an/co-split/blob/main/src/types/database.types.ts): `src/types/database.types.ts`

### Persistence and shared state

- [Supabase client](https://github.com/kartoff-an/co-split/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- **Supabase**
- [Theme provider](https://github.com/kartoff-an/co-split/blob/main/src/features/theme/ThemeProvider.tsx): `src/features/theme/ThemeProvider.tsx`
- [Domain models](https://github.com/kartoff-an/co-split/blob/main/src/types/index.ts): `src/types/index.ts`

### Other components

- **Ledger user**

## Connections

- Ledger user → App routes: opens app (evidence: `src/App.tsx`)
- App routes → Auth provider: wraps routes (evidence: `src/App.tsx`)
- App routes → Dashboard: routes to (evidence: `src/App.tsx`)
- App routes → Workspace view: routes to (evidence: `src/App.tsx`)
- App routes → Join workspace: routes to (evidence: `src/App.tsx`)
- Auth provider → Auth service: uses (evidence: `src/features/auth/AuthProvider.tsx`)
- Google login → Auth service: signs in
- Dashboard → Dashboard data: loads overview (evidence: `src/features/dashboard/Dashboard.tsx`)
- Dashboard data → Workspace service: fetches workspaces (evidence: `src/features/dashboard/useDashboard.ts`)
- Workspace view → Workspace state: loads workspace (evidence: `src/features/workspaces/WorkspacePage.tsx`)
- Workspace view → Balance calculations: loads balances (evidence: `src/features/workspaces/WorkspacePage.tsx`)
- Workspace view → Expense screens: renders expenses (evidence: `src/features/workspaces/WorkspacePage.tsx`)
- Workspace view → Balance and settlement UI: renders balances (evidence: `src/features/workspaces/WorkspacePage.tsx`)
- Join workspace → Workspace service: joins workspace (evidence: `src/features/workspaces/JoinPage.tsx`)
- Workspace state → Workspace service: loads and updates (evidence: `src/features/workspaces/useWorkspace.ts`)
- Workspace state → Expense service: changes expenses (evidence: `src/features/workspaces/useWorkspace.ts`)
- Workspace service → Member operations: delegates membership (evidence: `src/features/workspaces/workspaceService.ts`)
- Workspace service → Workspace records: delegates workspace data (evidence: `src/features/workspaces/workspaceService.ts`)
- Expense service → Expense data access: delegates expense data (evidence: `src/features/expenses/expenseService.ts`)
- Workspace service → Supabase client: calls RPC (evidence: `src/features/workspaces/workspaceService.ts`)
- Member operations → Supabase client: reads and writes (evidence: `src/features/workspaces/members.ts`)
- Workspace records → Supabase client: reads and writes (evidence: `src/features/workspaces/workspaces.ts`)
- Expense data access → Supabase client: reads and writes (evidence: `src/features/expenses/expenses.ts`)
- Balance calculations → Supabase client: queries balances (evidence: `src/features/expenses/useBalance.ts`)
- Auth service → Supabase client: uses auth (evidence: `src/features/auth/authService.ts`)
- Supabase client → Supabase: connects (evidence: `src/lib/supabase.ts`)
- Supabase → Settlement RPC types: exposes settlement function (evidence: `README.md`)
- Workspace service → Domain models: maps domain data (evidence: `src/features/workspaces/workspaceService.ts`)
- Supabase client → Domain models: uses database types (evidence: `src/lib/supabase.ts`)
