# amirwolf512k/manga-autotranslate architecture

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

- Interactive diagram: https://gitdiagram.com/amirwolf512k/manga-autotranslate
- Repository: https://github.com/amirwolf512k/manga-autotranslate

## Overview

Manga AutoTranslate processes manga chapters from folders, images, archives, PDFs, or URLs into translated, cleaned, Persian-rendered pages and PDF/ZIP/HTML/PSD outputs. The principal workflow is input acquisition and extraction, bubble detection/OCR, chapter-level API translation, two-image cleanup, then rendering and export; desktop/web/CLI interfaces and Android are front ends to the same Python engine. The graph also preserves the browser image-extraction capability and Android’s native OCR implementation. Relationships among Python stages are based on README workflow descriptions; unsampled modules may have additional wiring not shown here.

Main entry points: [`manga_sections/95_run.py`](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/95_run.py) (Pipeline runner), [`android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt`](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt) (OCR engine facade), [`manga_sections/80_translate.py`](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/80_translate.py) (Chapter translation), [`android/app/src/main/java/com/amirwolf/mangatranslator/MainActivity.kt`](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/app/src/main/java/com/amirwolf/mangatranslator/MainActivity.kt) (Android application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_desktop_web_cli["Desktop, web, CLI<br/>[manga_app.py]"]
end

subgraph group_acquisition["Input acquisition"]
  node_browser_extract["Image extractor<br/>[content.js]"]
  node_extract_worker["Extractor background<br/>[background.js]"]
  node_input["Chapter inputs<br/>[60_input.py]"]
  node_chapter_extract["Page extraction<br/>[70_extract.py]"]
end

subgraph group_translation["Translation engine"]
  node_runner["Pipeline runner<br/>[95_run.py]"]
  node_ocr["Bubble detection and OCR<br/>[30_ocr.py]"]
  node_translate["Chapter translation<br/>[80_translate.py]"]
  node_api["Translation providers<br/>[50_translator.py]"]
  node_api_text["API text handling<br/>[40_api_text.py]"]
end

subgraph group_image["Image processing"]
  node_cleanup["Bubble cleanup<br/>[85_cleanup.py]"]
  node_render["Persian page rendering<br/>[90_render.py]"]
  node_output["Export formats<br/>[95_run.py]"]
end

subgraph group_android["Android runtime"]
  node_android_ui["Android application<br/>[MainActivity.kt]"]
  node_android_bridge["Python bridge<br/>[bridge.py]"]
  node_android_server["Android app server<br/>[app_server.py]"]
  node_ocr_facade["OCR engine facade<br/>[OCREngine.kt]"]
  node_detect_engine["Detection engine<br/>[DetectionEngine.kt]"]
  node_recognize_engine["Recognition engine"]
  node_ort[("ONNX sessions")]
  node_android_result["OCR results<br/>[OCREngineResult.kt]"]
end

node_user(("Manga user"))

node_user -->|"starts job"| node_desktop_web_cli
node_desktop_web_cli -->|"submits chapter"| node_runner
node_user -->|"requests images"| node_browser_extract
node_browser_extract -.->|"sends extraction"| node_extract_worker
node_extract_worker -.->|"provides URLs"| node_input
node_runner -->|"loads inputs"| node_input
node_runner -->|"extracts pages"| node_chapter_extract
node_runner -->|"runs OCR"| node_ocr
node_runner -->|"translates chapter"| node_translate
node_translate -->|"requests translation"| node_api
node_translate -.->|"handles API text"| node_api_text
node_runner -->|"cleans bubbles"| node_cleanup
node_runner -->|"renders pages"| node_render
node_runner -->|"exports files"| node_output
node_user -->|"starts mobile job"| node_android_ui
node_android_ui -->|"calls Python bridge"| node_android_bridge
node_android_bridge -->|"uses shared engine"| node_runner
node_android_ui -.->|"runs app server"| node_android_server
node_ocr_facade -->|"detects text boxes"| node_detect_engine
node_ocr_facade -->|"recognizes crops"| node_recognize_engine
node_detect_engine -->|"runs detection"| node_ort
node_recognize_engine -->|"runs recognition"| node_ort
node_ocr_facade -->|"returns OCR"| node_android_result

click node_desktop_web_cli "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_app.py"
click node_browser_extract "https://github.com/amirwolf512k/manga-autotranslate/blob/main/extract/content.js"
click node_extract_worker "https://github.com/amirwolf512k/manga-autotranslate/blob/main/extract/background.js"
click node_input "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/60_input.py"
click node_chapter_extract "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/70_extract.py"
click node_runner "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/95_run.py"
click node_ocr "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/30_ocr.py"
click node_translate "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/80_translate.py"
click node_api "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/50_translator.py"
click node_api_text "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/40_api_text.py"
click node_cleanup "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/85_cleanup.py"
click node_render "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/90_render.py"
click node_output "https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/95_run.py"
click node_android_ui "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/app/src/main/java/com/amirwolf/mangatranslator/MainActivity.kt"
click node_android_bridge "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/app/src/main/python/bridge.py"
click node_android_server "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/app/src/main/python/app_server.py"
click node_ocr_facade "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt"
click node_detect_engine "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/DetectionEngine.kt"
click node_recognize_engine "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/RecognitionEngine.kt"
click node_ort "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/ORTSessionManager.kt"
click node_android_result "https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngineResult.kt"

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_desktop_web_cli,node_user toneBlue
class node_browser_extract,node_extract_worker,node_input,node_chapter_extract toneAmber
class node_runner,node_ocr,node_translate,node_api,node_api_text toneMint
class node_cleanup,node_render,node_output toneRose
class node_android_ui,node_android_bridge,node_android_server,node_ocr_facade,node_detect_engine,node_recognize_engine,node_ort,node_android_result toneIndigo
```

## Components

### User interfaces

- [Desktop, web, CLI](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_app.py): `manga_app.py`

### Input acquisition

- [Image extractor](https://github.com/amirwolf512k/manga-autotranslate/blob/main/extract/content.js): `extract/content.js`
- [Extractor background](https://github.com/amirwolf512k/manga-autotranslate/blob/main/extract/background.js): `extract/background.js`
- [Chapter inputs](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/60_input.py): `manga_sections/60_input.py`
- [Page extraction](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/70_extract.py): `manga_sections/70_extract.py`

### Translation engine

- [Pipeline runner](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/95_run.py): `manga_sections/95_run.py`
- [Bubble detection and OCR](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/30_ocr.py): `manga_sections/30_ocr.py`
- [Chapter translation](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/80_translate.py): `manga_sections/80_translate.py`
- [Translation providers](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/50_translator.py): `manga_sections/50_translator.py`
- [API text handling](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/40_api_text.py): `manga_sections/40_api_text.py`

### Image processing

- [Bubble cleanup](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/85_cleanup.py): `manga_sections/85_cleanup.py`
- [Persian page rendering](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/90_render.py): `manga_sections/90_render.py`
- [Export formats](https://github.com/amirwolf512k/manga-autotranslate/blob/main/manga_sections/95_run.py): `manga_sections/95_run.py`

### Android runtime

- [Android application](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/app/src/main/java/com/amirwolf/mangatranslator/MainActivity.kt): `android/app/src/main/java/com/amirwolf/mangatranslator/MainActivity.kt`
- [Python bridge](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/app/src/main/python/bridge.py): `android/app/src/main/python/bridge.py`
- [Android app server](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/app/src/main/python/app_server.py): `android/app/src/main/python/app_server.py`
- [OCR engine facade](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt): `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt`
- [Detection engine](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/DetectionEngine.kt): `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/DetectionEngine.kt`
- [Recognition engine](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/RecognitionEngine.kt): `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/RecognitionEngine.kt`
- [ONNX sessions](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/ORTSessionManager.kt): `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/ORTSessionManager.kt`
- [OCR results](https://github.com/amirwolf512k/manga-autotranslate/blob/main/android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngineResult.kt): `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngineResult.kt`

### Other components

- **Manga user**

## Connections

- Manga user → Desktop, web, CLI: starts job
- Desktop, web, CLI → Pipeline runner: submits chapter
- Manga user → Image extractor: requests images
- Image extractor → Extractor background: sends extraction
- Extractor background → Chapter inputs: provides URLs
- Pipeline runner → Chapter inputs: loads inputs
- Pipeline runner → Page extraction: extracts pages
- Pipeline runner → Bubble detection and OCR: runs OCR
- Pipeline runner → Chapter translation: translates chapter
- Chapter translation → Translation providers: requests translation
- Chapter translation → API text handling: handles API text
- Pipeline runner → Bubble cleanup: cleans bubbles
- Pipeline runner → Persian page rendering: renders pages
- Pipeline runner → Export formats: exports files (evidence: `manga_sections/95_run.py`)
- Manga user → Android application: starts mobile job
- Android application → Python bridge: calls Python bridge (evidence: `android/app/src/main/java/com/amirwolf/mangatranslator/MainActivity.kt`)
- Python bridge → Pipeline runner: uses shared engine (evidence: `android/app/src/main/python/bridge.py`)
- Android application → Android app server: runs app server
- OCR engine facade → Detection engine: detects text boxes (evidence: `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt`)
- OCR engine facade → Recognition engine: recognizes crops (evidence: `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt`)
- Detection engine → ONNX sessions: runs detection (evidence: `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/DetectionEngine.kt`)
- Recognition engine → ONNX sessions: runs recognition (evidence: `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/RecognitionEngine.kt`)
- OCR engine facade → OCR results: returns OCR (evidence: `android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt`)
