# muanyan-mjq/zotero-interlinear architecture

> Architecture diagram of the GitHub repository muanyan-mjq/zotero-interlinear, 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/muanyan-mjq/zotero-interlinear
- Repository: https://github.com/muanyan-mjq/zotero-interlinear

## Overview

Interlinear is a Zotero desktop-reader plugin for translating structured PDF paragraphs inline. Its main workflow runs from reader interaction through translation orchestration and a selected service, then renders and caches results. The README also documents chat assistance, bilingual export, glossary enforcement, appearance controls, and alternate reader layouts. Sampled source supports key reader, provider, settings, and cache links; other feature links rely on README statements, so unsampled implementation details are not inferred.

Main entry points: [`src/bilingualReader.ts`](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/bilingualReader.ts) (Reader orchestration), [`src/settings.ts`](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/settings.ts) (Settings and preferences), [`src/modules/preferenceScript.ts`](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/modules/preferenceScript.ts) (Settings interface), [`src/providers/index.ts`](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/index.ts) (Provider registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reader["Reader experience"]
  node_bilingual["Reader orchestration<br/>[bilingualReader.ts]"]
  node_reader_ui["Reader controls<br/>[readerUI.ts]"]
  node_interactions["Paragraph interactions"]
  node_display["Display modes<br/>[displayMode.ts]"]
  node_highlight["Linked highlighting<br/>[readerHighlight.ts]"]
  node_layout["Reading layouts<br/>[readingLayout.ts]"]
  node_scroll["Split-pane scrolling"]
end

subgraph group_translation["Translation runtime"]
  node_pipeline["Batch preparation"]
  node_cache[("Translation cache")]
  node_format["Translation formatting"]
end

subgraph group_providers["Translation services"]
  node_provider_registry["Provider registry<br/>[index.ts]"]
  node_free_router["Free-service routing<br/>[free.ts]"]
  node_google["Google Translate<br/>[google.ts]"]
  node_chat_provider["LLM chat requests<br/>[chat.ts]"]
  node_secure_request["Secure HTTP requests<br/>[secureRequest.ts]"]
end

subgraph group_preferences["Configuration and appearance"]
  node_settings["Settings and preferences<br/>[settings.ts]"]
  node_preference_ui["Settings interface"]
  node_appearance["Appearance controls<br/>[appearance.ts]"]
  node_font_catalog["Font catalog<br/>[fontCatalog.ts]"]
end

subgraph group_support["Reader support"]
  node_glossary["Glossary<br/>[glossary.ts]"]
  node_chat["Reading assistant<br/>[chatPane.ts]"]
  node_chat_context["Chat context<br/>[chatContext.ts]"]
  node_export["Bilingual PDF export<br/>[exportLayout.ts]"]
end

node_zotero(("Zotero reader"))

node_zotero -->|"opens reader"| node_bilingual
node_bilingual -->|"prepares batches"| node_pipeline
node_bilingual -->|"requests translations"| node_provider_registry
node_bilingual -->|"loads cached results"| node_cache
node_bilingual -->|"renders translations"| node_format
node_provider_registry -->|"dispatches free service"| node_free_router
node_provider_registry -->|"dispatches chat"| node_chat_provider
node_free_router -->|"uses Google backend"| node_google
node_chat_provider -->|"sends requests"| node_secure_request
node_bilingual -->|"reads translation settings"| node_settings
node_settings -->|"configures glossary terms"| node_glossary
node_settings -->|"stores appearance options"| node_appearance
node_preference_ui -->|"saves preferences"| node_settings
node_preference_ui -->|"edits appearance"| node_appearance
node_preference_ui -->|"uses font detection"| node_font_catalog
node_zotero -->|"uses reader controls"| node_reader_ui
node_reader_ui -.->|"controls translation runs"| node_bilingual
node_interactions -.->|"triggers paragraph translation"| node_bilingual
node_bilingual -->|"cycles display modes"| node_display
node_bilingual -->|"starts pane synchronization"| node_scroll
node_bilingual -.->|"updates linked highlights"| node_highlight
node_bilingual -.->|"renders reader layouts"| node_layout
node_zotero -->|"asks reading questions"| node_chat
node_chat -.->|"uses document context"| node_chat_context
node_chat -.->|"sends assistant turns"| node_chat_provider
node_zotero -->|"exports bilingual PDF"| node_export
node_bilingual -.->|"applies glossary"| node_glossary

click node_bilingual "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/bilingualReader.ts"
click node_reader_ui "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerUI.ts"
click node_interactions "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerInteractions.ts"
click node_display "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/displayMode.ts"
click node_highlight "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerHighlight.ts"
click node_layout "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readingLayout.ts"
click node_scroll "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerScrollSync.ts"
click node_pipeline "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/translationPipeline.ts"
click node_cache "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/translationCache.ts"
click node_format "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/translationFormat.ts"
click node_provider_registry "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/index.ts"
click node_free_router "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/free.ts"
click node_google "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/google.ts"
click node_chat_provider "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/chat.ts"
click node_secure_request "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/secureRequest.ts"
click node_settings "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/settings.ts"
click node_preference_ui "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/modules/preferenceScript.ts"
click node_appearance "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/appearance.ts"
click node_font_catalog "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/fontCatalog.ts"
click node_glossary "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/glossary.ts"
click node_chat "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/chatPane.ts"
click node_chat_context "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/chatContext.ts"
click node_export "https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/exportLayout.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_bilingual,node_reader_ui,node_interactions,node_display,node_highlight,node_layout,node_scroll toneBlue
class node_pipeline,node_cache,node_format toneAmber
class node_provider_registry,node_free_router,node_google,node_chat_provider,node_secure_request toneMint
class node_settings,node_preference_ui,node_appearance,node_font_catalog toneRose
class node_glossary,node_chat,node_chat_context,node_export,node_zotero toneIndigo
```

## Components

### Reader experience

- [Reader orchestration](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/bilingualReader.ts): `src/bilingualReader.ts`
- [Reader controls](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerUI.ts): `src/readerUI.ts`
- [Paragraph interactions](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerInteractions.ts): `src/readerInteractions.ts`
- [Display modes](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/displayMode.ts): `src/displayMode.ts`
- [Linked highlighting](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerHighlight.ts): `src/readerHighlight.ts`
- [Reading layouts](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readingLayout.ts): `src/readingLayout.ts`
- [Split-pane scrolling](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/readerScrollSync.ts): `src/readerScrollSync.ts`

### Translation runtime

- [Batch preparation](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/translationPipeline.ts): `src/translationPipeline.ts`
- [Translation cache](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/translationCache.ts): `src/translationCache.ts`
- [Translation formatting](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/translationFormat.ts): `src/translationFormat.ts`

### Translation services

- [Provider registry](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/index.ts): `src/providers/index.ts`
- [Free-service routing](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/free.ts): `src/providers/free.ts`
- [Google Translate](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/google.ts): `src/providers/google.ts`
- [LLM chat requests](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/chat.ts): `src/providers/chat.ts`
- [Secure HTTP requests](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/providers/secureRequest.ts): `src/providers/secureRequest.ts`

### Configuration and appearance

- [Settings and preferences](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/settings.ts): `src/settings.ts`
- [Settings interface](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/modules/preferenceScript.ts): `src/modules/preferenceScript.ts`
- [Appearance controls](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/appearance.ts): `src/appearance.ts`
- [Font catalog](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/fontCatalog.ts): `src/fontCatalog.ts`

### Reader support

- [Glossary](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/glossary.ts): `src/glossary.ts`
- [Reading assistant](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/chatPane.ts): `src/chatPane.ts`
- [Chat context](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/chatContext.ts): `src/chatContext.ts`
- [Bilingual PDF export](https://github.com/muanyan-mjq/zotero-interlinear/blob/main/src/exportLayout.ts): `src/exportLayout.ts`

### Other components

- **Zotero reader**

## Connections

- Zotero reader → Reader orchestration: opens reader (evidence: `README.md`)
- Reader orchestration → Batch preparation: prepares batches (evidence: `src/bilingualReader.ts`)
- Reader orchestration → Provider registry: requests translations (evidence: `src/bilingualReader.ts`)
- Reader orchestration → Translation cache: loads cached results (evidence: `src/bilingualReader.ts`)
- Reader orchestration → Translation formatting: renders translations (evidence: `src/bilingualReader.ts`)
- Provider registry → Free-service routing: dispatches free service (evidence: `src/providers/index.ts`)
- Provider registry → LLM chat requests: dispatches chat (evidence: `src/providers/index.ts`)
- Free-service routing → Google Translate: uses Google backend (evidence: `src/providers/free.ts`)
- LLM chat requests → Secure HTTP requests: sends requests (evidence: `src/providers/chat.ts`)
- Reader orchestration → Settings and preferences: reads translation settings (evidence: `src/bilingualReader.ts`)
- Settings and preferences → Glossary: configures glossary terms (evidence: `src/settings.ts`)
- Settings and preferences → Appearance controls: stores appearance options (evidence: `src/settings.ts`)
- Settings interface → Settings and preferences: saves preferences (evidence: `src/modules/preferenceScript.ts`)
- Settings interface → Appearance controls: edits appearance (evidence: `src/modules/preferenceScript.ts`)
- Settings interface → Font catalog: uses font detection (evidence: `src/modules/preferenceScript.ts`)
- Zotero reader → Reader controls: uses reader controls (evidence: `README.md`)
- Reader controls → Reader orchestration: controls translation runs (evidence: `src/bilingualReader.ts`)
- Paragraph interactions → Reader orchestration: triggers paragraph translation (evidence: `src/bilingualReader.ts`)
- Reader orchestration → Display modes: cycles display modes (evidence: `src/bilingualReader.ts`)
- Reader orchestration → Split-pane scrolling: starts pane synchronization (evidence: `src/bilingualReader.ts`)
- Reader orchestration → Linked highlighting: updates linked highlights (evidence: `src/bilingualReader.ts`)
- Reader orchestration → Reading layouts: renders reader layouts (evidence: `src/bilingualReader.ts`)
- Zotero reader → Reading assistant: asks reading questions (evidence: `README.md`)
- Reading assistant → Chat context: uses document context
- Reading assistant → LLM chat requests: sends assistant turns
- Zotero reader → Bilingual PDF export: exports bilingual PDF (evidence: `README.md`)
- Reader orchestration → Glossary: applies glossary (evidence: `src/bilingualReader.ts`)
