# fishjar/kiss-translator architecture

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

- Interactive diagram: https://gitdiagram.com/fishjar/kiss-translator
- Repository: https://github.com/fishjar/kiss-translator

## Overview

KISS Translator is a browser translation extension and userscript. A user selects text or invokes page translation; the interface sends work through translation APIs to configured built-in or plugin services and presents bilingual results. Separate product stages cover selection/dictionary lookup, webpages and subtitles, and document/image processing. Provider capability selection and local-AI model/runtime management are important internal layers. README documents the broader feature set; several implementation paths are supported only by the tree and are shown without speculative call edges.

Main entry points: [`src/apis/index.js`](https://github.com/fishjar/kiss-translator/blob/dev/src/apis/index.js) (Translation APIs), [`src/libs/translator.js`](https://github.com/fishjar/kiss-translator/blob/dev/src/libs/translator.js) (Webpage translation), [`src/fileTranslation/pipelineCore.js`](https://github.com/fishjar/kiss-translator/blob/dev/src/fileTranslation/pipelineCore.js) (File pipeline), [`src/localAi/core/modelManager.ts`](https://github.com/fishjar/kiss-translator/blob/dev/src/localAi/core/modelManager.ts) (Model manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Translation interaction"]
  node_selection["Selection controller"]
  node_selectionui["Selection UI<br/>[index.js]"]
  node_dict["Dictionary handler<br/>[DictHandler.js]"]
  node_storage[("Settings storage<br/>[storage.js]")]
end

subgraph group_providers["Services and providers"]
  node_api["Translation APIs<br/>[index.js]"]
  node_trans["Translation engines<br/>[trans.js]"]
  node_serviceconfig["Service selection"]
  node_pluginruntime["Plugin runtime<br/>[runtime.js]"]
  node_pluginregistry["Provider plugins<br/>[registry.js]"]
  node_translationservice(("Translation services"))
end

subgraph group_content["Page and media translation"]
  node_page["Webpage translation<br/>[translator.js]"]
  node_rules["Page rules<br/>[rules.js]"]
  node_subtitles["Bilingual subtitles"]
end

subgraph group_documents["File translation"]
  node_fileview["File translation UI<br/>[index.js]"]
  node_filepipeline["File pipeline<br/>[pipelineCore.js]"]
  node_filecache[("Result cache<br/>[resultCache.js]")]
  node_imagemgr["Image translation"]
end

subgraph group_localai["Local AI"]
  node_localmodels["Model manager<br/>[modelManager.ts]"]
  node_localruntime["Inference runtime<br/>[runtimeManager.ts]"]
  node_localcatalog[("Model catalog<br/>[catalog.ts]")]
end

node_user(("User"))

node_user -->|"selects text"| node_selection
node_selection -.->|"opens panel"| node_selectionui
node_selectionui -->|"looks up words"| node_dict
node_dict -->|"requests lookup"| node_api
node_api -->|"delegates translation"| node_trans
node_api -->|"sends requests"| node_translationservice
node_serviceconfig -->|"validates capabilities"| node_pluginregistry
node_pluginruntime -.->|"dispatches plugin calls"| node_translationservice
node_user -->|"starts page translation"| node_page
node_page -.->|"translates page text"| node_api
node_page -.->|"applies rules"| node_rules
node_user -->|"opens subtitles"| node_subtitles
node_subtitles -->|"requests translation"| node_api
node_user -->|"chooses file"| node_fileview
node_fileview -.->|"starts processing"| node_filepipeline
node_filepipeline -->|"reads and writes results"| node_filecache
node_filepipeline -->|"invokes providers"| node_api
node_user -->|"translates image"| node_imagemgr
node_imagemgr -.->|"requests image services"| node_api
node_localmodels -->|"loads catalog"| node_localcatalog
node_localmodels -->|"uses runtime host"| node_localruntime
node_localruntime -->|"manages model state"| node_localmodels
node_api -->|"reads settings"| node_storage

click node_selection "https://github.com/fishjar/kiss-translator/blob/dev/src/hooks/useSelectionController.js"
click node_selectionui "https://github.com/fishjar/kiss-translator/blob/dev/src/views/Selection/index.js"
click node_dict "https://github.com/fishjar/kiss-translator/blob/dev/src/views/Selection/DictHandler.js"
click node_api "https://github.com/fishjar/kiss-translator/blob/dev/src/apis/index.js"
click node_trans "https://github.com/fishjar/kiss-translator/blob/dev/src/apis/trans.js"
click node_serviceconfig "https://github.com/fishjar/kiss-translator/blob/dev/src/config/serviceSelection.js"
click node_pluginruntime "https://github.com/fishjar/kiss-translator/blob/dev/src/builtin-plugins/runtime.js"
click node_pluginregistry "https://github.com/fishjar/kiss-translator/blob/dev/src/providers/registry.js"
click node_page "https://github.com/fishjar/kiss-translator/blob/dev/src/libs/translator.js"
click node_rules "https://github.com/fishjar/kiss-translator/blob/dev/src/libs/rules.js"
click node_subtitles "https://github.com/fishjar/kiss-translator/blob/dev/src/subtitle/BilingualSubtitleManager.js"
click node_fileview "https://github.com/fishjar/kiss-translator/blob/dev/src/views/FileTranslate/index.js"
click node_filepipeline "https://github.com/fishjar/kiss-translator/blob/dev/src/fileTranslation/pipelineCore.js"
click node_filecache "https://github.com/fishjar/kiss-translator/blob/dev/src/fileTranslation/resultCache.js"
click node_imagemgr "https://github.com/fishjar/kiss-translator/blob/dev/src/libs/imageTranslate/imageTranslateManager.js"
click node_localmodels "https://github.com/fishjar/kiss-translator/blob/dev/src/localAi/core/modelManager.ts"
click node_localruntime "https://github.com/fishjar/kiss-translator/blob/dev/src/localAi/runtime/runtimeManager.ts"
click node_localcatalog "https://github.com/fishjar/kiss-translator/blob/dev/src/localAi/core/catalog.ts"
click node_storage "https://github.com/fishjar/kiss-translator/blob/dev/src/libs/storage.js"

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_selection,node_selectionui,node_dict,node_storage,node_user toneBlue
class node_api,node_trans,node_serviceconfig,node_pluginruntime,node_pluginregistry,node_translationservice toneAmber
class node_page,node_rules,node_subtitles toneMint
class node_fileview,node_filepipeline,node_filecache,node_imagemgr toneRose
class node_localmodels,node_localruntime,node_localcatalog toneIndigo
```

## Components

### Translation interaction

- [Selection controller](https://github.com/fishjar/kiss-translator/blob/dev/src/hooks/useSelectionController.js): `src/hooks/useSelectionController.js`
- [Selection UI](https://github.com/fishjar/kiss-translator/blob/dev/src/views/Selection/index.js): `src/views/Selection/index.js`
- [Dictionary handler](https://github.com/fishjar/kiss-translator/blob/dev/src/views/Selection/DictHandler.js): `src/views/Selection/DictHandler.js`
- [Settings storage](https://github.com/fishjar/kiss-translator/blob/dev/src/libs/storage.js): `src/libs/storage.js`

### Services and providers

- [Translation APIs](https://github.com/fishjar/kiss-translator/blob/dev/src/apis/index.js): `src/apis/index.js`
- [Translation engines](https://github.com/fishjar/kiss-translator/blob/dev/src/apis/trans.js): `src/apis/trans.js`
- [Service selection](https://github.com/fishjar/kiss-translator/blob/dev/src/config/serviceSelection.js): `src/config/serviceSelection.js`
- [Plugin runtime](https://github.com/fishjar/kiss-translator/blob/dev/src/builtin-plugins/runtime.js): `src/builtin-plugins/runtime.js`
- [Provider plugins](https://github.com/fishjar/kiss-translator/blob/dev/src/providers/registry.js): `src/providers/registry.js`
- **Translation services**

### Page and media translation

- [Webpage translation](https://github.com/fishjar/kiss-translator/blob/dev/src/libs/translator.js): `src/libs/translator.js`
- [Page rules](https://github.com/fishjar/kiss-translator/blob/dev/src/libs/rules.js): `src/libs/rules.js`
- [Bilingual subtitles](https://github.com/fishjar/kiss-translator/blob/dev/src/subtitle/BilingualSubtitleManager.js): `src/subtitle/BilingualSubtitleManager.js`

### File translation

- [File translation UI](https://github.com/fishjar/kiss-translator/blob/dev/src/views/FileTranslate/index.js): `src/views/FileTranslate/index.js`
- [File pipeline](https://github.com/fishjar/kiss-translator/blob/dev/src/fileTranslation/pipelineCore.js): `src/fileTranslation/pipelineCore.js`
- [Result cache](https://github.com/fishjar/kiss-translator/blob/dev/src/fileTranslation/resultCache.js): `src/fileTranslation/resultCache.js`
- [Image translation](https://github.com/fishjar/kiss-translator/blob/dev/src/libs/imageTranslate/imageTranslateManager.js): `src/libs/imageTranslate/imageTranslateManager.js`

### Local AI

- [Model manager](https://github.com/fishjar/kiss-translator/blob/dev/src/localAi/core/modelManager.ts): `src/localAi/core/modelManager.ts`
- [Inference runtime](https://github.com/fishjar/kiss-translator/blob/dev/src/localAi/runtime/runtimeManager.ts): `src/localAi/runtime/runtimeManager.ts`
- [Model catalog](https://github.com/fishjar/kiss-translator/blob/dev/src/localAi/core/catalog.ts): `src/localAi/core/catalog.ts`

### Other components

- **User**

## Connections

- User → Selection controller: selects text (evidence: `README.md`)
- Selection controller → Selection UI: opens panel
- Selection UI → Dictionary handler: looks up words (evidence: `src/views/Selection/DictHandler.js`)
- Dictionary handler → Translation APIs: requests lookup (evidence: `src/views/Selection/DictHandler.js`)
- Translation APIs → Translation engines: delegates translation (evidence: `src/apis/index.js`)
- Translation APIs → Translation services: sends requests (evidence: `README.md`)
- Service selection → Provider plugins: validates capabilities (evidence: `src/config/serviceSelection.js`)
- Plugin runtime → Translation services: dispatches plugin calls
- User → Webpage translation: starts page translation (evidence: `README.md`)
- Webpage translation → Translation APIs: translates page text
- Webpage translation → Page rules: applies rules
- User → Bilingual subtitles: opens subtitles (evidence: `README.md`)
- Bilingual subtitles → Translation APIs: requests translation (evidence: `src/subtitle/BilingualSubtitleManager.js`)
- User → File translation UI: chooses file (evidence: `README.md`)
- File translation UI → File pipeline: starts processing
- File pipeline → Result cache: reads and writes results (evidence: `src/fileTranslation/pipelineCore.js`)
- File pipeline → Translation APIs: invokes providers (evidence: `src/fileTranslation/pipelineCore.js`)
- User → Image translation: translates image (evidence: `README.md`)
- Image translation → Translation APIs: requests image services
- Model manager → Model catalog: loads catalog (evidence: `src/localAi/core/modelManager.ts`)
- Model manager → Inference runtime: uses runtime host (evidence: `src/localAi/core/modelManager.ts`)
- Inference runtime → Model manager: manages model state (evidence: `src/localAi/runtime/runtimeManager.ts`)
- Translation APIs → Settings storage: reads settings (evidence: `src/apis/index.js`)
