# unheat/kites architecture

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

- Interactive diagram: https://gitdiagram.com/unheat/kites
- Repository: https://github.com/unheat/kites

## Overview

Kites is a Chrome extension for translating manga and webtoon images in-browser, with a companion Studio and an optional provider worker. The principal flow starts with a page image or crop, passes through extension messaging into image analysis and translation, then renders translated text back into the reading experience. The graph also preserves chapter reading, model controls, Studio editing/export, and worker services. Several implementation links are based on README descriptions; unsampled subsystem internals and their exact dispatch paths are not inferred.

Main entry points: [`src/offscreen/services/PipelineOrchestrator.ts`](https://github.com/unheat/kites/blob/main/src/offscreen/services/PipelineOrchestrator.ts) (Image pipeline), [`src/popup/components/EngineSelectionPanel.tsx`](https://github.com/unheat/kites/blob/main/src/popup/components/EngineSelectionPanel.tsx) (Engine controls), [`src/content/index.tsx`](https://github.com/unheat/kites/blob/main/src/content/index.tsx) (Manga reader), [`src/background/index.ts`](https://github.com/unheat/kites/blob/main/src/background/index.ts) (Job coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reading["Reading experience"]
  node_reader["Manga reader<br/>[index.tsx]"]
  node_media["Media targeting<br/>[mediaTargets.ts]"]
  node_chapter["Chapter reader"]
  node_zip["Chapter ZIP export<br/>[chapterZip.ts]"]
end

subgraph group_runtime["Translation runtime"]
  node_background["Job coordinator<br/>[index.ts]"]
  node_database[("Job storage<br/>[db.ts]")]
  node_pipeline["Image pipeline"]
  node_ocr["Text detection<br/>[PaddleOcrEngine.ts]"]
  node_ocrregistry["OCR registry<br/>[ocrRegistry.ts]"]
  node_bubbles["Bubble detection"]
  node_translation["Text translation"]
  node_inpaint["Background repair"]
  node_typesetting["Text typesetting"]
  node_color["Manga colorization"]
  node_geometry["Geometry utilities<br/>[geometry.ts]"]
end

subgraph group_models["Models and settings"]
  node_hardware["Hardware selection<br/>[hardware.ts]"]
  node_popup["Engine controls"]
  node_ordering["Engine ordering<br/>[engineOrdering.ts]"]
  node_customapi["Custom providers<br/>[customApi.ts]"]
  node_sharedconfig["Translation preferences<br/>[glossary.ts]"]
  node_colorconfig["Color tiers<br/>[colorTiers.ts]"]
  node_inpaintconfig["Inpaint tiers<br/>[inpaintTiers.ts]"]
  node_fontconfig["Font presets"]
  node_siteconfig["Site rules<br/>[siteRules.ts]"]
end

subgraph group_studio["Studio editing"]
  node_studio["Studio editor<br/>[Studio.tsx]"]
  node_studioapp["Studio dashboard<br/>[App.tsx]"]
  node_studioexport["Studio export<br/>[psdExport.ts]"]
end

subgraph group_worker["Provider worker"]
  node_worker["Translation API worker<br/>[index.ts]"]
end

node_provider(("External AI provider"))
node_readeruser(("Reader"))

node_readeruser -->|"uses"| node_reader
node_reader -->|"targets media"| node_media
node_reader -->|"sends requests"| node_background
node_background -->|"dispatches jobs"| node_pipeline
node_background -->|"stores jobs"| node_database
node_pipeline -.->|"detects text"| node_ocr
node_pipeline -.->|"detects bubbles"| node_bubbles
node_pipeline -.->|"translates text"| node_translation
node_pipeline -.->|"repairs backgrounds"| node_inpaint
node_pipeline -.->|"lays out text"| node_typesetting
node_pipeline -.->|"colorizes artwork"| node_color
node_ocr -->|"resolves tier"| node_ocrregistry
node_ocr -->|"checks WebGPU"| node_hardware
node_popup -->|"orders engines"| node_ordering
node_popup -.->|"configures providers"| node_customapi
node_popup -.->|"configures translation"| node_sharedconfig
node_popup -->|"configures color"| node_colorconfig
node_popup -->|"configures repair"| node_inpaintconfig
node_popup -->|"configures fonts"| node_fontconfig
node_reader -->|"matches site rules"| node_siteconfig
node_color -->|"uses geometry"| node_geometry
node_reader -->|"opens reader"| node_chapter
node_chapter -->|"exports chapter"| node_zip
node_studioapp -->|"loads jobs"| node_database
node_studioapp -->|"opens editor"| node_studio
node_studio -.->|"exports artwork"| node_studioexport
node_translation -.->|"optional remote translation"| node_worker
node_worker -.->|"dispatches requests"| node_provider

click node_reader "https://github.com/unheat/kites/blob/main/src/content/index.tsx"
click node_media "https://github.com/unheat/kites/blob/main/src/content/mediaTargets.ts"
click node_chapter "https://github.com/unheat/kites/blob/main/src/content/ChapterReaderModal.tsx"
click node_zip "https://github.com/unheat/kites/blob/main/src/content/chapterZip.ts"
click node_background "https://github.com/unheat/kites/blob/main/src/background/index.ts"
click node_database "https://github.com/unheat/kites/blob/main/src/db.ts"
click node_pipeline "https://github.com/unheat/kites/blob/main/src/offscreen/services/PipelineOrchestrator.ts"
click node_ocr "https://github.com/unheat/kites/blob/main/src/offscreen/engines/ocr/PaddleOcrEngine.ts"
click node_ocrregistry "https://github.com/unheat/kites/blob/main/src/offscreen/engines/ocr/ocrRegistry.ts"
click node_bubbles "https://github.com/unheat/kites/blob/main/src/offscreen/engines/bubble/NeuralBubbleEngine.ts"
click node_translation "https://github.com/unheat/kites/blob/main/src/offscreen/services/TranslationManager.ts"
click node_inpaint "https://github.com/unheat/kites/blob/main/src/offscreen/engines/inpaint/LamaBaseInpaintEngine.ts"
click node_typesetting "https://github.com/unheat/kites/blob/main/src/offscreen/engines/typeset/AutoBalloonTypesetter.ts"
click node_color "https://github.com/unheat/kites/blob/main/src/offscreen/engines/color/MangaColorizeEngine.ts"
click node_hardware "https://github.com/unheat/kites/blob/main/src/offscreen/utils/hardware.ts"
click node_popup "https://github.com/unheat/kites/blob/main/src/popup/components/EngineSelectionPanel.tsx"
click node_ordering "https://github.com/unheat/kites/blob/main/src/shared/engineOrdering.ts"
click node_customapi "https://github.com/unheat/kites/blob/main/src/shared/customApi.ts"
click node_sharedconfig "https://github.com/unheat/kites/blob/main/src/shared/glossary.ts"
click node_colorconfig "https://github.com/unheat/kites/blob/main/src/shared/colorTiers.ts"
click node_inpaintconfig "https://github.com/unheat/kites/blob/main/src/shared/inpaintTiers.ts"
click node_fontconfig "https://github.com/unheat/kites/blob/main/src/shared/renderFontPresets.ts"
click node_siteconfig "https://github.com/unheat/kites/blob/main/src/shared/siteRules.ts"
click node_geometry "https://github.com/unheat/kites/blob/main/src/shared/utils/geometry.ts"
click node_studio "https://github.com/unheat/kites/blob/main/src/studio/Studio.tsx"
click node_studioapp "https://github.com/unheat/kites/blob/main/src/App.tsx"
click node_studioexport "https://github.com/unheat/kites/blob/main/src/studio/export/psdExport.ts"
click node_worker "https://github.com/unheat/kites/blob/main/worker/src/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_reader,node_media,node_chapter,node_zip toneBlue
class node_background,node_database,node_pipeline,node_ocr,node_ocrregistry,node_bubbles,node_translation,node_inpaint,node_typesetting,node_color,node_geometry toneAmber
class node_hardware,node_popup,node_ordering,node_customapi,node_sharedconfig,node_colorconfig,node_inpaintconfig,node_fontconfig,node_siteconfig toneMint
class node_studio,node_studioapp,node_studioexport toneRose
class node_worker,node_provider,node_readeruser toneIndigo
```

## Components

### Reading experience

- [Manga reader](https://github.com/unheat/kites/blob/main/src/content/index.tsx): `src/content/index.tsx`
- [Media targeting](https://github.com/unheat/kites/blob/main/src/content/mediaTargets.ts): `src/content/mediaTargets.ts`
- [Chapter reader](https://github.com/unheat/kites/blob/main/src/content/ChapterReaderModal.tsx): `src/content/ChapterReaderModal.tsx`
- [Chapter ZIP export](https://github.com/unheat/kites/blob/main/src/content/chapterZip.ts): `src/content/chapterZip.ts`

### Translation runtime

- [Job coordinator](https://github.com/unheat/kites/blob/main/src/background/index.ts): `src/background/index.ts`
- [Job storage](https://github.com/unheat/kites/blob/main/src/db.ts): `src/db.ts`
- [Image pipeline](https://github.com/unheat/kites/blob/main/src/offscreen/services/PipelineOrchestrator.ts): `src/offscreen/services/PipelineOrchestrator.ts`
- [Text detection](https://github.com/unheat/kites/blob/main/src/offscreen/engines/ocr/PaddleOcrEngine.ts): `src/offscreen/engines/ocr/PaddleOcrEngine.ts`
- [OCR registry](https://github.com/unheat/kites/blob/main/src/offscreen/engines/ocr/ocrRegistry.ts): `src/offscreen/engines/ocr/ocrRegistry.ts`
- [Bubble detection](https://github.com/unheat/kites/blob/main/src/offscreen/engines/bubble/NeuralBubbleEngine.ts): `src/offscreen/engines/bubble/NeuralBubbleEngine.ts`
- [Text translation](https://github.com/unheat/kites/blob/main/src/offscreen/services/TranslationManager.ts): `src/offscreen/services/TranslationManager.ts`
- [Background repair](https://github.com/unheat/kites/blob/main/src/offscreen/engines/inpaint/LamaBaseInpaintEngine.ts): `src/offscreen/engines/inpaint/LamaBaseInpaintEngine.ts`
- [Text typesetting](https://github.com/unheat/kites/blob/main/src/offscreen/engines/typeset/AutoBalloonTypesetter.ts): `src/offscreen/engines/typeset/AutoBalloonTypesetter.ts`
- [Manga colorization](https://github.com/unheat/kites/blob/main/src/offscreen/engines/color/MangaColorizeEngine.ts): `src/offscreen/engines/color/MangaColorizeEngine.ts`
- [Geometry utilities](https://github.com/unheat/kites/blob/main/src/shared/utils/geometry.ts): `src/shared/utils/geometry.ts`

### Models and settings

- [Hardware selection](https://github.com/unheat/kites/blob/main/src/offscreen/utils/hardware.ts): `src/offscreen/utils/hardware.ts`
- [Engine controls](https://github.com/unheat/kites/blob/main/src/popup/components/EngineSelectionPanel.tsx): `src/popup/components/EngineSelectionPanel.tsx`
- [Engine ordering](https://github.com/unheat/kites/blob/main/src/shared/engineOrdering.ts): `src/shared/engineOrdering.ts`
- [Custom providers](https://github.com/unheat/kites/blob/main/src/shared/customApi.ts): `src/shared/customApi.ts`
- [Translation preferences](https://github.com/unheat/kites/blob/main/src/shared/glossary.ts): `src/shared/glossary.ts`
- [Color tiers](https://github.com/unheat/kites/blob/main/src/shared/colorTiers.ts): `src/shared/colorTiers.ts`
- [Inpaint tiers](https://github.com/unheat/kites/blob/main/src/shared/inpaintTiers.ts): `src/shared/inpaintTiers.ts`
- [Font presets](https://github.com/unheat/kites/blob/main/src/shared/renderFontPresets.ts): `src/shared/renderFontPresets.ts`
- [Site rules](https://github.com/unheat/kites/blob/main/src/shared/siteRules.ts): `src/shared/siteRules.ts`

### Studio editing

- [Studio editor](https://github.com/unheat/kites/blob/main/src/studio/Studio.tsx): `src/studio/Studio.tsx`
- [Studio dashboard](https://github.com/unheat/kites/blob/main/src/App.tsx): `src/App.tsx`
- [Studio export](https://github.com/unheat/kites/blob/main/src/studio/export/psdExport.ts): `src/studio/export/psdExport.ts`

### Provider worker

- [Translation API worker](https://github.com/unheat/kites/blob/main/worker/src/index.ts): `worker/src/index.ts`

### Other components

- **External AI provider**
- **Reader**

## Connections

- Reader → Manga reader: uses (evidence: `README.md`)
- Manga reader → Media targeting: targets media (evidence: `src/content/index.tsx`)
- Manga reader → Job coordinator: sends requests
- Job coordinator → Image pipeline: dispatches jobs
- Job coordinator → Job storage: stores jobs (evidence: `src/background/index.ts`)
- Image pipeline → Text detection: detects text
- Image pipeline → Bubble detection: detects bubbles
- Image pipeline → Text translation: translates text
- Image pipeline → Background repair: repairs backgrounds
- Image pipeline → Text typesetting: lays out text
- Image pipeline → Manga colorization: colorizes artwork
- Text detection → OCR registry: resolves tier (evidence: `src/offscreen/engines/ocr/PaddleOcrEngine.ts`)
- Text detection → Hardware selection: checks WebGPU (evidence: `src/offscreen/engines/ocr/PaddleOcrEngine.ts`)
- Engine controls → Engine ordering: orders engines (evidence: `src/popup/components/EngineSelectionPanel.tsx`)
- Engine controls → Custom providers: configures providers
- Engine controls → Translation preferences: configures translation
- Engine controls → Color tiers: configures color (evidence: `src/popup/components/EngineSelectionPanel.tsx`)
- Engine controls → Inpaint tiers: configures repair (evidence: `src/popup/components/EngineSelectionPanel.tsx`)
- Engine controls → Font presets: configures fonts (evidence: `src/popup/components/EngineSelectionPanel.tsx`)
- Manga reader → Site rules: matches site rules (evidence: `src/content/index.tsx`)
- Manga colorization → Geometry utilities: uses geometry (evidence: `src/offscreen/engines/color/MangaColorizeEngine.ts`)
- Manga reader → Chapter reader: opens reader (evidence: `src/content/index.tsx`)
- Chapter reader → Chapter ZIP export: exports chapter (evidence: `src/content/index.tsx`)
- Studio dashboard → Job storage: loads jobs (evidence: `src/App.tsx`)
- Studio dashboard → Studio editor: opens editor (evidence: `src/App.tsx`)
- Studio editor → Studio export: exports artwork
- Text translation → Translation API worker: optional remote translation
- Translation API worker → External AI provider: dispatches requests
