# losshye/catatku architecture

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

- Interactive diagram: https://gitdiagram.com/losshye/catatku
- Repository: https://github.com/losshye/catatku

## Overview

Catatku is an offline-first personal-finance PWA: users enter income, expenses, or wallet transfers, then review balances, budgets, history, and reports from device-local data. The main flow runs from the app shell through screens and a reactive ledger hook to IndexedDB-backed repositories and domain calculations. Other documented capabilities include wallet/category management, recurring items, savings, debts, receipt scanning, security, and backup/sharing. Edges follow shown imports/calls or README statements; unsampled implementation details are omitted.

Main entry points: [`src/App.tsx`](https://github.com/losshye/catatku/blob/main/src/App.tsx) (App shell), [`src/db/transactions.repo.ts`](https://github.com/losshye/catatku/blob/main/src/db/transactions.repo.ts) (Transaction repository), [`src/hooks/useLedger.ts`](https://github.com/losshye/catatku/blob/main/src/hooks/useLedger.ts) (Reactive ledger hook), [`src/db/database.ts`](https://github.com/losshye/catatku/blob/main/src/db/database.ts) (IndexedDB schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_entry["React entry<br/>[main.tsx]"]
  node_shell["App shell<br/>[App.tsx]"]
end

subgraph group_finance["Finance workflows"]
  node_home["Home screen<br/>[HomeScreen.tsx]"]
  node_input["Transaction input<br/>[InputScreen.tsx]"]
  node_budget["Budgets and goals<br/>[BudgetScreen.tsx]"]
  node_history["History and editing<br/>[HistoryScreen.tsx]"]
  node_reports["Reports<br/>[ReportScreen.tsx]"]
  node_wallets["Wallet management<br/>[WalletSheet.tsx]"]
  node_categories["Category management<br/>[CategorySheet.tsx]"]
  node_receipt["Receipt scanning"]
  node_settings["Settings and sharing<br/>[SettingsSheet.tsx]"]
end

subgraph group_storage["Local data"]
  node_ledgerhook["Reactive ledger hook<br/>[useLedger.ts]"]
  node_ledger["Ledger read model<br/>[ledger.ts]"]
  node_database[("IndexedDB schema<br/>[database.ts]")]
  node_transactions["Transaction repository"]
  node_budgetsrepo["Budget repository<br/>[budgets.repo.ts]"]
  node_walletrepo["Wallet repository<br/>[wallets.repo.ts]"]
end

subgraph group_domain["Domain logic"]
  node_transactionlogic["Transaction rules<br/>[transaction.ts]"]
  node_money["Rupiah arithmetic<br/>[money.ts]"]
  node_date["Local date cycles<br/>[date.ts]"]
end

subgraph group_security["Security and portability"]
  node_securityrepo["Security repository<br/>[security.repo.ts]"]
  node_vault["Encrypted vault<br/>[vault.ts]"]
  node_export["Backup and export<br/>[export.ts]"]
  node_sharedpack["Shared wallet packs<br/>[sharedPack.ts]"]
  node_securityui["PIN lock screen<br/>[PinLockScreen.tsx]"]
end

node_user(("User"))

node_user -->|"uses"| node_entry
node_entry -->|"mounts"| node_shell
node_shell -->|"routes"| node_home
node_shell -->|"routes"| node_input
node_shell -->|"routes"| node_budget
node_shell -->|"routes"| node_history
node_shell -->|"routes"| node_reports
node_shell -->|"loads PIN"| node_securityrepo
node_shell -->|"checks vault"| node_vault
node_shell -.->|"locks app"| node_securityui
node_home -->|"reads snapshot"| node_ledgerhook
node_input -->|"saves transaction"| node_transactions
node_input -->|"reads snapshot"| node_ledgerhook
node_input -->|"opens picker"| node_categories
node_input -->|"opens scanner"| node_receipt
node_budget -->|"upserts budget"| node_budgetsrepo
node_budget -->|"reads snapshot"| node_ledgerhook
node_history -->|"reads snapshot"| node_ledgerhook
node_history -->|"edits transactions"| node_transactions
node_reports -->|"reads snapshot"| node_ledgerhook
node_home -->|"opens wallets"| node_wallets
node_settings -->|"serializes backup"| node_export
node_settings -->|"parses pack"| node_sharedpack
node_ledgerhook -->|"loads snapshot"| node_ledger
node_ledger -->|"reads encrypted data"| node_vault
node_ledger -->|"reads tables"| node_database
node_transactions -->|"validates input"| node_transactionlogic
node_transactions -->|"mutates vault data"| node_vault
node_transactions -->|"writes records"| node_database
node_transactions -->|"gets cycle month"| node_date
node_transactions -->|"validates amounts"| node_money
node_budgetsrepo -.->|"stores budgets"| node_database
node_walletrepo -.->|"stores wallets"| node_database
node_securityrepo -->|"stores security"| node_database
node_securityrepo -->|"uses vault"| node_vault
node_vault -->|"stores ciphertext"| node_database

click node_entry "https://github.com/losshye/catatku/blob/main/src/main.tsx"
click node_shell "https://github.com/losshye/catatku/blob/main/src/App.tsx"
click node_home "https://github.com/losshye/catatku/blob/main/src/screens/HomeScreen.tsx"
click node_input "https://github.com/losshye/catatku/blob/main/src/screens/InputScreen.tsx"
click node_budget "https://github.com/losshye/catatku/blob/main/src/screens/BudgetScreen.tsx"
click node_history "https://github.com/losshye/catatku/blob/main/src/screens/HistoryScreen.tsx"
click node_reports "https://github.com/losshye/catatku/blob/main/src/screens/ReportScreen.tsx"
click node_wallets "https://github.com/losshye/catatku/blob/main/src/components/WalletSheet.tsx"
click node_categories "https://github.com/losshye/catatku/blob/main/src/components/CategorySheet.tsx"
click node_receipt "https://github.com/losshye/catatku/blob/main/src/components/ReceiptScanSheet.tsx"
click node_settings "https://github.com/losshye/catatku/blob/main/src/components/SettingsSheet.tsx"
click node_ledgerhook "https://github.com/losshye/catatku/blob/main/src/hooks/useLedger.ts"
click node_ledger "https://github.com/losshye/catatku/blob/main/src/db/ledger.ts"
click node_database "https://github.com/losshye/catatku/blob/main/src/db/database.ts"
click node_transactions "https://github.com/losshye/catatku/blob/main/src/db/transactions.repo.ts"
click node_budgetsrepo "https://github.com/losshye/catatku/blob/main/src/db/budgets.repo.ts"
click node_walletrepo "https://github.com/losshye/catatku/blob/main/src/db/wallets.repo.ts"
click node_securityrepo "https://github.com/losshye/catatku/blob/main/src/db/security.repo.ts"
click node_vault "https://github.com/losshye/catatku/blob/main/src/db/vault.ts"
click node_export "https://github.com/losshye/catatku/blob/main/src/domain/export.ts"
click node_sharedpack "https://github.com/losshye/catatku/blob/main/src/domain/sharedPack.ts"
click node_transactionlogic "https://github.com/losshye/catatku/blob/main/src/domain/transaction.ts"
click node_money "https://github.com/losshye/catatku/blob/main/src/domain/money.ts"
click node_date "https://github.com/losshye/catatku/blob/main/src/domain/date.ts"
click node_securityui "https://github.com/losshye/catatku/blob/main/src/components/PinLockScreen.tsx"

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_entry,node_shell,node_user toneBlue
class node_home,node_input,node_budget,node_history,node_reports,node_wallets,node_categories,node_receipt,node_settings toneAmber
class node_ledgerhook,node_ledger,node_database,node_transactions,node_budgetsrepo,node_walletrepo toneMint
class node_transactionlogic,node_money,node_date toneRose
class node_securityrepo,node_vault,node_export,node_sharedpack,node_securityui toneIndigo
```

## Components

### App shell

- [React entry](https://github.com/losshye/catatku/blob/main/src/main.tsx): `src/main.tsx`
- [App shell](https://github.com/losshye/catatku/blob/main/src/App.tsx): `src/App.tsx`

### Finance workflows

- [Home screen](https://github.com/losshye/catatku/blob/main/src/screens/HomeScreen.tsx): `src/screens/HomeScreen.tsx`
- [Transaction input](https://github.com/losshye/catatku/blob/main/src/screens/InputScreen.tsx): `src/screens/InputScreen.tsx`
- [Budgets and goals](https://github.com/losshye/catatku/blob/main/src/screens/BudgetScreen.tsx): `src/screens/BudgetScreen.tsx`
- [History and editing](https://github.com/losshye/catatku/blob/main/src/screens/HistoryScreen.tsx): `src/screens/HistoryScreen.tsx`
- [Reports](https://github.com/losshye/catatku/blob/main/src/screens/ReportScreen.tsx): `src/screens/ReportScreen.tsx`
- [Wallet management](https://github.com/losshye/catatku/blob/main/src/components/WalletSheet.tsx): `src/components/WalletSheet.tsx`
- [Category management](https://github.com/losshye/catatku/blob/main/src/components/CategorySheet.tsx): `src/components/CategorySheet.tsx`
- [Receipt scanning](https://github.com/losshye/catatku/blob/main/src/components/ReceiptScanSheet.tsx): `src/components/ReceiptScanSheet.tsx`
- [Settings and sharing](https://github.com/losshye/catatku/blob/main/src/components/SettingsSheet.tsx): `src/components/SettingsSheet.tsx`

### Local data

- [Reactive ledger hook](https://github.com/losshye/catatku/blob/main/src/hooks/useLedger.ts): `src/hooks/useLedger.ts`
- [Ledger read model](https://github.com/losshye/catatku/blob/main/src/db/ledger.ts): `src/db/ledger.ts`
- [IndexedDB schema](https://github.com/losshye/catatku/blob/main/src/db/database.ts): `src/db/database.ts`
- [Transaction repository](https://github.com/losshye/catatku/blob/main/src/db/transactions.repo.ts): `src/db/transactions.repo.ts`
- [Budget repository](https://github.com/losshye/catatku/blob/main/src/db/budgets.repo.ts): `src/db/budgets.repo.ts`
- [Wallet repository](https://github.com/losshye/catatku/blob/main/src/db/wallets.repo.ts): `src/db/wallets.repo.ts`

### Domain logic

- [Transaction rules](https://github.com/losshye/catatku/blob/main/src/domain/transaction.ts): `src/domain/transaction.ts`
- [Rupiah arithmetic](https://github.com/losshye/catatku/blob/main/src/domain/money.ts): `src/domain/money.ts`
- [Local date cycles](https://github.com/losshye/catatku/blob/main/src/domain/date.ts): `src/domain/date.ts`

### Security and portability

- [Security repository](https://github.com/losshye/catatku/blob/main/src/db/security.repo.ts): `src/db/security.repo.ts`
- [Encrypted vault](https://github.com/losshye/catatku/blob/main/src/db/vault.ts): `src/db/vault.ts`
- [Backup and export](https://github.com/losshye/catatku/blob/main/src/domain/export.ts): `src/domain/export.ts`
- [Shared wallet packs](https://github.com/losshye/catatku/blob/main/src/domain/sharedPack.ts): `src/domain/sharedPack.ts`
- [PIN lock screen](https://github.com/losshye/catatku/blob/main/src/components/PinLockScreen.tsx): `src/components/PinLockScreen.tsx`

### Other components

- **User**

## Connections

- User → React entry: uses (evidence: `README.md`)
- React entry → App shell: mounts (evidence: `src/main.tsx`)
- App shell → Home screen: routes (evidence: `src/App.tsx`)
- App shell → Transaction input: routes (evidence: `src/App.tsx`)
- App shell → Budgets and goals: routes (evidence: `src/App.tsx`)
- App shell → History and editing: routes (evidence: `src/App.tsx`)
- App shell → Reports: routes (evidence: `src/App.tsx`)
- App shell → Security repository: loads PIN (evidence: `src/App.tsx`)
- App shell → Encrypted vault: checks vault (evidence: `src/App.tsx`)
- App shell → PIN lock screen: locks app (evidence: `src/App.tsx`)
- Home screen → Reactive ledger hook: reads snapshot (evidence: `src/screens/HomeScreen.tsx`)
- Transaction input → Transaction repository: saves transaction (evidence: `src/screens/InputScreen.tsx`)
- Transaction input → Reactive ledger hook: reads snapshot (evidence: `src/screens/InputScreen.tsx`)
- Transaction input → Category management: opens picker (evidence: `src/screens/InputScreen.tsx`)
- Transaction input → Receipt scanning: opens scanner (evidence: `src/screens/InputScreen.tsx`)
- Budgets and goals → Budget repository: upserts budget (evidence: `src/screens/BudgetScreen.tsx`)
- Budgets and goals → Reactive ledger hook: reads snapshot (evidence: `src/screens/BudgetScreen.tsx`)
- History and editing → Reactive ledger hook: reads snapshot (evidence: `src/screens/HistoryScreen.tsx`)
- History and editing → Transaction repository: edits transactions (evidence: `src/screens/HistoryScreen.tsx`)
- Reports → Reactive ledger hook: reads snapshot (evidence: `src/screens/ReportScreen.tsx`)
- Home screen → Wallet management: opens wallets (evidence: `src/screens/HomeScreen.tsx`)
- Settings and sharing → Backup and export: serializes backup (evidence: `src/components/SettingsSheet.tsx`)
- Settings and sharing → Shared wallet packs: parses pack (evidence: `src/components/SettingsSheet.tsx`)
- Reactive ledger hook → Ledger read model: loads snapshot (evidence: `src/hooks/useLedger.ts`)
- Ledger read model → Encrypted vault: reads encrypted data (evidence: `src/db/ledger.ts`)
- Ledger read model → IndexedDB schema: reads tables (evidence: `src/db/ledger.ts`)
- Transaction repository → Transaction rules: validates input (evidence: `src/db/transactions.repo.ts`)
- Transaction repository → Encrypted vault: mutates vault data (evidence: `src/db/transactions.repo.ts`)
- Transaction repository → IndexedDB schema: writes records (evidence: `src/db/transactions.repo.ts`)
- Transaction repository → Local date cycles: gets cycle month (evidence: `src/db/transactions.repo.ts`)
- Transaction repository → Rupiah arithmetic: validates amounts (evidence: `src/db/transactions.repo.ts`)
- Budget repository → IndexedDB schema: stores budgets (evidence: `src/db/budgets.repo.ts`)
- Wallet repository → IndexedDB schema: stores wallets
- Security repository → IndexedDB schema: stores security (evidence: `src/db/security.repo.ts`)
- Security repository → Encrypted vault: uses vault (evidence: `src/db/security.repo.ts`)
- Encrypted vault → IndexedDB schema: stores ciphertext (evidence: `src/db/vault.ts`)
