# yfengg/scanlate architecture

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

- Interactive diagram: https://gitdiagram.com/yfengg/scanlate
- Repository: https://github.com/yfengg/scanlate

## Overview

Scanlate is a multilingual comic-translation workbench. Users create projects and chapters, import pages, detect or define text regions, OCR or enter source text, generate translation candidates, review warnings and terminology, then edit and approve translations. Approval records trusted translations in project memory and can suggest glossary decisions. The graph includes documented validation, sound-effect, and page-imaging capabilities; rendering/export are not implemented. Some links reflect README statements or source-index references rather than inspected call sites, so uncertain integrations are marked dashed.

Main entry points: [`src/scanlate/pipeline/pipeline.py`](https://github.com/yfengg/scanlate/blob/main/src/scanlate/pipeline/pipeline.py) (Translation decisions), [`src/scanlate/api/app.py`](https://github.com/yfengg/scanlate/blob/main/src/scanlate/api/app.py) (HTTP API), [`src/scanlate/storage/repository.py`](https://github.com/yfengg/scanlate/blob/main/src/scanlate/storage/repository.py) (Project repository), [`src/scanlate/imaging/service.py`](https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/service.py) (Page workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Translation workflow"]
  node_pipeline["Translation decisions<br/>[pipeline.py]"]
  node_approval["Human approval<br/>[approval.py]"]
  node_validation["Translation validators<br/>[validators.py]"]
end

subgraph group_imaging["Page imaging"]
  node_page_service["Page workflow<br/>[service.py]"]
  node_importer["Page import<br/>[importer.py]"]
  node_detection["Region detection<br/>[detection.py]"]
  node_ocr["OCR<br/>[ocr.py]"]
  node_layout["Region geometry<br/>[layout.py]"]
end

subgraph group_language["Language intelligence"]
  node_adapter["Language adapters<br/>[adapter.py]"]
  node_analysis["Linguistic analysis<br/>[analysis.py]"]
  node_ja_adapter["Japanese adapter<br/>[adapter.py]"]
  node_ko_adapter["Korean adapter<br/>[adapter.py]"]
  node_en_adapter["English adapter<br/>[adapter.py]"]
  node_context["Local context<br/>[local.py]"]
  node_sfx["SFX rendering<br/>[renderer.py]"]
  node_categories["SFX categories<br/>[categories.py]"]
end

subgraph group_knowledge["Project knowledge"]
  node_glossary[("Project glossary<br/>[store.py]")]
  node_memory[("Translation memory<br/>[store.py]")]
end

subgraph group_platform["Application platform"]
  node_api["HTTP API<br/>[app.py]"]
  node_page_api["Page routes<br/>[pages.py]"]
  node_workbench["Workbench UI<br/>[view.py]"]
  node_schemas["Response schemas<br/>[schemas.py]"]
  node_repository[("Project repository<br/>[repository.py]")]
  node_models["Domain records<br/>[models.py]"]
  node_uow["Transaction boundary<br/>[unit_of_work.py]"]
end

node_user(("Translator"))
node_mt_backend["MT backend"]

node_user -->|"uses"| node_workbench
node_workbench -->|"requests"| node_api
node_api -->|"routes pages"| node_page_api
node_api -.->|"calls"| node_pipeline
node_api -->|"calls"| node_approval
node_api -->|"reads and writes"| node_repository
node_api -->|"serializes"| node_schemas
node_page_api -->|"delegates"| node_page_service
node_page_api -->|"reads and writes"| node_repository
node_page_service -->|"imports pages"| node_importer
node_page_service -->|"detects regions"| node_detection
node_page_service -->|"reads regions"| node_ocr
node_page_service -->|"uses geometry"| node_layout
node_page_service -->|"persists segments"| node_repository
node_pipeline -->|"analyzes text"| node_adapter
node_pipeline -->|"checks terms"| node_glossary
node_pipeline -->|"checks precedent"| node_memory
node_pipeline -->|"gets context"| node_context
node_pipeline -->|"reports issues"| node_validation
node_pipeline -->|"renders SFX"| node_sfx
node_pipeline -->|"requests candidate"| node_mt_backend
node_pipeline -->|"loads segments"| node_repository
node_adapter -->|"produces analysis"| node_analysis
node_ja_adapter -->|"implements"| node_adapter
node_ko_adapter -->|"implements"| node_adapter
node_en_adapter -->|"implements"| node_adapter
node_sfx -->|"uses categories"| node_categories
node_approval -->|"updates state"| node_repository
node_approval -->|"records approval"| node_memory
node_approval -->|"suggests terms"| node_glossary
node_approval -->|"commits atomically"| node_uow
node_glossary -->|"uses transactions"| node_uow
node_memory -->|"uses transactions"| node_uow
node_repository -->|"maps records"| node_models
node_repository -->|"shares boundary"| node_uow
node_api -->|"serves page"| node_workbench
node_validation -->|"checks decisions"| node_glossary

click node_api "https://github.com/yfengg/scanlate/blob/main/src/scanlate/api/app.py"
click node_page_api "https://github.com/yfengg/scanlate/blob/main/src/scanlate/api/pages.py"
click node_workbench "https://github.com/yfengg/scanlate/blob/main/src/scanlate/workbench/view.py"
click node_schemas "https://github.com/yfengg/scanlate/blob/main/src/scanlate/api/schemas.py"
click node_page_service "https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/service.py"
click node_importer "https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/importer.py"
click node_detection "https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/detection.py"
click node_ocr "https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/ocr.py"
click node_layout "https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/layout.py"
click node_pipeline "https://github.com/yfengg/scanlate/blob/main/src/scanlate/pipeline/pipeline.py"
click node_approval "https://github.com/yfengg/scanlate/blob/main/src/scanlate/pipeline/approval.py"
click node_validation "https://github.com/yfengg/scanlate/blob/main/src/scanlate/validation/validators.py"
click node_adapter "https://github.com/yfengg/scanlate/blob/main/src/scanlate/core/adapter.py"
click node_analysis "https://github.com/yfengg/scanlate/blob/main/src/scanlate/core/analysis.py"
click node_ja_adapter "https://github.com/yfengg/scanlate/blob/main/src/scanlate/languages/ja/adapter.py"
click node_ko_adapter "https://github.com/yfengg/scanlate/blob/main/src/scanlate/languages/ko/adapter.py"
click node_en_adapter "https://github.com/yfengg/scanlate/blob/main/src/scanlate/languages/en/adapter.py"
click node_context "https://github.com/yfengg/scanlate/blob/main/src/scanlate/context/local.py"
click node_sfx "https://github.com/yfengg/scanlate/blob/main/src/scanlate/sfx/renderer.py"
click node_categories "https://github.com/yfengg/scanlate/blob/main/src/scanlate/sfx/categories.py"
click node_glossary "https://github.com/yfengg/scanlate/blob/main/src/scanlate/glossary/store.py"
click node_memory "https://github.com/yfengg/scanlate/blob/main/src/scanlate/memory/store.py"
click node_repository "https://github.com/yfengg/scanlate/blob/main/src/scanlate/storage/repository.py"
click node_models "https://github.com/yfengg/scanlate/blob/main/src/scanlate/storage/models.py"
click node_uow "https://github.com/yfengg/scanlate/blob/main/src/scanlate/storage/unit_of_work.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_pipeline,node_approval,node_validation toneBlue
class node_page_service,node_importer,node_detection,node_ocr,node_layout toneAmber
class node_adapter,node_analysis,node_ja_adapter,node_ko_adapter,node_en_adapter,node_context,node_sfx,node_categories toneMint
class node_glossary,node_memory toneRose
class node_api,node_page_api,node_workbench,node_schemas,node_repository,node_models,node_uow,node_user,node_mt_backend toneIndigo
```

## Components

### Translation workflow

- [Translation decisions](https://github.com/yfengg/scanlate/blob/main/src/scanlate/pipeline/pipeline.py): `src/scanlate/pipeline/pipeline.py`
- [Human approval](https://github.com/yfengg/scanlate/blob/main/src/scanlate/pipeline/approval.py): `src/scanlate/pipeline/approval.py`
- [Translation validators](https://github.com/yfengg/scanlate/blob/main/src/scanlate/validation/validators.py): `src/scanlate/validation/validators.py`

### Page imaging

- [Page workflow](https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/service.py): `src/scanlate/imaging/service.py`
- [Page import](https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/importer.py): `src/scanlate/imaging/importer.py`
- [Region detection](https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/detection.py): `src/scanlate/imaging/detection.py`
- [OCR](https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/ocr.py): `src/scanlate/imaging/ocr.py`
- [Region geometry](https://github.com/yfengg/scanlate/blob/main/src/scanlate/imaging/layout.py): `src/scanlate/imaging/layout.py`

### Language intelligence

- [Language adapters](https://github.com/yfengg/scanlate/blob/main/src/scanlate/core/adapter.py): `src/scanlate/core/adapter.py`
- [Linguistic analysis](https://github.com/yfengg/scanlate/blob/main/src/scanlate/core/analysis.py): `src/scanlate/core/analysis.py`
- [Japanese adapter](https://github.com/yfengg/scanlate/blob/main/src/scanlate/languages/ja/adapter.py): `src/scanlate/languages/ja/adapter.py`
- [Korean adapter](https://github.com/yfengg/scanlate/blob/main/src/scanlate/languages/ko/adapter.py): `src/scanlate/languages/ko/adapter.py`
- [English adapter](https://github.com/yfengg/scanlate/blob/main/src/scanlate/languages/en/adapter.py): `src/scanlate/languages/en/adapter.py`
- [Local context](https://github.com/yfengg/scanlate/blob/main/src/scanlate/context/local.py): `src/scanlate/context/local.py`
- [SFX rendering](https://github.com/yfengg/scanlate/blob/main/src/scanlate/sfx/renderer.py): `src/scanlate/sfx/renderer.py`
- [SFX categories](https://github.com/yfengg/scanlate/blob/main/src/scanlate/sfx/categories.py): `src/scanlate/sfx/categories.py`

### Project knowledge

- [Project glossary](https://github.com/yfengg/scanlate/blob/main/src/scanlate/glossary/store.py): `src/scanlate/glossary/store.py`
- [Translation memory](https://github.com/yfengg/scanlate/blob/main/src/scanlate/memory/store.py): `src/scanlate/memory/store.py`

### Application platform

- [HTTP API](https://github.com/yfengg/scanlate/blob/main/src/scanlate/api/app.py): `src/scanlate/api/app.py`
- [Page routes](https://github.com/yfengg/scanlate/blob/main/src/scanlate/api/pages.py): `src/scanlate/api/pages.py`
- [Workbench UI](https://github.com/yfengg/scanlate/blob/main/src/scanlate/workbench/view.py): `src/scanlate/workbench/view.py`
- [Response schemas](https://github.com/yfengg/scanlate/blob/main/src/scanlate/api/schemas.py): `src/scanlate/api/schemas.py`
- [Project repository](https://github.com/yfengg/scanlate/blob/main/src/scanlate/storage/repository.py): `src/scanlate/storage/repository.py`
- [Domain records](https://github.com/yfengg/scanlate/blob/main/src/scanlate/storage/models.py): `src/scanlate/storage/models.py`
- [Transaction boundary](https://github.com/yfengg/scanlate/blob/main/src/scanlate/storage/unit_of_work.py): `src/scanlate/storage/unit_of_work.py`

### Other components

- **Translator**
- **MT backend**

## Connections

- Translator → Workbench UI: uses (evidence: `README.md`)
- Workbench UI → HTTP API: requests (evidence: `README.md`)
- HTTP API → Page routes: routes pages (evidence: `src/scanlate/api/app.py`)
- HTTP API → Translation decisions: calls
- HTTP API → Human approval: calls (evidence: `src/scanlate/api/app.py`)
- HTTP API → Project repository: reads and writes (evidence: `src/scanlate/api/app.py`)
- HTTP API → Response schemas: serializes (evidence: `src/scanlate/api/app.py`)
- Page routes → Page workflow: delegates (evidence: `src/scanlate/api/pages.py`)
- Page routes → Project repository: reads and writes (evidence: `src/scanlate/api/pages.py`)
- Page workflow → Page import: imports pages (evidence: `src/scanlate/imaging/service.py`)
- Page workflow → Region detection: detects regions (evidence: `src/scanlate/imaging/service.py`)
- Page workflow → OCR: reads regions (evidence: `src/scanlate/imaging/service.py`)
- Page workflow → Region geometry: uses geometry (evidence: `src/scanlate/imaging/service.py`)
- Page workflow → Project repository: persists segments (evidence: `src/scanlate/imaging/service.py`)
- Translation decisions → Language adapters: analyzes text (evidence: `src/scanlate/pipeline/pipeline.py`)
- Translation decisions → Project glossary: checks terms (evidence: `src/scanlate/pipeline/pipeline.py`)
- Translation decisions → Translation memory: checks precedent (evidence: `src/scanlate/pipeline/pipeline.py`)
- Translation decisions → Local context: gets context (evidence: `src/scanlate/pipeline/pipeline.py`)
- Translation decisions → Translation validators: reports issues (evidence: `src/scanlate/pipeline/pipeline.py`)
- Translation decisions → SFX rendering: renders SFX (evidence: `src/scanlate/pipeline/pipeline.py`)
- Translation decisions → MT backend: requests candidate (evidence: `src/scanlate/pipeline/pipeline.py`)
- Translation decisions → Project repository: loads segments (evidence: `src/scanlate/pipeline/pipeline.py`)
- Language adapters → Linguistic analysis: produces analysis (evidence: `src/scanlate/core/adapter.py`)
- Japanese adapter → Language adapters: implements (evidence: `src/scanlate/languages/ja/adapter.py`)
- Korean adapter → Language adapters: implements (evidence: `src/scanlate/languages/ko/adapter.py`)
- English adapter → Language adapters: implements (evidence: `src/scanlate/languages/en/adapter.py`)
- SFX rendering → SFX categories: uses categories (evidence: `src/scanlate/sfx/renderer.py`)
- Human approval → Project repository: updates state (evidence: `src/scanlate/pipeline/approval.py`)
- Human approval → Translation memory: records approval (evidence: `src/scanlate/pipeline/approval.py`)
- Human approval → Project glossary: suggests terms (evidence: `src/scanlate/pipeline/approval.py`)
- Human approval → Transaction boundary: commits atomically (evidence: `src/scanlate/pipeline/approval.py`)
- Project glossary → Transaction boundary: uses transactions (evidence: `src/scanlate/glossary/store.py`)
- Translation memory → Transaction boundary: uses transactions (evidence: `src/scanlate/memory/store.py`)
- Project repository → Domain records: maps records (evidence: `src/scanlate/storage/repository.py`)
- Project repository → Transaction boundary: shares boundary (evidence: `src/scanlate/storage/repository.py`)
- HTTP API → Workbench UI: serves page (evidence: `src/scanlate/api/app.py`)
- Translation validators → Project glossary: checks decisions (evidence: `src/scanlate/validation/validators.py`)
