# namanyakeren/sakukeluarga architecture

> Architecture diagram of the GitHub repository namanyakeren/sakukeluarga, 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/namanyakeren/sakukeluarga
- Repository: https://github.com/namanyakeren/sakukeluarga

## Overview

Saku Keluarga is a family income-and-expense tracker whose main workflow is recording transactions through WhatsApp, storing them in PostgreSQL, and reviewing scoped balances and reports in the web dashboard. Separate flows cover wallets and transfers, electricity and household utilities, and administration such as member management, logs, backups, and WhatsApp connection status. The graph uses the README and indexed excerpts for relationships; unsampled subsystem wiring is not assumed beyond documented behavior.

Main entry points: [`apps/wa/src/messages.ts`](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/messages.ts) (Message handling), [`packages/db/src/services.ts`](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/services.ts) (Finance services), [`apps/wa/src/bot.ts`](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/bot.ts) (Bot connection), [`packages/db/src/electricity.ts`](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/electricity.ts) (Electricity records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_wa["WhatsApp bot"]
  node_bot["Bot connection<br/>[bot.ts]"]
  node_message_handler["Message handling<br/>[messages.ts]"]
  node_anti_ban["Send protection<br/>[anti-ban.ts]"]
  node_wa_electricity["Electricity input<br/>[electricity.ts]"]
  node_wa_utility["Utility input<br/>[utility.ts]"]
  node_wa_status["Bot status API<br/>[http.ts]"]
end

subgraph group_web["Web dashboard"]
  node_dashboard["Dashboard reports<br/>[page.tsx]"]
  node_transactions["Transaction views<br/>[page.tsx]"]
  node_wallets["Wallet views<br/>[page.tsx]"]
  node_reports["Reports and export<br/>[page.tsx]"]
  node_electricity_page["Electricity views<br/>[page.tsx]"]
  node_utility_page["Household utility views<br/>[page.tsx]"]
  node_web_actions["Web mutations<br/>[transactions.ts]"]
  node_web_queries["Scoped queries<br/>[queries.ts]"]
end

subgraph group_data["Finance data"]
  node_db_services["Finance services<br/>[services.ts]"]
  node_db_electricity["Electricity records<br/>[electricity.ts]"]
  node_db_utility_expense["Utility expenses<br/>[utility-expense.ts]"]
  node_db_client["Database client<br/>[client.ts]"]
end

subgraph group_shared["Shared domain logic"]
  node_parser["Message parser<br/>[parse.ts]"]
  node_money["Amount parsing<br/>[money.ts]"]
  node_dates["Date handling<br/>[dates.ts]"]
  node_electricity_logic["Electricity calculations<br/>[electricity.ts]"]
end

subgraph group_ops["Administration"]
  node_web_auth["Authentication<br/>[auth.ts]"]
  node_admin_tools["Admin tools<br/>[page.tsx]"]
  node_logs["Application logs<br/>[logs.ts]"]
  node_backups["Backup and restore<br/>[backup.ts]"]
end

node_family(("Family member"))
node_admin(("Family admin"))
node_whatsapp(("WhatsApp"))
node_postgres[("PostgreSQL")]

node_family -->|"sends entries"| node_whatsapp
node_whatsapp -->|"delivers messages"| node_bot
node_bot -->|"dispatches messages"| node_message_handler
node_message_handler -->|"parses entries"| node_parser
node_parser -->|"finds amounts"| node_money
node_parser -->|"resolves dates"| node_dates
node_message_handler -->|"records transactions"| node_db_services
node_message_handler -->|"routes commands"| node_wa_electricity
node_message_handler -->|"routes commands"| node_wa_utility
node_wa_electricity -->|"records purchase"| node_db_electricity
node_wa_utility -->|"records utility"| node_db_utility_expense
node_message_handler -->|"queues replies"| node_anti_ban
node_bot -->|"connects via Baileys"| node_whatsapp
node_db_services -->|"reads and writes"| node_postgres
node_db_electricity -->|"creates expense"| node_db_utility_expense
node_db_utility_expense -->|"records expense"| node_db_services
node_db_services -->|"uses client"| node_db_client
node_db_client -->|"connects"| node_postgres
node_admin -->|"signs in"| node_web_auth
node_family -->|"manages entries"| node_transactions
node_transactions -.->|"submits changes"| node_web_actions
node_web_actions -.->|"records changes"| node_db_services
node_dashboard -.->|"loads summaries"| node_web_queries
node_transactions -.->|"loads transactions"| node_web_queries
node_wallets -.->|"loads balances"| node_web_queries
node_reports -.->|"loads reports"| node_web_queries
node_reports -->|"exports CSV data"| node_postgres
node_electricity_page -.->|"manages records"| node_db_electricity
node_utility_page -.->|"manages records"| node_db_utility_expense
node_admin_tools -->|"shows connection status"| node_wa_status
node_admin_tools -.->|"manages backups"| node_backups
node_admin_tools -.->|"views logs"| node_logs
node_wa_status -->|"reports bot state"| node_bot
node_db_electricity -->|"checks readings"| node_electricity_logic

click node_bot "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/bot.ts"
click node_message_handler "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/messages.ts"
click node_anti_ban "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/anti-ban.ts"
click node_wa_electricity "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/electricity.ts"
click node_wa_utility "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/utility.ts"
click node_wa_status "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/http.ts"
click node_dashboard "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/dashboard/page.tsx"
click node_transactions "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/transactions/page.tsx"
click node_wallets "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/wallets/page.tsx"
click node_reports "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/reports/page.tsx"
click node_electricity_page "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/electricity/page.tsx"
click node_utility_page "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/utilities/page.tsx"
click node_web_actions "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/actions/transactions.ts"
click node_web_queries "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/queries.ts"
click node_web_auth "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/auth.ts"
click node_admin_tools "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/settings/page.tsx"
click node_logs "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/logs.ts"
click node_backups "https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/backup.ts"
click node_db_services "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/services.ts"
click node_db_electricity "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/electricity.ts"
click node_db_utility_expense "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/utility-expense.ts"
click node_db_client "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/client.ts"
click node_parser "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/parse.ts"
click node_money "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/money.ts"
click node_dates "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/dates.ts"
click node_electricity_logic "https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/electricity.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_bot,node_message_handler,node_anti_ban,node_wa_electricity,node_wa_utility,node_wa_status toneBlue
class node_dashboard,node_transactions,node_wallets,node_reports,node_electricity_page,node_utility_page,node_web_actions,node_web_queries,node_postgres toneAmber
class node_db_services,node_db_electricity,node_db_utility_expense,node_db_client toneMint
class node_parser,node_money,node_dates,node_electricity_logic toneRose
class node_web_auth,node_admin_tools,node_logs,node_backups,node_family,node_admin,node_whatsapp toneIndigo
```

## Components

### WhatsApp bot

- [Bot connection](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/bot.ts): `apps/wa/src/bot.ts`
- [Message handling](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/messages.ts): `apps/wa/src/messages.ts`
- [Send protection](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/anti-ban.ts): `apps/wa/src/anti-ban.ts`
- [Electricity input](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/electricity.ts): `apps/wa/src/electricity.ts`
- [Utility input](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/utility.ts): `apps/wa/src/utility.ts`
- [Bot status API](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/wa/src/http.ts): `apps/wa/src/http.ts`

### Web dashboard

- [Dashboard reports](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/dashboard/page.tsx): `apps/web/src/app/(app)/dashboard/page.tsx`
- [Transaction views](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/transactions/page.tsx): `apps/web/src/app/(app)/transactions/page.tsx`
- [Wallet views](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/wallets/page.tsx): `apps/web/src/app/(app)/wallets/page.tsx`
- [Reports and export](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/reports/page.tsx): `apps/web/src/app/(app)/reports/page.tsx`
- [Electricity views](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/electricity/page.tsx): `apps/web/src/app/(app)/electricity/page.tsx`
- [Household utility views](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/utilities/page.tsx): `apps/web/src/app/(app)/utilities/page.tsx`
- [Web mutations](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/actions/transactions.ts): `apps/web/src/lib/actions/transactions.ts`
- [Scoped queries](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/queries.ts): `apps/web/src/lib/queries.ts`

### Finance data

- [Finance services](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/services.ts): `packages/db/src/services.ts`
- [Electricity records](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/electricity.ts): `packages/db/src/electricity.ts`
- [Utility expenses](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/utility-expense.ts): `packages/db/src/utility-expense.ts`
- [Database client](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/db/src/client.ts): `packages/db/src/client.ts`

### Shared domain logic

- [Message parser](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/parse.ts): `packages/shared/src/parse.ts`
- [Amount parsing](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/money.ts): `packages/shared/src/money.ts`
- [Date handling](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/dates.ts): `packages/shared/src/dates.ts`
- [Electricity calculations](https://github.com/namanyakeren/sakukeluarga/blob/main/packages/shared/src/electricity.ts): `packages/shared/src/electricity.ts`

### Administration

- [Authentication](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/auth.ts): `apps/web/src/lib/auth.ts`
- [Admin tools](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/app/(app)/settings/page.tsx): `apps/web/src/app/(app)/settings/page.tsx`
- [Application logs](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/logs.ts): `apps/web/src/lib/logs.ts`
- [Backup and restore](https://github.com/namanyakeren/sakukeluarga/blob/main/apps/web/src/lib/backup.ts): `apps/web/src/lib/backup.ts`

### Other components

- **Family member**
- **Family admin**
- **WhatsApp**
- **PostgreSQL**

## Connections

- Family member → WhatsApp: sends entries (evidence: `README.md`)
- WhatsApp → Bot connection: delivers messages (evidence: `README.md`)
- Bot connection → Message handling: dispatches messages (evidence: `apps/wa/src/bot.ts`)
- Message handling → Message parser: parses entries (evidence: `apps/wa/src/messages.ts`)
- Message parser → Amount parsing: finds amounts (evidence: `packages/shared/src/parse.ts`)
- Message parser → Date handling: resolves dates (evidence: `packages/shared/src/parse.ts`)
- Message handling → Finance services: records transactions (evidence: `apps/wa/src/messages.ts`)
- Message handling → Electricity input: routes commands (evidence: `apps/wa/src/messages.ts`)
- Message handling → Utility input: routes commands (evidence: `apps/wa/src/messages.ts`)
- Electricity input → Electricity records: records purchase (evidence: `apps/wa/src/electricity.ts`)
- Utility input → Utility expenses: records utility (evidence: `apps/wa/src/utility.ts`)
- Message handling → Send protection: queues replies (evidence: `apps/wa/src/messages.ts`)
- Bot connection → WhatsApp: connects via Baileys (evidence: `apps/wa/src/bot.ts`)
- Finance services → PostgreSQL: reads and writes (evidence: `README.md`)
- Electricity records → Utility expenses: creates expense (evidence: `packages/db/src/electricity.ts`)
- Utility expenses → Finance services: records expense (evidence: `packages/db/src/utility-expense.ts`)
- Finance services → Database client: uses client (evidence: `packages/db/src/services.ts`)
- Database client → PostgreSQL: connects (evidence: `README.md`)
- Family admin → Authentication: signs in (evidence: `README.md`)
- Family member → Transaction views: manages entries (evidence: `README.md`)
- Transaction views → Web mutations: submits changes
- Web mutations → Finance services: records changes
- Dashboard reports → Scoped queries: loads summaries
- Transaction views → Scoped queries: loads transactions
- Wallet views → Scoped queries: loads balances
- Reports and export → Scoped queries: loads reports
- Reports and export → PostgreSQL: exports CSV data
- Electricity views → Electricity records: manages records
- Household utility views → Utility expenses: manages records
- Admin tools → Bot status API: shows connection status (evidence: `README.md`)
- Admin tools → Backup and restore: manages backups
- Admin tools → Application logs: views logs
- Bot status API → Bot connection: reports bot state (evidence: `README.md`)
- Electricity records → Electricity calculations: checks readings (evidence: `packages/db/src/electricity.ts`)
