# joydeepdas-01/bahikhata architecture

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

- Interactive diagram: https://gitdiagram.com/joydeepdas-01/bahikhata
- Repository: https://github.com/joydeepdas-01/bahikhata

## Overview

BahiKhata is an offline-first customer credit-ledger app for shop owners, available on web and Android. The main workflow is adding customers (individually or in bulk), tracking outstanding and paid balances, then preparing multilingual payment reminders that open in WhatsApp. Settings also provide appearance and reminder preferences, CSV backup/import, and safe local-data reset. The graph reflects documented capabilities where source excerpts are unavailable; those subsystem links are omitted when their wiring is not established by the sampled code.

Main entry points: [`src/App.tsx`](https://github.com/joydeepdas-01/bahikhata/blob/main/src/App.tsx) (App shell), [`src/components/WhatsAppPreview.tsx`](https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/WhatsAppPreview.tsx) (Reminder composer), [`src/hooks/useCustomers.ts`](https://github.com/joydeepdas-01/bahikhata/blob/main/src/hooks/useCustomers.ts) (Ledger state), [`src/components/SettingsModal.tsx`](https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/SettingsModal.tsx) (Settings panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App workflow"]
  node_app["App shell<br/>[App.tsx]"]
  node_customer_ui["Customer screens<br/>[CustomerList.tsx]"]
  node_customer_form["Customer form<br/>[CustomerForm.tsx]"]
  node_bulk_sheet["Bulk add sheet<br/>[BulkPasteSheet.tsx]"]
end

subgraph group_ledger["Ledger and storage"]
  node_ledger_hook["Ledger state<br/>[useCustomers.ts]"]
  node_customer_model["Customer model<br/>[customer.ts]"]
  node_date_logic["Due-date logic<br/>[dateClassifier.ts]"]
  node_repository["Customer repository"]
  node_indexeddb[("IndexedDB ledger")]
end

subgraph group_reminders["Reminder workflow"]
  node_whatsapp_preview["Reminder composer"]
  node_templates["Message templates<br/>[templates.ts]"]
  node_amount_format["Currency formatting<br/>[amountFormatter.ts]"]
end

subgraph group_settings["Settings and import"]
  node_settings_ui["Settings panel<br/>[SettingsModal.tsx]"]
  node_display_context["Display preferences"]
  node_browser_storage[("Browser local storage")]
  node_csv_helper["CSV import/export<br/>[csvHelper.ts]"]
  node_tsv_helper["TSV parsing<br/>[tsvHelper.ts]"]
end

subgraph group_platform["Runtime platforms"]
  node_android_activity["Android bridge<br/>[MainActivity.java]"]
  node_capacitor_app["Capacitor app API"]
end

node_owner(("Shop owner"))
node_whatsapp["WhatsApp"]

node_owner -->|"uses"| node_app
node_app -->|"loads ledger state"| node_ledger_hook
node_app -->|"renders"| node_customer_ui
node_app -->|"opens form"| node_customer_form
node_app -->|"opens bulk add"| node_bulk_sheet
node_app -->|"opens settings"| node_settings_ui
node_app -->|"opens composer"| node_whatsapp_preview
node_ledger_hook -->|"reads and writes"| node_repository
node_repository -->|"reads and writes"| node_indexeddb
node_ledger_hook -->|"uses types"| node_customer_model
node_ledger_hook -->|"classifies due dates"| node_date_logic
node_customer_ui -->|"invokes ledger actions"| node_app
node_customer_form -->|"submits customer"| node_app
node_bulk_sheet -->|"submits customers"| node_app
node_app -->|"updates reminder time"| node_ledger_hook
node_whatsapp_preview -->|"parses message"| node_templates
node_whatsapp_preview -->|"formats amount"| node_amount_format
node_whatsapp_preview -->|"formats due date"| node_date_logic
node_whatsapp_preview -->|"reads reminder settings"| node_display_context
node_whatsapp_preview -->|"opens message link"| node_whatsapp
node_settings_ui -->|"imports and clears data"| node_ledger_hook
node_settings_ui -->|"imports and exports CSV"| node_csv_helper
node_settings_ui -->|"previews templates"| node_templates
node_settings_ui -->|"updates preferences"| node_display_context
node_display_context -->|"persists preferences"| node_browser_storage
node_bulk_sheet -.->|"parses pasted rows"| node_tsv_helper
node_app -->|"handles native back"| node_capacitor_app
node_capacitor_app -.->|"uses bridge"| node_android_activity

click node_app "https://github.com/joydeepdas-01/bahikhata/blob/main/src/App.tsx"
click node_customer_ui "https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/CustomerList.tsx"
click node_customer_form "https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/CustomerForm.tsx"
click node_bulk_sheet "https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/BulkPasteSheet.tsx"
click node_ledger_hook "https://github.com/joydeepdas-01/bahikhata/blob/main/src/hooks/useCustomers.ts"
click node_customer_model "https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/customer.ts"
click node_date_logic "https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/dateClassifier.ts"
click node_repository "https://github.com/joydeepdas-01/bahikhata/blob/main/src/infrastructure/CustomerRepository.ts"
click node_whatsapp_preview "https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/WhatsAppPreview.tsx"
click node_templates "https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/templates.ts"
click node_amount_format "https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/amountFormatter.ts"
click node_settings_ui "https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/SettingsModal.tsx"
click node_display_context "https://github.com/joydeepdas-01/bahikhata/blob/main/src/context/DisplaySettingsContext.tsx"
click node_csv_helper "https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/csvHelper.ts"
click node_tsv_helper "https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/tsvHelper.ts"
click node_android_activity "https://github.com/joydeepdas-01/bahikhata/blob/main/android/app/src/main/java/com/bahikhata/app/MainActivity.java"

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_app,node_customer_ui,node_customer_form,node_bulk_sheet toneBlue
class node_ledger_hook,node_customer_model,node_date_logic,node_repository,node_indexeddb toneAmber
class node_whatsapp_preview,node_templates,node_amount_format toneMint
class node_settings_ui,node_display_context,node_browser_storage,node_csv_helper,node_tsv_helper toneRose
class node_android_activity,node_capacitor_app,node_owner,node_whatsapp toneIndigo
```

## Components

### App workflow

- [App shell](https://github.com/joydeepdas-01/bahikhata/blob/main/src/App.tsx): `src/App.tsx`
- [Customer screens](https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/CustomerList.tsx): `src/components/CustomerList.tsx`
- [Customer form](https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/CustomerForm.tsx): `src/components/CustomerForm.tsx`
- [Bulk add sheet](https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/BulkPasteSheet.tsx): `src/components/BulkPasteSheet.tsx`

### Ledger and storage

- [Ledger state](https://github.com/joydeepdas-01/bahikhata/blob/main/src/hooks/useCustomers.ts): `src/hooks/useCustomers.ts`
- [Customer model](https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/customer.ts): `src/domain/customer.ts`
- [Due-date logic](https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/dateClassifier.ts): `src/domain/dateClassifier.ts`
- [Customer repository](https://github.com/joydeepdas-01/bahikhata/blob/main/src/infrastructure/CustomerRepository.ts): `src/infrastructure/CustomerRepository.ts`
- **IndexedDB ledger**

### Reminder workflow

- [Reminder composer](https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/WhatsAppPreview.tsx): `src/components/WhatsAppPreview.tsx`
- [Message templates](https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/templates.ts): `src/domain/templates.ts`
- [Currency formatting](https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/amountFormatter.ts): `src/domain/amountFormatter.ts`

### Settings and import

- [Settings panel](https://github.com/joydeepdas-01/bahikhata/blob/main/src/components/SettingsModal.tsx): `src/components/SettingsModal.tsx`
- [Display preferences](https://github.com/joydeepdas-01/bahikhata/blob/main/src/context/DisplaySettingsContext.tsx): `src/context/DisplaySettingsContext.tsx`
- **Browser local storage**
- [CSV import/export](https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/csvHelper.ts): `src/domain/csvHelper.ts`
- [TSV parsing](https://github.com/joydeepdas-01/bahikhata/blob/main/src/domain/tsvHelper.ts): `src/domain/tsvHelper.ts`

### Runtime platforms

- [Android bridge](https://github.com/joydeepdas-01/bahikhata/blob/main/android/app/src/main/java/com/bahikhata/app/MainActivity.java): `android/app/src/main/java/com/bahikhata/app/MainActivity.java`
- **Capacitor app API**

### Other components

- **Shop owner**
- **WhatsApp**

## Connections

- Shop owner → App shell: uses
- App shell → Ledger state: loads ledger state
- App shell → Customer screens: renders
- App shell → Customer form: opens form
- App shell → Bulk add sheet: opens bulk add
- App shell → Settings panel: opens settings
- App shell → Reminder composer: opens composer
- Ledger state → Customer repository: reads and writes
- Customer repository → IndexedDB ledger: reads and writes
- Ledger state → Customer model: uses types
- Ledger state → Due-date logic: classifies due dates
- Customer screens → App shell: invokes ledger actions
- Customer form → App shell: submits customer
- Bulk add sheet → App shell: submits customers
- App shell → Ledger state: updates reminder time
- Reminder composer → Message templates: parses message
- Reminder composer → Currency formatting: formats amount
- Reminder composer → Due-date logic: formats due date
- Reminder composer → Display preferences: reads reminder settings
- Reminder composer → WhatsApp: opens message link
- Settings panel → Ledger state: imports and clears data
- Settings panel → CSV import/export: imports and exports CSV
- Settings panel → Message templates: previews templates
- Settings panel → Display preferences: updates preferences
- Display preferences → Browser local storage: persists preferences
- Bulk add sheet → TSV parsing: parses pasted rows
- App shell → Capacitor app API: handles native back
- Capacitor app API → Android bridge: uses bridge
