# zt-fang/eyeopener-translator architecture

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

- Interactive diagram: https://gitdiagram.com/zt-fang/eyeopener-translator
- Repository: https://github.com/zt-fang/eyeopener-translator

## Overview

EyeOpener is an Android real-time speech translation app that overlays subtitles on other apps. The main flow captures microphone or device audio, filters speech, recognizes it with a language-selected offline engine, translates finalized text, and presents subtitle state in a movable floating window; model downloads and settings support that flow. The README also documents history, an AI chat assistant, cloud/AI translation, and personalization. Edges are limited to README statements and shown source references/calls; several UI and translation implementations were not sampled, so their internal wiring is omitted.

Main entry points: [`app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt`](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt) (Subtitle manager), [`domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt`](https://github.com/zt-fang/eyeopener-translator/blob/main/domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt) (Translation choices), [`app/src/main/java/io/github/ztfang/eye/MainActivity.kt`](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/java/io/github/ztfang/eye/MainActivity.kt) (Main activity), [`engine/src/main/kotlin/io/github/ztfang/eye/engine/ModelPreparer.kt`](https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/ModelPreparer.kt) (Model preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_activity["Main activity<br/>[MainActivity.kt]"]
  node_floating["Floating subtitles"]
  node_assistant["Assistant chat<br/>[MainActivity.kt]"]
  node_settings["Settings"]
  node_history["History screen<br/>[HistoryScreen.kt]"]
end

subgraph group_speech["Speech processing"]
  node_manager["Subtitle manager<br/>[SubtitleManager.kt]"]
  node_vad["Speech detection<br/>[SileroVadEngine.kt]"]
  node_sherpa["Sherpa ASR"]
  node_vosk["Vosk ASR<br/>[VoskAsrEngine.kt]"]
end

subgraph group_models["Models and translation"]
  node_modelprep["Model preparation<br/>[ModelPreparer.kt]"]
  node_modelscreen["Model management UI"]
  node_translation["Translation choices"]
  node_localtranslate["Local translation"]
  node_cloudtranslate["Cloud translation"]
  node_aitranslate["AI translation"]
end

subgraph group_persistence["Local persistence"]
  node_historyrepo["History repository"]
  node_database[("History database<br/>[AppDatabase.kt]")]
  node_dao["History DAO<br/>[HistoryDao.kt]"]
  node_settingsrepo["Settings repository"]
  node_datastore[("Settings store")]
end

node_user(("User"))
node_cloudservices{{"Cloud providers"}}
node_llm{{"LLM service"}}
node_deviceaudio(("Device audio"))

node_user -->|"opens and configures"| node_activity
node_activity -->|"starts overlay"| node_floating
node_floating -->|"starts processing"| node_manager
node_deviceaudio -->|"provides audio"| node_manager
node_manager -->|"checks speech"| node_vad
node_manager -->|"selects engine"| node_sherpa
node_manager -->|"selects engine"| node_vosk
node_manager -->|"updates subtitle state"| node_floating
node_manager -->|"uses selected mode"| node_translation
node_translation -->|"selects local"| node_localtranslate
node_translation -->|"selects cloud"| node_cloudtranslate
node_translation -->|"selects AI"| node_aitranslate
node_cloudtranslate -->|"uses provider"| node_cloudservices
node_aitranslate -->|"calls configured API"| node_llm
node_modelprep -->|"prepares engine"| node_sherpa
node_modelprep -->|"prepares engine"| node_vosk
node_modelscreen -.->|"requests models"| node_modelprep
node_manager -.->|"records history"| node_historyrepo
node_history -->|"browses records"| node_historyrepo
node_historyrepo -->|"reads and writes"| node_dao
node_database -->|"provides"| node_dao
node_settings -.->|"reads and updates"| node_settingsrepo
node_settingsrepo -->|"persists preferences"| node_datastore
node_activity -->|"hosts chat"| node_assistant

click node_activity "https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/java/io/github/ztfang/eye/MainActivity.kt"
click node_floating "https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/java/io/github/ztfang/eye/FloatingSubtitleService.kt"
click node_assistant "https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/java/io/github/ztfang/eye/MainActivity.kt"
click node_settings "https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SettingsViewModel.kt"
click node_history "https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/ui/screen/HistoryScreen.kt"
click node_manager "https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt"
click node_vad "https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/vad/SileroVadEngine.kt"
click node_sherpa "https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/asr/SherpaOnnxAsrEngine.kt"
click node_vosk "https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/asr/VoskAsrEngine.kt"
click node_modelprep "https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/ModelPreparer.kt"
click node_modelscreen "https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/ui/screens/LocalModelsScreen.kt"
click node_translation "https://github.com/zt-fang/eyeopener-translator/blob/main/domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt"
click node_historyrepo "https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/repository/HistoryRepositoryImpl.kt"
click node_database "https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/local/database/AppDatabase.kt"
click node_dao "https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/local/dao/HistoryDao.kt"
click node_settingsrepo "https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/repository/SettingsRepositoryImpl.kt"
click node_datastore "https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/local/datastore/SettingsDataStore.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_activity,node_floating,node_assistant,node_settings,node_history,node_user toneBlue
class node_manager,node_vad,node_sherpa,node_vosk toneAmber
class node_modelprep,node_modelscreen,node_translation,node_localtranslate,node_cloudtranslate,node_aitranslate toneMint
class node_historyrepo,node_database,node_dao,node_settingsrepo,node_datastore toneRose
class node_cloudservices,node_llm,node_deviceaudio toneIndigo
```

## Components

### App experience

- [Main activity](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/java/io/github/ztfang/eye/MainActivity.kt): `app/src/main/java/io/github/ztfang/eye/MainActivity.kt`
- [Floating subtitles](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/java/io/github/ztfang/eye/FloatingSubtitleService.kt): `app/src/main/java/io/github/ztfang/eye/FloatingSubtitleService.kt`
- [Assistant chat](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/java/io/github/ztfang/eye/MainActivity.kt): `app/src/main/java/io/github/ztfang/eye/MainActivity.kt`
- [Settings](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SettingsViewModel.kt): `app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SettingsViewModel.kt`
- [History screen](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/ui/screen/HistoryScreen.kt): `app/src/main/kotlin/io/github/ztfang/eye/ui/screen/HistoryScreen.kt`

### Speech processing

- [Subtitle manager](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt): `app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt`
- [Speech detection](https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/vad/SileroVadEngine.kt): `engine/src/main/kotlin/io/github/ztfang/eye/engine/vad/SileroVadEngine.kt`
- [Sherpa ASR](https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/asr/SherpaOnnxAsrEngine.kt): `engine/src/main/kotlin/io/github/ztfang/eye/engine/asr/SherpaOnnxAsrEngine.kt`
- [Vosk ASR](https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/asr/VoskAsrEngine.kt): `engine/src/main/kotlin/io/github/ztfang/eye/engine/asr/VoskAsrEngine.kt`

### Models and translation

- [Model preparation](https://github.com/zt-fang/eyeopener-translator/blob/main/engine/src/main/kotlin/io/github/ztfang/eye/engine/ModelPreparer.kt): `engine/src/main/kotlin/io/github/ztfang/eye/engine/ModelPreparer.kt`
- [Model management UI](https://github.com/zt-fang/eyeopener-translator/blob/main/app/src/main/kotlin/io/github/ztfang/eye/ui/screens/LocalModelsScreen.kt): `app/src/main/kotlin/io/github/ztfang/eye/ui/screens/LocalModelsScreen.kt`
- [Translation choices](https://github.com/zt-fang/eyeopener-translator/blob/main/domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt): `domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt`
- **Local translation**
- **Cloud translation**
- **AI translation**

### Local persistence

- [History repository](https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/repository/HistoryRepositoryImpl.kt): `data/src/main/kotlin/io/github/ztfang/eye/data/repository/HistoryRepositoryImpl.kt`
- [History database](https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/local/database/AppDatabase.kt): `data/src/main/kotlin/io/github/ztfang/eye/data/local/database/AppDatabase.kt`
- [History DAO](https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/local/dao/HistoryDao.kt): `data/src/main/kotlin/io/github/ztfang/eye/data/local/dao/HistoryDao.kt`
- [Settings repository](https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/repository/SettingsRepositoryImpl.kt): `data/src/main/kotlin/io/github/ztfang/eye/data/repository/SettingsRepositoryImpl.kt`
- [Settings store](https://github.com/zt-fang/eyeopener-translator/blob/main/data/src/main/kotlin/io/github/ztfang/eye/data/local/datastore/SettingsDataStore.kt): `data/src/main/kotlin/io/github/ztfang/eye/data/local/datastore/SettingsDataStore.kt`

### Other components

- **User**
- **Cloud providers**
- **LLM service**
- **Device audio**

## Connections

- User → Main activity: opens and configures (evidence: `README.md`)
- Main activity → Floating subtitles: starts overlay (evidence: `app/src/main/java/io/github/ztfang/eye/MainActivity.kt`)
- Floating subtitles → Subtitle manager: starts processing (evidence: `app/src/main/java/io/github/ztfang/eye/FloatingSubtitleService.kt`)
- Device audio → Subtitle manager: provides audio (evidence: `README.md`)
- Subtitle manager → Speech detection: checks speech (evidence: `app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt`)
- Subtitle manager → Sherpa ASR: selects engine (evidence: `app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt`)
- Subtitle manager → Vosk ASR: selects engine (evidence: `app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt`)
- Subtitle manager → Floating subtitles: updates subtitle state (evidence: `app/src/main/java/io/github/ztfang/eye/FloatingSubtitleService.kt`)
- Subtitle manager → Translation choices: uses selected mode (evidence: `app/src/main/kotlin/io/github/ztfang/eye/viewmodel/SubtitleManager.kt`)
- Translation choices → Local translation: selects local (evidence: `domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt`)
- Translation choices → Cloud translation: selects cloud (evidence: `domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt`)
- Translation choices → AI translation: selects AI (evidence: `domain/src/main/kotlin/io/github/ztfang/eye/domain/model/TranslationEngine.kt`)
- Cloud translation → Cloud providers: uses provider (evidence: `README.md`)
- AI translation → LLM service: calls configured API (evidence: `README.md`)
- Model preparation → Sherpa ASR: prepares engine (evidence: `engine/src/main/kotlin/io/github/ztfang/eye/engine/ModelPreparer.kt`)
- Model preparation → Vosk ASR: prepares engine (evidence: `engine/src/main/kotlin/io/github/ztfang/eye/engine/ModelPreparer.kt`)
- Model management UI → Model preparation: requests models
- Subtitle manager → History repository: records history
- History screen → History repository: browses records (evidence: `README.md`)
- History repository → History DAO: reads and writes (evidence: `data/src/main/kotlin/io/github/ztfang/eye/data/repository/HistoryRepositoryImpl.kt`)
- History database → History DAO: provides (evidence: `data/src/main/kotlin/io/github/ztfang/eye/data/local/database/AppDatabase.kt`)
- Settings → Settings repository: reads and updates
- Settings repository → Settings store: persists preferences (evidence: `data/src/main/kotlin/io/github/ztfang/eye/data/repository/SettingsRepositoryImpl.kt`)
- Main activity → Assistant chat: hosts chat (evidence: `README.md`)
