# chetanjagan/parda architecture

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

- Interactive diagram: https://gitdiagram.com/chetanjagan/parda
- Repository: https://github.com/chetanjagan/parda

## Overview

Parda is a local-first document redaction product. A user uploads a PDF or photo, browser OCR and text/visual detectors find sensitive content, the user reviews and edits proposed regions, and export produces a flattened PDF or PNG plus an audit file. The repository also contains the Python reference pipeline, synthetic-data generation, model training, evaluation, and ONNX export used to build and verify the browser version. Relationships for unsampled subsystems are included only where the README documents them; source-level evidence is limited to the excerpts and index shown.

Main entry points: [`web/src/app/pipeline.ts`](https://github.com/chetanjagan/parda/blob/main/web/src/app/pipeline.ts) (Page analysis), [`parda/pipeline/redactor.py`](https://github.com/chetanjagan/parda/blob/main/parda/pipeline/redactor.py) (Redaction orchestrator), [`web/src/app/main.ts`](https://github.com/chetanjagan/parda/blob/main/web/src/app/main.ts) (App workflow), [`web/src/app/worker.ts`](https://github.com/chetanjagan/parda/blob/main/web/src/app/worker.ts) (Background worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser_app["Browser app"]
  node_app["App workflow<br/>[main.ts]"]
  node_page_loading["Page loading<br/>[pages.ts]"]
  node_analysis_client["Analysis client<br/>[client.ts]"]
  node_background_worker["Background worker<br/>[worker.ts]"]
  node_review["Review controls<br/>[review.ts]"]
  node_export["PDF and audit export<br/>[export.ts]"]
end

subgraph group_browser_inference["Browser inference"]
  node_browser_pipeline["Page analysis<br/>[pipeline.ts]"]
  node_browser_ocr["Browser OCR<br/>[tesseract.ts]"]
  node_easyocr["EasyOCR reader<br/>[reader.ts]"]
  node_browser_gliner["GLiNER inference<br/>[model.ts]"]
  node_browser_rules["PII rules and spans<br/>[rules.ts]"]
  node_browser_geometry["Region geometry<br/>[boxes.ts]"]
  node_browser_yolo["Visual detection<br/>[yolo.ts]"]
end

subgraph group_python_runtime["Python pipeline"]
  node_python_redactor["Redaction orchestrator<br/>[redactor.py]"]
  node_python_ocr["OCR engines<br/>[engines.py]"]
  node_python_pii["PII prediction<br/>[predict.py]"]
  node_python_geometry["Boxes and masking<br/>[boxes.py]"]
  node_python_visual["YOLO detection<br/>[detectors.py]"]
end

subgraph group_model_data["Data and models"]
  node_synthetic_data["Synthetic documents<br/>[templates.py]"]
  node_training_data["PII training data<br/>[build_data.py]"]
  node_model_training["GLiNER training<br/>[train_gliner.py]"]
  node_onnx_export["ONNX export<br/>[onnx_export.py]"]
  node_model_runtime["ONNX runtime<br/>[onnx_runtime.py]"]
end

node_user(("Document user"))

node_user -->|"uploads document"| node_app
node_app -->|"loads pages"| node_page_loading
node_app -->|"starts analysis"| node_analysis_client
node_analysis_client -->|"dispatches work"| node_background_worker
node_background_worker -->|"runs analysis"| node_browser_pipeline
node_background_worker -->|"runs photo OCR"| node_easyocr
node_background_worker -->|"loads model"| node_browser_gliner
node_browser_pipeline -->|"reads text"| node_browser_ocr
node_browser_pipeline -->|"reads text"| node_easyocr
node_browser_pipeline -->|"predicts spans"| node_browser_gliner
node_browser_pipeline -->|"finds rule matches"| node_browser_rules
node_browser_pipeline -->|"finds visual regions"| node_browser_yolo
node_browser_pipeline -->|"maps redactions"| node_browser_geometry
node_analysis_client -->|"opens review"| node_review
node_user -->|"edits findings"| node_review
node_review -->|"exports result"| node_export
node_app -->|"downloads output"| node_export
node_python_redactor -->|"runs OCR"| node_python_ocr
node_python_redactor -->|"predicts PII"| node_python_pii
node_python_redactor -->|"detects regions"| node_python_visual
node_python_redactor -->|"builds redactions"| node_python_geometry
node_synthetic_data -.->|"supplies labeled pages"| node_training_data
node_training_data -.->|"trains text model"| node_model_training
node_model_training -.->|"exports model"| node_onnx_export
node_onnx_export -->|"uses runtime helpers"| node_model_runtime
node_model_runtime -->|"provides inference"| node_python_pii

click node_app "https://github.com/chetanjagan/parda/blob/main/web/src/app/main.ts"
click node_page_loading "https://github.com/chetanjagan/parda/blob/main/web/src/app/pages.ts"
click node_analysis_client "https://github.com/chetanjagan/parda/blob/main/web/src/app/client.ts"
click node_background_worker "https://github.com/chetanjagan/parda/blob/main/web/src/app/worker.ts"
click node_review "https://github.com/chetanjagan/parda/blob/main/web/src/app/review.ts"
click node_export "https://github.com/chetanjagan/parda/blob/main/web/src/app/export.ts"
click node_browser_pipeline "https://github.com/chetanjagan/parda/blob/main/web/src/app/pipeline.ts"
click node_browser_ocr "https://github.com/chetanjagan/parda/blob/main/web/src/ocr/tesseract.ts"
click node_easyocr "https://github.com/chetanjagan/parda/blob/main/web/src/easyocr/reader.ts"
click node_browser_gliner "https://github.com/chetanjagan/parda/blob/main/web/src/gliner/model.ts"
click node_browser_rules "https://github.com/chetanjagan/parda/blob/main/web/src/core/rules.ts"
click node_browser_geometry "https://github.com/chetanjagan/parda/blob/main/web/src/core/boxes.ts"
click node_browser_yolo "https://github.com/chetanjagan/parda/blob/main/web/src/vision/yolo.ts"
click node_python_redactor "https://github.com/chetanjagan/parda/blob/main/parda/pipeline/redactor.py"
click node_python_ocr "https://github.com/chetanjagan/parda/blob/main/parda/ocr/engines.py"
click node_python_pii "https://github.com/chetanjagan/parda/blob/main/parda/pii/predict.py"
click node_python_geometry "https://github.com/chetanjagan/parda/blob/main/parda/pipeline/boxes.py"
click node_python_visual "https://github.com/chetanjagan/parda/blob/main/parda/vision/detectors.py"
click node_synthetic_data "https://github.com/chetanjagan/parda/blob/main/parda/synth/templates.py"
click node_training_data "https://github.com/chetanjagan/parda/blob/main/parda/pii/build_data.py"
click node_model_training "https://github.com/chetanjagan/parda/blob/main/parda/pii/train_gliner.py"
click node_onnx_export "https://github.com/chetanjagan/parda/blob/main/parda/export/onnx_export.py"
click node_model_runtime "https://github.com/chetanjagan/parda/blob/main/parda/export/onnx_runtime.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_app,node_page_loading,node_analysis_client,node_background_worker,node_review,node_export,node_user toneBlue
class node_browser_pipeline,node_browser_ocr,node_easyocr,node_browser_gliner,node_browser_rules,node_browser_geometry,node_browser_yolo toneAmber
class node_python_redactor,node_python_ocr,node_python_pii,node_python_geometry,node_python_visual toneMint
class node_synthetic_data,node_training_data,node_model_training,node_onnx_export,node_model_runtime toneRose
```

## Components

### Browser app

- [App workflow](https://github.com/chetanjagan/parda/blob/main/web/src/app/main.ts): `web/src/app/main.ts`
- [Page loading](https://github.com/chetanjagan/parda/blob/main/web/src/app/pages.ts): `web/src/app/pages.ts`
- [Analysis client](https://github.com/chetanjagan/parda/blob/main/web/src/app/client.ts): `web/src/app/client.ts`
- [Background worker](https://github.com/chetanjagan/parda/blob/main/web/src/app/worker.ts): `web/src/app/worker.ts`
- [Review controls](https://github.com/chetanjagan/parda/blob/main/web/src/app/review.ts): `web/src/app/review.ts`
- [PDF and audit export](https://github.com/chetanjagan/parda/blob/main/web/src/app/export.ts): `web/src/app/export.ts`

### Browser inference

- [Page analysis](https://github.com/chetanjagan/parda/blob/main/web/src/app/pipeline.ts): `web/src/app/pipeline.ts`
- [Browser OCR](https://github.com/chetanjagan/parda/blob/main/web/src/ocr/tesseract.ts): `web/src/ocr/tesseract.ts`
- [EasyOCR reader](https://github.com/chetanjagan/parda/blob/main/web/src/easyocr/reader.ts): `web/src/easyocr/reader.ts`
- [GLiNER inference](https://github.com/chetanjagan/parda/blob/main/web/src/gliner/model.ts): `web/src/gliner/model.ts`
- [PII rules and spans](https://github.com/chetanjagan/parda/blob/main/web/src/core/rules.ts): `web/src/core/rules.ts`
- [Region geometry](https://github.com/chetanjagan/parda/blob/main/web/src/core/boxes.ts): `web/src/core/boxes.ts`
- [Visual detection](https://github.com/chetanjagan/parda/blob/main/web/src/vision/yolo.ts): `web/src/vision/yolo.ts`

### Python pipeline

- [Redaction orchestrator](https://github.com/chetanjagan/parda/blob/main/parda/pipeline/redactor.py): `parda/pipeline/redactor.py`
- [OCR engines](https://github.com/chetanjagan/parda/blob/main/parda/ocr/engines.py): `parda/ocr/engines.py`
- [PII prediction](https://github.com/chetanjagan/parda/blob/main/parda/pii/predict.py): `parda/pii/predict.py`
- [Boxes and masking](https://github.com/chetanjagan/parda/blob/main/parda/pipeline/boxes.py): `parda/pipeline/boxes.py`
- [YOLO detection](https://github.com/chetanjagan/parda/blob/main/parda/vision/detectors.py): `parda/vision/detectors.py`

### Data and models

- [Synthetic documents](https://github.com/chetanjagan/parda/blob/main/parda/synth/templates.py): `parda/synth/templates.py`
- [PII training data](https://github.com/chetanjagan/parda/blob/main/parda/pii/build_data.py): `parda/pii/build_data.py`
- [GLiNER training](https://github.com/chetanjagan/parda/blob/main/parda/pii/train_gliner.py): `parda/pii/train_gliner.py`
- [ONNX export](https://github.com/chetanjagan/parda/blob/main/parda/export/onnx_export.py): `parda/export/onnx_export.py`
- [ONNX runtime](https://github.com/chetanjagan/parda/blob/main/parda/export/onnx_runtime.py): `parda/export/onnx_runtime.py`

### Other components

- **Document user**

## Connections

- Document user → App workflow: uploads document (evidence: `README.md`)
- App workflow → Page loading: loads pages (evidence: `web/src/app/main.ts`)
- App workflow → Analysis client: starts analysis (evidence: `README.md`)
- Analysis client → Background worker: dispatches work (evidence: `web/src/app/client.ts`)
- Background worker → Page analysis: runs analysis (evidence: `web/src/app/worker.ts`)
- Background worker → EasyOCR reader: runs photo OCR (evidence: `web/src/app/worker.ts`)
- Background worker → GLiNER inference: loads model (evidence: `web/src/app/worker.ts`)
- Page analysis → Browser OCR: reads text (evidence: `README.md`)
- Page analysis → EasyOCR reader: reads text (evidence: `web/src/app/pipeline.ts`)
- Page analysis → GLiNER inference: predicts spans (evidence: `web/src/app/pipeline.ts`)
- Page analysis → PII rules and spans: finds rule matches (evidence: `web/src/app/pipeline.ts`)
- Page analysis → Visual detection: finds visual regions (evidence: `web/src/app/pipeline.ts`)
- Page analysis → Region geometry: maps redactions (evidence: `web/src/app/pipeline.ts`)
- Analysis client → Review controls: opens review (evidence: `web/src/app/client.ts`)
- Document user → Review controls: edits findings (evidence: `README.md`)
- Review controls → PDF and audit export: exports result (evidence: `README.md`)
- App workflow → PDF and audit export: downloads output (evidence: `web/src/app/main.ts`)
- Redaction orchestrator → OCR engines: runs OCR (evidence: `parda/pipeline/redact.py`)
- Redaction orchestrator → PII prediction: predicts PII (evidence: `parda/pipeline/redact.py`)
- Redaction orchestrator → YOLO detection: detects regions (evidence: `parda/pipeline/redact.py`)
- Redaction orchestrator → Boxes and masking: builds redactions (evidence: `parda/pipeline/redact.py`)
- Synthetic documents → PII training data: supplies labeled pages (evidence: `README.md`)
- PII training data → GLiNER training: trains text model (evidence: `README.md`)
- GLiNER training → ONNX export: exports model (evidence: `README.md`)
- ONNX export → ONNX runtime: uses runtime helpers (evidence: `parda/export/onnx_export.py`)
- ONNX runtime → PII prediction: provides inference (evidence: `parda/export/onnx_runtime.py`)
