# devesh176/translation_studio architecture

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

- Interactive diagram: https://gitdiagram.com/devesh176/translation_studio
- Repository: https://github.com/devesh176/translation_studio

## Overview

Translation Studio is a PDF translation platform: users upload a document, start translation, and retrieve a translated PDF and its structure. The worker parses the PDF into a structure-preserving IR, handles OCR and semantic translation units, routes translation to providers, validates results, and renders the output. The API also exposes cost and section-editing capabilities; the web app provides the interactive studio. Workflow links are supported by the README and indexed references; unsampled implementation details are not expanded into extra steps.

Main entry points: [`apps/worker/tasks/pipeline.py`](https://github.com/devesh176/translation_studio/blob/main/apps/worker/tasks/pipeline.py) (Translation worker), [`apps/api/routes/documents.py`](https://github.com/devesh176/translation_studio/blob/main/apps/api/routes/documents.py) (Document API), [`apps/web/app.js`](https://github.com/devesh176/translation_studio/blob/main/apps/web/app.js) (Web studio), [`packages/document/parser/pymupdf_parser.py`](https://github.com/devesh176/translation_studio/blob/main/packages/document/parser/pymupdf_parser.py) (PDF to IR parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Studio"]
  node_web["Web studio<br/>[app.js]"]
  node_api_routes["Document API<br/>[documents.py]"]
  node_section_api["Section editing API<br/>[sections.py]"]
end

subgraph group_pipeline["Document Pipeline"]
  node_pipeline["Translation worker<br/>[pipeline.py]"]
  node_section_edit["Prompt editing<br/>[section_edit.py]"]
  node_classifier["PDF classifier<br/>[pdf_classifier.py]"]
  node_parser["PDF to IR parser<br/>[pymupdf_parser.py]"]
  node_ir["Document IR<br/>[node.py]"]
  node_ocr["Bodhan OCR<br/>[ocr.py]"]
end

subgraph group_translation["Translation and QA"]
  node_units["Semantic units<br/>[units.py]"]
  node_segments["Segment grouping<br/>[segments.py]"]
  node_router["Translation router"]
  node_bodhan_mt["Bodhan translation<br/>[translation.py]"]
  node_openrouter_mt["OpenRouter translation<br/>[translation.py]"]
  node_invariant_qa["Invariant validation<br/>[invariants.py]"]
  node_semantic_qa["Semantic QA<br/>[qa.py]"]
end

subgraph group_render["PDF Rendering"]
  node_renderer["PDF renderer<br/>[pdf_renderer.py]"]
  node_layout["Layout engine<br/>[layout_engine.py]"]
  node_visual_qa["Visual QA<br/>[visual.py]"]
end

subgraph group_platform["State and Operations"]
  node_storage[("Object storage<br/>[base.py]")]
  node_ledger[("Cost ledger<br/>[ledger.py]")]
  node_config["Configuration loader<br/>[config_loader.py]"]
  node_observability["Observability<br/>[metrics.py]"]
end

node_user(("Document user"))

node_user -->|"uses"| node_web
node_user -->|"uploads PDF"| node_api_routes
node_web -.->|"calls API"| node_api_routes
node_api_routes -->|"classifies upload"| node_classifier
node_api_routes -->|"stores and reads"| node_storage
node_api_routes -->|"starts translation"| node_pipeline
node_api_routes -->|"reads costs"| node_ledger
node_section_api -->|"starts edit"| node_section_edit
node_pipeline -->|"classifies PDF"| node_classifier
node_pipeline -->|"parses PDF"| node_parser
node_parser -->|"creates nodes"| node_ir
node_pipeline -->|"requests OCR"| node_ocr
node_pipeline -->|"groups paragraphs"| node_units
node_pipeline -->|"uses segments"| node_segments
node_pipeline -->|"selects provider"| node_router
node_router -->|"loads routing rules"| node_config
node_pipeline -->|"dispatches translation"| node_bodhan_mt
node_pipeline -->|"dispatches translation"| node_openrouter_mt
node_pipeline -->|"validates invariants"| node_invariant_qa
node_pipeline -->|"checks translation"| node_semantic_qa
node_pipeline -->|"renders PDF"| node_renderer
node_renderer -->|"fits text"| node_layout
node_pipeline -->|"checks rendered PDF"| node_visual_qa
node_pipeline -->|"records cost"| node_ledger
node_pipeline -.->|"persists results"| node_storage
node_api_routes -.->|"reports metrics"| node_observability

click node_web "https://github.com/devesh176/translation_studio/blob/main/apps/web/app.js"
click node_api_routes "https://github.com/devesh176/translation_studio/blob/main/apps/api/routes/documents.py"
click node_section_api "https://github.com/devesh176/translation_studio/blob/main/apps/api/routes/sections.py"
click node_pipeline "https://github.com/devesh176/translation_studio/blob/main/apps/worker/tasks/pipeline.py"
click node_section_edit "https://github.com/devesh176/translation_studio/blob/main/apps/worker/tasks/section_edit.py"
click node_classifier "https://github.com/devesh176/translation_studio/blob/main/packages/document/parser/pdf_classifier.py"
click node_parser "https://github.com/devesh176/translation_studio/blob/main/packages/document/parser/pymupdf_parser.py"
click node_ir "https://github.com/devesh176/translation_studio/blob/main/packages/core/domain/node.py"
click node_ocr "https://github.com/devesh176/translation_studio/blob/main/packages/providers/bodhan/ocr.py"
click node_units "https://github.com/devesh176/translation_studio/blob/main/packages/semantic/units.py"
click node_segments "https://github.com/devesh176/translation_studio/blob/main/packages/semantic/segments.py"
click node_router "https://github.com/devesh176/translation_studio/blob/main/packages/routing/translation_router.py"
click node_bodhan_mt "https://github.com/devesh176/translation_studio/blob/main/packages/providers/bodhan/translation.py"
click node_openrouter_mt "https://github.com/devesh176/translation_studio/blob/main/packages/providers/openrouter/translation.py"
click node_invariant_qa "https://github.com/devesh176/translation_studio/blob/main/packages/validation/invariants.py"
click node_semantic_qa "https://github.com/devesh176/translation_studio/blob/main/packages/semantic/qa.py"
click node_renderer "https://github.com/devesh176/translation_studio/blob/main/packages/rendering/pdf_renderer.py"
click node_layout "https://github.com/devesh176/translation_studio/blob/main/packages/rendering/layout_engine.py"
click node_visual_qa "https://github.com/devesh176/translation_studio/blob/main/packages/validation/visual.py"
click node_storage "https://github.com/devesh176/translation_studio/blob/main/packages/storage/object_store/base.py"
click node_ledger "https://github.com/devesh176/translation_studio/blob/main/packages/costs/ledger.py"
click node_config "https://github.com/devesh176/translation_studio/blob/main/packages/core/config_loader.py"
click node_observability "https://github.com/devesh176/translation_studio/blob/main/packages/observability/metrics.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_web,node_api_routes,node_section_api,node_user toneBlue
class node_pipeline,node_section_edit,node_classifier,node_parser,node_ir,node_ocr toneAmber
class node_units,node_segments,node_router,node_bodhan_mt,node_openrouter_mt,node_invariant_qa,node_semantic_qa toneMint
class node_renderer,node_layout,node_visual_qa toneRose
class node_storage,node_ledger,node_config,node_observability toneIndigo
```

## Components

### API and Studio

- [Web studio](https://github.com/devesh176/translation_studio/blob/main/apps/web/app.js): `apps/web/app.js`
- [Document API](https://github.com/devesh176/translation_studio/blob/main/apps/api/routes/documents.py): `apps/api/routes/documents.py`
- [Section editing API](https://github.com/devesh176/translation_studio/blob/main/apps/api/routes/sections.py): `apps/api/routes/sections.py`

### Document Pipeline

- [Translation worker](https://github.com/devesh176/translation_studio/blob/main/apps/worker/tasks/pipeline.py): `apps/worker/tasks/pipeline.py`
- [Prompt editing](https://github.com/devesh176/translation_studio/blob/main/apps/worker/tasks/section_edit.py): `apps/worker/tasks/section_edit.py`
- [PDF classifier](https://github.com/devesh176/translation_studio/blob/main/packages/document/parser/pdf_classifier.py): `packages/document/parser/pdf_classifier.py`
- [PDF to IR parser](https://github.com/devesh176/translation_studio/blob/main/packages/document/parser/pymupdf_parser.py): `packages/document/parser/pymupdf_parser.py`
- [Document IR](https://github.com/devesh176/translation_studio/blob/main/packages/core/domain/node.py): `packages/core/domain/node.py`
- [Bodhan OCR](https://github.com/devesh176/translation_studio/blob/main/packages/providers/bodhan/ocr.py): `packages/providers/bodhan/ocr.py`

### Translation and QA

- [Semantic units](https://github.com/devesh176/translation_studio/blob/main/packages/semantic/units.py): `packages/semantic/units.py`
- [Segment grouping](https://github.com/devesh176/translation_studio/blob/main/packages/semantic/segments.py): `packages/semantic/segments.py`
- [Translation router](https://github.com/devesh176/translation_studio/blob/main/packages/routing/translation_router.py): `packages/routing/translation_router.py`
- [Bodhan translation](https://github.com/devesh176/translation_studio/blob/main/packages/providers/bodhan/translation.py): `packages/providers/bodhan/translation.py`
- [OpenRouter translation](https://github.com/devesh176/translation_studio/blob/main/packages/providers/openrouter/translation.py): `packages/providers/openrouter/translation.py`
- [Invariant validation](https://github.com/devesh176/translation_studio/blob/main/packages/validation/invariants.py): `packages/validation/invariants.py`
- [Semantic QA](https://github.com/devesh176/translation_studio/blob/main/packages/semantic/qa.py): `packages/semantic/qa.py`

### PDF Rendering

- [PDF renderer](https://github.com/devesh176/translation_studio/blob/main/packages/rendering/pdf_renderer.py): `packages/rendering/pdf_renderer.py`
- [Layout engine](https://github.com/devesh176/translation_studio/blob/main/packages/rendering/layout_engine.py): `packages/rendering/layout_engine.py`
- [Visual QA](https://github.com/devesh176/translation_studio/blob/main/packages/validation/visual.py): `packages/validation/visual.py`

### State and Operations

- [Object storage](https://github.com/devesh176/translation_studio/blob/main/packages/storage/object_store/base.py): `packages/storage/object_store/base.py`
- [Cost ledger](https://github.com/devesh176/translation_studio/blob/main/packages/costs/ledger.py): `packages/costs/ledger.py`
- [Configuration loader](https://github.com/devesh176/translation_studio/blob/main/packages/core/config_loader.py): `packages/core/config_loader.py`
- [Observability](https://github.com/devesh176/translation_studio/blob/main/packages/observability/metrics.py): `packages/observability/metrics.py`

### Other components

- **Document user**

## Connections

- Document user → Web studio: uses (evidence: `README.md`)
- Document user → Document API: uploads PDF (evidence: `README.md`)
- Web studio → Document API: calls API
- Document API → PDF classifier: classifies upload (evidence: `apps/api/routes/documents.py`)
- Document API → Object storage: stores and reads (evidence: `apps/api/routes/documents.py`)
- Document API → Translation worker: starts translation (evidence: `apps/api/routes/documents.py`)
- Document API → Cost ledger: reads costs (evidence: `apps/api/routes/documents.py`)
- Section editing API → Prompt editing: starts edit
- Translation worker → PDF classifier: classifies PDF (evidence: `apps/worker/tasks/pipeline.py`)
- Translation worker → PDF to IR parser: parses PDF (evidence: `apps/worker/tasks/pipeline.py`)
- PDF to IR parser → Document IR: creates nodes (evidence: `packages/document/parser/pymupdf_parser.py`)
- Translation worker → Bodhan OCR: requests OCR (evidence: `apps/worker/tasks/pipeline.py`)
- Translation worker → Semantic units: groups paragraphs (evidence: `README.md`)
- Translation worker → Segment grouping: uses segments (evidence: `apps/worker/tasks/pipeline.py`)
- Translation worker → Translation router: selects provider (evidence: `apps/worker/tasks/pipeline.py`)
- Translation router → Configuration loader: loads routing rules (evidence: `packages/routing/translation_router.py`)
- Translation worker → Bodhan translation: dispatches translation (evidence: `apps/worker/tasks/pipeline.py`)
- Translation worker → OpenRouter translation: dispatches translation (evidence: `apps/worker/tasks/pipeline.py`)
- Translation worker → Invariant validation: validates invariants (evidence: `README.md`)
- Translation worker → Semantic QA: checks translation (evidence: `README.md`)
- Translation worker → PDF renderer: renders PDF (evidence: `README.md`)
- PDF renderer → Layout engine: fits text (evidence: `packages/rendering/pdf_renderer.py`)
- Translation worker → Visual QA: checks rendered PDF (evidence: `README.md`)
- Translation worker → Cost ledger: records cost (evidence: `README.md`)
- Translation worker → Object storage: persists results
- Document API → Observability: reports metrics
