# vashgehlot/ai-accountant---temporary architecture

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

- Interactive diagram: https://gitdiagram.com/vashgehlot/ai-accountant---temporary
- Repository: https://github.com/vashgehlot/ai-accountant---temporary

## Overview

Super Accountant turns uploaded or manually entered UK financial documents into reviewed client transactions and a double-entry trial balance. The main workflow is: users submit documents, background analysis extracts transactions, matching and validation resolve accounting details, and ledger operations save and present results. The README also documents client workspaces, duplicate detection, statement-balance checks, and Excel export. The graph combines those documented capabilities with source-index and excerpt evidence; unsampled route wiring is not inferred beyond the README.

Main entry points: [`server.py`](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/server.py) (HTTP routes), [`ledgersync/ledger.py`](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/ledger.py) (Client ledger operations), [`frontend/src/lib/api.ts`](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/lib/api.ts) (API client), [`ledgersync/pipeline.py`](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/pipeline.py) (Document pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Client workspace"]
  node_workspace["Client pages<br/>[page.tsx]"]
  node_upload_ui["Document uploads<br/>[AddDocuments.tsx]"]
  node_ledger_ui["Ledger review<br/>[ledger.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_clients_api["Client API calls<br/>[clients.ts]"]
end

subgraph group_api["API and jobs"]
  node_http_api["HTTP routes<br/>[server.py]"]
  node_job_store["Background jobs<br/>[jobs.py]"]
end

subgraph group_analysis["Document analysis"]
  node_intake["Upload intake<br/>[intake.py]"]
  node_pipeline["Document pipeline<br/>[pipeline.py]"]
  node_extractor["Transaction extraction<br/>[extractor.py]"]
  node_model_client["Hosted vision model<br/>[model_client.py]"]
end

subgraph group_accounting["Accounting engine"]
  node_matching["Document matching<br/>[matching.py]"]
  node_checks["Transaction checks<br/>[checks.py]"]
  node_accounts["Chart of accounts<br/>[accounts.py]"]
  node_posting["Double-entry posting<br/>[posting.py]"]
  node_statement_check["Statement checks<br/>[statements.py]"]
end

subgraph group_data["Saved ledgers"]
  node_ledger["Client ledger operations<br/>[ledger.py]"]
  node_store[("SQLite persistence<br/>[store.py]")]
  node_export["Excel export<br/>[export.py]"]
end

node_user(("Accountant"))

node_user -->|"reviews"| node_workspace
node_workspace -->|"adds documents"| node_upload_ui
node_upload_ui -->|"submits analysis"| node_api_client
node_api_client -->|"calls API"| node_http_api
node_http_api -->|"starts jobs"| node_job_store
node_http_api -->|"validates uploads"| node_intake
node_http_api -->|"runs analysis"| node_pipeline
node_pipeline -->|"reads prepared input"| node_intake
node_pipeline -->|"requests extraction"| node_extractor
node_extractor -->|"reads documents"| node_model_client
node_model_client -->|"sends documents to provider"| node_user
node_http_api -->|"serves ledger operations"| node_ledger
node_ledger -->|"recomputes matches"| node_matching
node_ledger -->|"validates transactions"| node_checks
node_checks -->|"checks account codes"| node_accounts
node_ledger -->|"builds trial balance"| node_posting
node_ledger -->|"checks balances"| node_statement_check
node_ledger -->|"reads and writes"| node_store
node_http_api -->|"persists client work"| node_store
node_ledger -->|"exports workbook"| node_export
node_http_api -->|"returns results"| node_api_client
node_api_client -->|"provides ledger data"| node_ledger_ui
node_ledger_ui -->|"uses client operations"| node_clients_api
node_clients_api -->|"uses requests"| node_api_client

click node_workspace "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/app/clients/%5Bid%5D/page.tsx"
click node_upload_ui "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/components/AddDocuments.tsx"
click node_ledger_ui "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/lib/ledger.ts"
click node_api_client "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/lib/api.ts"
click node_clients_api "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/lib/clients.ts"
click node_http_api "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/server.py"
click node_job_store "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/jobs.py"
click node_intake "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/intake.py"
click node_pipeline "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/pipeline.py"
click node_extractor "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/extractor.py"
click node_model_client "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/model_client.py"
click node_matching "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/matching.py"
click node_checks "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/checks.py"
click node_accounts "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/accounts.py"
click node_posting "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/posting.py"
click node_statement_check "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/statements.py"
click node_ledger "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/ledger.py"
click node_store "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/store.py"
click node_export "https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/export.py"

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_workspace,node_upload_ui,node_ledger_ui,node_api_client,node_clients_api toneBlue
class node_http_api,node_job_store toneAmber
class node_intake,node_pipeline,node_extractor,node_model_client toneMint
class node_matching,node_checks,node_accounts,node_posting,node_statement_check toneRose
class node_ledger,node_store,node_export,node_user toneIndigo
```

## Components

### Client workspace

- [Client pages](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/app/clients/%5Bid%5D/page.tsx): `frontend/src/app/clients/[id]/page.tsx`
- [Document uploads](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/components/AddDocuments.tsx): `frontend/src/components/AddDocuments.tsx`
- [Ledger review](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/lib/ledger.ts): `frontend/src/lib/ledger.ts`
- [API client](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Client API calls](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/frontend/src/lib/clients.ts): `frontend/src/lib/clients.ts`

### API and jobs

- [HTTP routes](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/server.py): `server.py`
- [Background jobs](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/jobs.py): `ledgersync/jobs.py`

### Document analysis

- [Upload intake](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/intake.py): `ledgersync/intake.py`
- [Document pipeline](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/pipeline.py): `ledgersync/pipeline.py`
- [Transaction extraction](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/extractor.py): `ledgersync/extractor.py`
- [Hosted vision model](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/model_client.py): `ledgersync/model_client.py`

### Accounting engine

- [Document matching](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/matching.py): `ledgersync/matching.py`
- [Transaction checks](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/checks.py): `ledgersync/checks.py`
- [Chart of accounts](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/accounts.py): `ledgersync/accounts.py`
- [Double-entry posting](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/posting.py): `ledgersync/posting.py`
- [Statement checks](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/statements.py): `ledgersync/statements.py`

### Saved ledgers

- [Client ledger operations](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/ledger.py): `ledgersync/ledger.py`
- [SQLite persistence](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/store.py): `ledgersync/store.py`
- [Excel export](https://github.com/vashgehlot/ai-accountant---temporary/blob/main/ledgersync/export.py): `ledgersync/export.py`

### Other components

- **Accountant**

## Connections

- Accountant → Client pages: reviews (evidence: `README.md`)
- Client pages → Document uploads: adds documents (evidence: `README.md`)
- Document uploads → API client: submits analysis (evidence: `README.md`)
- API client → HTTP routes: calls API (evidence: `README.md`)
- HTTP routes → Background jobs: starts jobs (evidence: `README.md`)
- HTTP routes → Upload intake: validates uploads (evidence: `server.py`)
- HTTP routes → Document pipeline: runs analysis (evidence: `README.md`)
- Document pipeline → Upload intake: reads prepared input (evidence: `ledgersync/pipeline.py`)
- Document pipeline → Transaction extraction: requests extraction (evidence: `README.md`)
- Transaction extraction → Hosted vision model: reads documents (evidence: `README.md`)
- Hosted vision model → Accountant: sends documents to provider (evidence: `README.md`)
- HTTP routes → Client ledger operations: serves ledger operations (evidence: `server.py`)
- Client ledger operations → Document matching: recomputes matches (evidence: `ledgersync/ledger.py`)
- Client ledger operations → Transaction checks: validates transactions (evidence: `ledgersync/ledger.py`)
- Transaction checks → Chart of accounts: checks account codes (evidence: `ledgersync/checks.py`)
- Client ledger operations → Double-entry posting: builds trial balance (evidence: `ledgersync/ledger.py`)
- Client ledger operations → Statement checks: checks balances (evidence: `ledgersync/ledger.py`)
- Client ledger operations → SQLite persistence: reads and writes (evidence: `ledgersync/ledger.py`)
- HTTP routes → SQLite persistence: persists client work (evidence: `server.py`)
- Client ledger operations → Excel export: exports workbook (evidence: `ledgersync/ledger.py`)
- HTTP routes → API client: returns results (evidence: `README.md`)
- API client → Ledger review: provides ledger data (evidence: `frontend/src/lib/api.ts`)
- Ledger review → Client API calls: uses client operations (evidence: `frontend/src/lib/ledger.ts`)
- Client API calls → API client: uses requests (evidence: `frontend/src/lib/clients.ts`)
