# krishna199766-arch/kannakuai architecture

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

- Interactive diagram: https://gitdiagram.com/krishna199766-arch/kannakuai
- Repository: https://github.com/krishna199766-arch/kannakuai

## Overview

Kannaku AI is an Indian GST accounting app. A user creates or selects a business, enters vouchers or submits bills/voice commands, reviews drafts, and confirms posting through the deterministic ledger engine; reports and registers expose the resulting books. The graph also preserves authentication, masters, inventory, and GST capabilities. Several subsystem links are documented or visible in imports, but unsampled route and screen internals limit certainty about some runtime connections.

Main entry points: [`server/src/api/routes.ts`](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/api/routes.ts) (API routes), [`server/src/ledger/post.ts`](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/post.ts) (Voucher posting), [`web/src/api.ts`](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/api.ts) (HTTP client), [`server/src/db/client.ts`](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/db/client.ts) (PGlite database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_webapp["Accounting screens<br/>[App.tsx]"]
  node_webstate["App state<br/>[state.tsx]"]
  node_webapi["HTTP client<br/>[api.ts]"]
  node_entry["Voucher entry<br/>[VoucherEntry.tsx]"]
  node_review["Bill review<br/>[Review.tsx]"]
  node_voiceui["Voice panel<br/>[Voice.tsx]"]
  node_reportsui["Report screens<br/>[Reports.tsx]"]
  node_authui["Sign-in screens<br/>[Auth.tsx]"]
end

subgraph group_server["Accounting server"]
  node_routes["API routes<br/>[routes.ts]"]
  node_authroutes["Auth routes<br/>[routes.ts]"]
  node_auth["Accounts and sessions<br/>[auth.ts]"]
end

subgraph group_ai["AI workflows"]
  node_documents["Bill ingestion<br/>[documents.ts]"]
  node_resolver["Name matching<br/>[resolver.ts]"]
  node_voice["Voice intent workflow<br/>[engine.ts]"]
end

subgraph group_books["Books and tax"]
  node_posting["Voucher posting<br/>[post.ts]"]
  node_plans["Posting plans<br/>[plan.ts]"]
  node_context["Ledger context<br/>[context.ts]"]
  node_masters["Business masters<br/>[masters.ts]"]
  node_tax["India GST engine<br/>[india-gst.ts]"]
  node_store[("PGlite database<br/>[client.ts]")]
end

subgraph group_insights["Reports and inventory"]
  node_stock["Stock valuation<br/>[valuation.ts]"]
  node_stockops["Stock operations<br/>[stock.ts]"]
  node_financials["Financial reports<br/>[financials.ts]"]
  node_registers["Registers and ageing<br/>[registers.ts]"]
  node_gstreports["GST reports<br/>[gst.ts]"]
  node_dashboard["Dashboard<br/>[dashboard.ts]"]
end

node_user(("Business user"))
node_claude["Anthropic API"]

node_user -->|"uses"| node_webapp
node_webapp -->|"reads state"| node_webstate
node_webapp -->|"shows"| node_entry
node_webapp -->|"shows"| node_reportsui
node_webapp -->|"opens"| node_voiceui
node_webstate -->|"calls"| node_webapi
node_entry -->|"submits vouchers"| node_webapi
node_review -->|"submits review"| node_webapi
node_voiceui -->|"sends commands"| node_webapi
node_authui -->|"calls"| node_webapi
node_webapi -.->|"requests API"| node_routes
node_routes -->|"registers routes"| node_authroutes
node_authroutes -->|"delegates to"| node_auth
node_auth -->|"reads and writes"| node_store
node_routes -->|"invokes posting"| node_posting
node_routes -->|"ingests bills"| node_documents
node_documents -->|"matches names"| node_resolver
node_documents -->|"posts confirmed bill"| node_posting
node_documents -->|"recomputes tax"| node_tax
node_routes -->|"routes voice"| node_voice
node_voice -->|"finds candidates"| node_resolver
node_voice -->|"previews and posts"| node_posting
node_voice -->|"queries ageing"| node_registers
node_voice -->|"requests intent"| node_claude
node_documents -.->|"extracts bill"| node_claude
node_posting -->|"builds plan"| node_plans
node_posting -->|"loads context"| node_context
node_posting -->|"checks stock"| node_stockops
node_posting -->|"writes ledger"| node_store
node_context -->|"loads company data"| node_store
node_routes -->|"serves masters"| node_masters
node_routes -->|"serves dashboard"| node_dashboard
node_routes -->|"serves reports"| node_financials
node_routes -->|"serves registers"| node_registers
node_routes -->|"serves GST reports"| node_gstreports
node_routes -->|"serves stock"| node_stockops
node_financials -->|"queries books"| node_store
node_registers -->|"queries books"| node_store
node_stock -.->|"values inventory"| node_store
node_reportsui -.->|"requests reports"| node_webapi

click node_webapp "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/App.tsx"
click node_webstate "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/state.tsx"
click node_webapi "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/api.ts"
click node_entry "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/VoucherEntry.tsx"
click node_review "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/Review.tsx"
click node_voiceui "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/components/Voice.tsx"
click node_reportsui "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/Reports.tsx"
click node_authui "https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/Auth.tsx"
click node_routes "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/api/routes.ts"
click node_authroutes "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/auth/routes.ts"
click node_auth "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/auth/auth.ts"
click node_documents "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ai/documents.ts"
click node_resolver "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ai/resolver.ts"
click node_voice "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ai/voice/engine.ts"
click node_posting "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/post.ts"
click node_plans "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/plan.ts"
click node_context "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/context.ts"
click node_masters "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/masters.ts"
click node_tax "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/tax/india-gst.ts"
click node_store "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/db/client.ts"
click node_stock "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/inventory/valuation.ts"
click node_stockops "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/inventory/stock.ts"
click node_financials "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/financials.ts"
click node_registers "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/registers.ts"
click node_gstreports "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/gst.ts"
click node_dashboard "https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/dashboard.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_webapp,node_webstate,node_webapi,node_entry,node_review,node_voiceui,node_reportsui,node_authui,node_user toneBlue
class node_routes,node_authroutes,node_auth toneAmber
class node_documents,node_resolver,node_voice,node_claude toneMint
class node_posting,node_plans,node_context,node_masters,node_tax,node_store toneRose
class node_stock,node_stockops,node_financials,node_registers,node_gstreports,node_dashboard toneIndigo
```

## Components

### Web app

- [Accounting screens](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [App state](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/state.tsx): `web/src/state.tsx`
- [HTTP client](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/api.ts): `web/src/api.ts`
- [Voucher entry](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/VoucherEntry.tsx): `web/src/screens/VoucherEntry.tsx`
- [Bill review](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/Review.tsx): `web/src/screens/Review.tsx`
- [Voice panel](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/components/Voice.tsx): `web/src/components/Voice.tsx`
- [Report screens](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/Reports.tsx): `web/src/screens/Reports.tsx`
- [Sign-in screens](https://github.com/krishna199766-arch/kannakuai/blob/main/web/src/screens/Auth.tsx): `web/src/screens/Auth.tsx`

### Accounting server

- [API routes](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/api/routes.ts): `server/src/api/routes.ts`
- [Auth routes](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/auth/routes.ts): `server/src/auth/routes.ts`
- [Accounts and sessions](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/auth/auth.ts): `server/src/auth/auth.ts`

### AI workflows

- [Bill ingestion](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ai/documents.ts): `server/src/ai/documents.ts`
- [Name matching](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ai/resolver.ts): `server/src/ai/resolver.ts`
- [Voice intent workflow](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ai/voice/engine.ts): `server/src/ai/voice/engine.ts`

### Books and tax

- [Voucher posting](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/post.ts): `server/src/ledger/post.ts`
- [Posting plans](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/plan.ts): `server/src/ledger/plan.ts`
- [Ledger context](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/context.ts): `server/src/ledger/context.ts`
- [Business masters](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/ledger/masters.ts): `server/src/ledger/masters.ts`
- [India GST engine](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/tax/india-gst.ts): `server/src/tax/india-gst.ts`
- [PGlite database](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/db/client.ts): `server/src/db/client.ts`

### Reports and inventory

- [Stock valuation](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/inventory/valuation.ts): `server/src/inventory/valuation.ts`
- [Stock operations](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/inventory/stock.ts): `server/src/inventory/stock.ts`
- [Financial reports](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/financials.ts): `server/src/reports/financials.ts`
- [Registers and ageing](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/registers.ts): `server/src/reports/registers.ts`
- [GST reports](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/gst.ts): `server/src/reports/gst.ts`
- [Dashboard](https://github.com/krishna199766-arch/kannakuai/blob/main/server/src/reports/dashboard.ts): `server/src/reports/dashboard.ts`

### Other components

- **Business user**
- **Anthropic API**

## Connections

- Business user → Accounting screens: uses (evidence: `README.md`)
- Accounting screens → App state: reads state (evidence: `web/src/App.tsx`)
- Accounting screens → Voucher entry: shows (evidence: `web/src/App.tsx`)
- Accounting screens → Report screens: shows (evidence: `web/src/App.tsx`)
- Accounting screens → Voice panel: opens (evidence: `web/src/App.tsx`)
- App state → HTTP client: calls (evidence: `web/src/state.tsx`)
- Voucher entry → HTTP client: submits vouchers (evidence: `web/src/screens/VoucherEntry.tsx`)
- Bill review → HTTP client: submits review (evidence: `web/src/screens/Review.tsx`)
- Voice panel → HTTP client: sends commands (evidence: `web/src/components/Voice.tsx`)
- Sign-in screens → HTTP client: calls (evidence: `web/src/screens/Auth.tsx`)
- HTTP client → API routes: requests API
- API routes → Auth routes: registers routes (evidence: `server/src/app.ts`)
- Auth routes → Accounts and sessions: delegates to (evidence: `server/src/auth/routes.ts`)
- Accounts and sessions → PGlite database: reads and writes (evidence: `server/src/auth/auth.ts`)
- API routes → Voucher posting: invokes posting (evidence: `server/src/api/routes.ts`)
- API routes → Bill ingestion: ingests bills (evidence: `server/src/api/routes.ts`)
- Bill ingestion → Name matching: matches names (evidence: `server/src/ai/documents.ts`)
- Bill ingestion → Voucher posting: posts confirmed bill (evidence: `server/src/ai/documents.ts`)
- Bill ingestion → India GST engine: recomputes tax (evidence: `README.md`)
- API routes → Voice intent workflow: routes voice (evidence: `server/src/api/routes.ts`)
- Voice intent workflow → Name matching: finds candidates (evidence: `server/src/ai/voice/engine.ts`)
- Voice intent workflow → Voucher posting: previews and posts (evidence: `server/src/ai/voice/engine.ts`)
- Voice intent workflow → Registers and ageing: queries ageing (evidence: `server/src/ai/voice/engine.ts`)
- Voice intent workflow → Anthropic API: requests intent (evidence: `server/src/ai/voice/engine.ts`)
- Bill ingestion → Anthropic API: extracts bill (evidence: `README.md`)
- Voucher posting → Posting plans: builds plan (evidence: `server/src/ledger/post.ts`)
- Voucher posting → Ledger context: loads context (evidence: `server/src/ledger/post.ts`)
- Voucher posting → Stock operations: checks stock (evidence: `server/src/ledger/post.ts`)
- Voucher posting → PGlite database: writes ledger (evidence: `README.md`)
- Ledger context → PGlite database: loads company data (evidence: `server/src/ledger/context.ts`)
- API routes → Business masters: serves masters (evidence: `server/src/api/routes.ts`)
- API routes → Dashboard: serves dashboard (evidence: `server/src/api/routes.ts`)
- API routes → Financial reports: serves reports (evidence: `server/src/api/routes.ts`)
- API routes → Registers and ageing: serves registers (evidence: `server/src/api/routes.ts`)
- API routes → GST reports: serves GST reports (evidence: `server/src/api/routes.ts`)
- API routes → Stock operations: serves stock (evidence: `server/src/api/routes.ts`)
- Financial reports → PGlite database: queries books (evidence: `server/src/reports/financials.ts`)
- Registers and ageing → PGlite database: queries books (evidence: `server/src/reports/registers.ts`)
- Stock valuation → PGlite database: values inventory
- Report screens → HTTP client: requests reports
