# sathvik2005/tax-doc-classifier architecture

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

- Interactive diagram: https://gitdiagram.com/sathvik2005/tax-doc-classifier
- Repository: https://github.com/sathvik2005/tax-doc-classifier

## Overview

tax-doc-classifier is a text-based IRS form and page-kind classifier, with a web UI for uploading PDFs and reviewing per-page results. The main workflow runs from PDF upload through page text extraction (with UI-side OCR fallback), Jev classification, confidence gating, and streamed results. The classifier also exposes form identifiers and evaluation scoring; the UI includes catalog, evaluation, and settings views. Relationships are limited to README statements and shown source references; several UI and evaluation details are unsampled.

Main entry points: [`ui/server/index.ts`](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/server/index.ts) (Upload and stream server), [`ui/src/App.tsx`](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/App.tsx) (Web UI), [`src/classify.ts`](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/classify.ts) (Page classifier), [`src/backend.ts`](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/backend.ts) (Jev backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_classifier["Classification core"]
  node_classification["Page classifier<br/>[classify.ts]"]
  node_jev_backend["Jev backend<br/>[backend.ts]"]
  node_evaluation_runner["Evaluation runner<br/>[run.ts]"]
  node_scoring["Evaluation scoring<br/>[score.ts]"]
end

subgraph group_web["Web application"]
  node_ui["Web UI<br/>[App.tsx]"]
  node_classify_view["Classify view<br/>[ClassifyPage.tsx]"]
  node_catalog_view["Catalog view<br/>[CatalogPage.tsx]"]
  node_evaluation_view["Evaluation view<br/>[EvaluationPage.tsx]"]
  node_settings_view["Settings view<br/>[SettingsPage.tsx]"]
  node_server["Upload and stream server<br/>[index.ts]"]
  node_ocr["OCR fallback<br/>[index.ts]"]
  node_eval_results["Evaluation results<br/>[index.ts]"]
end

subgraph group_domain["Classification support"]
  node_page_text["PDF page text<br/>[state.ts]"]
  node_page_state["Page state<br/>[state.ts]"]
  node_criteria["Form criteria<br/>[criteria.json]"]
  node_ids["Form identifiers<br/>[ids.ts]"]
end

node_user(("Tax preparer"))
node_pdf["Tax PDF"]
node_jev["TypeSafe Jev"]

node_user -->|"uses"| node_ui
node_ui -->|"renders"| node_classify_view
node_ui -->|"renders"| node_catalog_view
node_ui -->|"renders"| node_evaluation_view
node_ui -->|"renders"| node_settings_view
node_classify_view -->|"uploads and streams"| node_server
node_pdf -->|"uploads"| node_server
node_server -->|"extracts page text"| node_page_text
node_server -->|"requests OCR"| node_ocr
node_server -->|"classifies pages"| node_classification
node_server -->|"configures backend"| node_jev_backend
node_classification -->|"builds state"| node_page_state
node_classification -->|"asks questions"| node_jev_backend
node_jev_backend -->|"sends request"| node_jev
node_classification -.->|"uses criteria"| node_criteria
node_server -->|"reads results"| node_eval_results
node_evaluation_view -->|"requests runs"| node_server
node_evaluation_runner -.->|"scores runs"| node_scoring
node_evaluation_runner -.->|"evaluates classifier"| node_classification

click node_ui "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/App.tsx"
click node_classify_view "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/ClassifyPage.tsx"
click node_catalog_view "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/CatalogPage.tsx"
click node_evaluation_view "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/EvaluationPage.tsx"
click node_settings_view "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/SettingsPage.tsx"
click node_server "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/server/index.ts"
click node_ocr "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/server/index.ts"
click node_page_text "https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/state.ts"
click node_page_state "https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/state.ts"
click node_criteria "https://github.com/sathvik2005/tax-doc-classifier/blob/master/data/criteria.json"
click node_classification "https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/classify.ts"
click node_jev_backend "https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/backend.ts"
click node_ids "https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/ids.ts"
click node_evaluation_runner "https://github.com/sathvik2005/tax-doc-classifier/blob/master/eval/run.ts"
click node_scoring "https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/score.ts"
click node_eval_results "https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/server/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_classification,node_jev_backend,node_evaluation_runner,node_scoring toneBlue
class node_ui,node_classify_view,node_catalog_view,node_evaluation_view,node_settings_view,node_server,node_ocr,node_eval_results toneAmber
class node_page_text,node_page_state,node_criteria,node_ids toneMint
class node_user,node_pdf,node_jev toneIndigo
```

## Components

### Classification core

- [Page classifier](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/classify.ts): `src/classify.ts`
- [Jev backend](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/backend.ts): `src/backend.ts`
- [Evaluation runner](https://github.com/sathvik2005/tax-doc-classifier/blob/master/eval/run.ts): `eval/run.ts`
- [Evaluation scoring](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/score.ts): `src/score.ts`

### Web application

- [Web UI](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/App.tsx): `ui/src/App.tsx`
- [Classify view](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/ClassifyPage.tsx): `ui/src/pages/ClassifyPage.tsx`
- [Catalog view](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/CatalogPage.tsx): `ui/src/pages/CatalogPage.tsx`
- [Evaluation view](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/EvaluationPage.tsx): `ui/src/pages/EvaluationPage.tsx`
- [Settings view](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/src/pages/SettingsPage.tsx): `ui/src/pages/SettingsPage.tsx`
- [Upload and stream server](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/server/index.ts): `ui/server/index.ts`
- [OCR fallback](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/server/index.ts): `ui/server/index.ts`
- [Evaluation results](https://github.com/sathvik2005/tax-doc-classifier/blob/master/ui/server/index.ts): `ui/server/index.ts`

### Classification support

- [PDF page text](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/state.ts): `src/state.ts`
- [Page state](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/state.ts): `src/state.ts`
- [Form criteria](https://github.com/sathvik2005/tax-doc-classifier/blob/master/data/criteria.json): `data/criteria.json`
- [Form identifiers](https://github.com/sathvik2005/tax-doc-classifier/blob/master/src/ids.ts): `src/ids.ts`

### Other components

- **Tax preparer**
- **Tax PDF**
- **TypeSafe Jev**

## Connections

- Tax preparer → Web UI: uses (evidence: `README.md`)
- Web UI → Classify view: renders (evidence: `ui/src/App.tsx`)
- Web UI → Catalog view: renders (evidence: `ui/src/App.tsx`)
- Web UI → Evaluation view: renders (evidence: `ui/src/App.tsx`)
- Web UI → Settings view: renders (evidence: `ui/src/App.tsx`)
- Classify view → Upload and stream server: uploads and streams (evidence: `ui/src/pages/ClassifyPage.tsx`)
- Tax PDF → Upload and stream server: uploads (evidence: `README.md`)
- Upload and stream server → PDF page text: extracts page text (evidence: `ui/server/index.ts`)
- Upload and stream server → OCR fallback: requests OCR (evidence: `ui/server/index.ts`)
- Upload and stream server → Page classifier: classifies pages (evidence: `ui/server/index.ts`)
- Upload and stream server → Jev backend: configures backend (evidence: `ui/server/index.ts`)
- Page classifier → Page state: builds state (evidence: `src/classify.ts`)
- Page classifier → Jev backend: asks questions (evidence: `src/classify.ts`)
- Jev backend → TypeSafe Jev: sends request (evidence: `src/backend.ts`)
- Page classifier → Form criteria: uses criteria (evidence: `README.md`)
- Upload and stream server → Evaluation results: reads results (evidence: `ui/server/index.ts`)
- Evaluation view → Upload and stream server: requests runs (evidence: `ui/src/pages/EvaluationPage.tsx`)
- Evaluation runner → Evaluation scoring: scores runs
- Evaluation runner → Page classifier: evaluates classifier
