# iqbalussain/iqbook architecture

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

- Interactive diagram: https://gitdiagram.com/iqbalussain/iqbook
- Repository: https://github.com/iqbalussain/iqbook

## Overview

Iqbook is an invoice and accounting application with a React interface and an Electron desktop mode. Users manage parties, create sales and purchase documents, record payments and vouchers, and review statements and reports. App.tsx routes users into those workflows; AppContext coordinates business state and accounting postings, with local storage and an optional LAN server path. The README documents backup/restore and offline desktop use. Some subsystems are represented by their known directory paths because their source was not sampled; the graph avoids inferring their internal wiring.

Main entry points: [`src/App.tsx`](https://github.com/iqbalussain/iqbook/blob/main/src/App.tsx) (App routing), [`src/contexts/AppContext.tsx`](https://github.com/iqbalussain/iqbook/blob/main/src/contexts/AppContext.tsx) (Business state), [`src/hooks/useRemoteCollection.ts`](https://github.com/iqbalussain/iqbook/blob/main/src/hooks/useRemoteCollection.ts) (Remote collection sync), [`src/lib/apiClient.ts`](https://github.com/iqbalussain/iqbook/blob/main/src/lib/apiClient.ts) (LAN API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application shell"]
  node_routes["App routing<br/>[App.tsx]"]
  node_layout["App layout<br/>[AppLayout.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_operations["Business operations"]
  node_parties["Party management<br/>[ClientsList.tsx]"]
  node_sales["Sales documents<br/>[InvoiceForm.tsx]"]
  node_purchases["Purchase invoices"]
  node_payments["Payments and receipts"]
  node_quotations["Quotations<br/>[QuotationForm.tsx]"]
end

subgraph group_accounting["Accounting and reports"]
  node_vouchers["Voucher workflows"]
  node_chart["Chart of accounts"]
  node_reports["Financial reports"]
  node_statements["Account statements"]
end

subgraph group_state["State and integrations"]
  node_context["Business state<br/>[AppContext.tsx]"]
  node_posting["Posting engine<br/>[postingEngine.ts]"]
  node_accountinglib["Accounting calculations<br/>[accounting.ts]"]
  node_localstorage[("Local persistence<br/>[useLocalStorage.ts]")]
  node_remotehook["Remote collection sync"]
  node_apiclient["LAN API client<br/>[apiClient.ts]"]
  node_lanserver["LAN server<br/>[server.js]"]
end

subgraph group_desktop["Desktop and support"]
  node_backup["Backup and restore<br/>[BackupRestore.tsx]"]
  node_electron["Electron main process<br/>[main.cjs]"]
  node_mcp["MCP tools"]
  node_supabasefn["MCP function<br/>[index.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_routes
node_routes -->|"renders"| node_layout
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_sales
node_routes -->|"routes to"| node_payments
node_routes -->|"routes to"| node_quotations
node_routes -->|"provides state"| node_context
node_context -->|"persists state"| node_localstorage
node_context -->|"uses sync"| node_remotehook
node_remotehook -->|"calls"| node_apiclient
node_apiclient -->|"HTTP requests"| node_lanserver
node_context -->|"builds postings"| node_posting
node_context -->|"validates postings"| node_accountinglib
node_user -->|"manages parties"| node_parties
node_user -->|"tracks purchases"| node_purchases
node_user -->|"records vouchers"| node_vouchers
node_user -->|"manages accounts"| node_chart
node_user -.->|"reviews results"| node_reports
node_user -.->|"reviews balances"| node_statements
node_user -->|"backs up data"| node_backup

click node_routes "https://github.com/iqbalussain/iqbook/blob/main/src/App.tsx"
click node_layout "https://github.com/iqbalussain/iqbook/blob/main/src/components/layout/AppLayout.tsx"
click node_dashboard "https://github.com/iqbalussain/iqbook/blob/main/src/pages/Dashboard.tsx"
click node_parties "https://github.com/iqbalussain/iqbook/blob/main/src/pages/ClientsList.tsx"
click node_sales "https://github.com/iqbalussain/iqbook/blob/main/src/pages/InvoiceForm.tsx"
click node_purchases "https://github.com/iqbalussain/iqbook/blob/main/src/pages/PurchaseInvoiceForm.tsx"
click node_payments "https://github.com/iqbalussain/iqbook/blob/main/src/pages/PaymentsReceipts.tsx"
click node_quotations "https://github.com/iqbalussain/iqbook/blob/main/src/pages/QuotationForm.tsx"
click node_vouchers "https://github.com/iqbalussain/iqbook/blob/main/src/pages/VoucherDashboard.tsx"
click node_chart "https://github.com/iqbalussain/iqbook/blob/main/src/pages/ChartOfAccounts.tsx"
click node_reports "https://github.com/iqbalussain/iqbook/tree/main/src/pages/reports"
click node_statements "https://github.com/iqbalussain/iqbook/blob/main/src/pages/ClientStatement.tsx"
click node_context "https://github.com/iqbalussain/iqbook/blob/main/src/contexts/AppContext.tsx"
click node_posting "https://github.com/iqbalussain/iqbook/blob/main/src/lib/postingEngine.ts"
click node_accountinglib "https://github.com/iqbalussain/iqbook/blob/main/src/lib/accounting.ts"
click node_localstorage "https://github.com/iqbalussain/iqbook/blob/main/src/hooks/useLocalStorage.ts"
click node_remotehook "https://github.com/iqbalussain/iqbook/blob/main/src/hooks/useRemoteCollection.ts"
click node_apiclient "https://github.com/iqbalussain/iqbook/blob/main/src/lib/apiClient.ts"
click node_lanserver "https://github.com/iqbalussain/iqbook/blob/main/server/server.js"
click node_backup "https://github.com/iqbalussain/iqbook/blob/main/src/components/BackupRestore.tsx"
click node_electron "https://github.com/iqbalussain/iqbook/blob/main/main.cjs"
click node_mcp "https://github.com/iqbalussain/iqbook/tree/main/src/lib/mcp/tools"
click node_supabasefn "https://github.com/iqbalussain/iqbook/blob/main/supabase/functions/mcp/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_routes,node_layout,node_dashboard,node_user toneBlue
class node_parties,node_sales,node_purchases,node_payments,node_quotations toneAmber
class node_vouchers,node_chart,node_reports,node_statements toneMint
class node_context,node_posting,node_accountinglib,node_localstorage,node_remotehook,node_apiclient,node_lanserver toneRose
class node_backup,node_electron,node_mcp,node_supabasefn toneIndigo
```

## Components

### Application shell

- [App routing](https://github.com/iqbalussain/iqbook/blob/main/src/App.tsx): `src/App.tsx`
- [App layout](https://github.com/iqbalussain/iqbook/blob/main/src/components/layout/AppLayout.tsx): `src/components/layout/AppLayout.tsx`
- [Dashboard](https://github.com/iqbalussain/iqbook/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`

### Business operations

- [Party management](https://github.com/iqbalussain/iqbook/blob/main/src/pages/ClientsList.tsx): `src/pages/ClientsList.tsx`
- [Sales documents](https://github.com/iqbalussain/iqbook/blob/main/src/pages/InvoiceForm.tsx): `src/pages/InvoiceForm.tsx`
- [Purchase invoices](https://github.com/iqbalussain/iqbook/blob/main/src/pages/PurchaseInvoiceForm.tsx): `src/pages/PurchaseInvoiceForm.tsx`
- [Payments and receipts](https://github.com/iqbalussain/iqbook/blob/main/src/pages/PaymentsReceipts.tsx): `src/pages/PaymentsReceipts.tsx`
- [Quotations](https://github.com/iqbalussain/iqbook/blob/main/src/pages/QuotationForm.tsx): `src/pages/QuotationForm.tsx`

### Accounting and reports

- [Voucher workflows](https://github.com/iqbalussain/iqbook/blob/main/src/pages/VoucherDashboard.tsx): `src/pages/VoucherDashboard.tsx`
- [Chart of accounts](https://github.com/iqbalussain/iqbook/blob/main/src/pages/ChartOfAccounts.tsx): `src/pages/ChartOfAccounts.tsx`
- [Financial reports](https://github.com/iqbalussain/iqbook/tree/main/src/pages/reports): `src/pages/reports`
- [Account statements](https://github.com/iqbalussain/iqbook/blob/main/src/pages/ClientStatement.tsx): `src/pages/ClientStatement.tsx`

### State and integrations

- [Business state](https://github.com/iqbalussain/iqbook/blob/main/src/contexts/AppContext.tsx): `src/contexts/AppContext.tsx`
- [Posting engine](https://github.com/iqbalussain/iqbook/blob/main/src/lib/postingEngine.ts): `src/lib/postingEngine.ts`
- [Accounting calculations](https://github.com/iqbalussain/iqbook/blob/main/src/lib/accounting.ts): `src/lib/accounting.ts`
- [Local persistence](https://github.com/iqbalussain/iqbook/blob/main/src/hooks/useLocalStorage.ts): `src/hooks/useLocalStorage.ts`
- [Remote collection sync](https://github.com/iqbalussain/iqbook/blob/main/src/hooks/useRemoteCollection.ts): `src/hooks/useRemoteCollection.ts`
- [LAN API client](https://github.com/iqbalussain/iqbook/blob/main/src/lib/apiClient.ts): `src/lib/apiClient.ts`
- [LAN server](https://github.com/iqbalussain/iqbook/blob/main/server/server.js): `server/server.js`

### Desktop and support

- [Backup and restore](https://github.com/iqbalussain/iqbook/blob/main/src/components/BackupRestore.tsx): `src/components/BackupRestore.tsx`
- [Electron main process](https://github.com/iqbalussain/iqbook/blob/main/main.cjs): `main.cjs`
- [MCP tools](https://github.com/iqbalussain/iqbook/tree/main/src/lib/mcp/tools): `src/lib/mcp/tools`
- [MCP function](https://github.com/iqbalussain/iqbook/blob/main/supabase/functions/mcp/index.ts): `supabase/functions/mcp/index.ts`

### Other components

- **User**

## Connections

- User → App routing: uses (evidence: `src/App.tsx`)
- App routing → App layout: renders (evidence: `src/App.tsx`)
- App routing → Dashboard: routes to (evidence: `src/App.tsx`)
- App routing → Sales documents: routes to (evidence: `src/App.tsx`)
- App routing → Payments and receipts: routes to (evidence: `src/App.tsx`)
- App routing → Quotations: routes to (evidence: `src/App.tsx`)
- App routing → Business state: provides state (evidence: `src/App.tsx`)
- Business state → Local persistence: persists state (evidence: `src/contexts/AppContext.tsx`)
- Business state → Remote collection sync: uses sync (evidence: `src/contexts/AppContext.tsx`)
- Remote collection sync → LAN API client: calls (evidence: `src/hooks/useRemoteCollection.ts`)
- LAN API client → LAN server: HTTP requests (evidence: `src/lib/apiClient.ts`)
- Business state → Posting engine: builds postings (evidence: `src/contexts/AppContext.tsx`)
- Business state → Accounting calculations: validates postings (evidence: `src/contexts/AppContext.tsx`)
- User → Party management: manages parties
- User → Purchase invoices: tracks purchases
- User → Voucher workflows: records vouchers
- User → Chart of accounts: manages accounts
- User → Financial reports: reviews results
- User → Account statements: reviews balances
- User → Backup and restore: backs up data
