# hao-yicheng/lang-reader architecture

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

- Interactive diagram: https://gitdiagram.com/hao-yicheng/lang-reader
- Repository: https://github.com/hao-yicheng/lang-reader

## Overview

Lang Reader is a browser-based language-learning app for reading personal Markdown/text notes, practicing vocabulary, and studying generated cards. The main workflow loads a document from configured, sample, draft, or uploaded sources; parses it into reading or vocabulary units; then presents interactive views with playback, translation, and study options. Study sessions track progress and support JSON import/export. Edges reflect visible imports/calls or README capabilities; several UI and document subsystems were not sampled, so their connections are omitted where evidence is unavailable.

Main entry points: [`src/app.js`](https://github.com/hao-yicheng/lang-reader/blob/main/src/app.js) (App orchestrator), [`src/study/controller.js`](https://github.com/hao-yicheng/lang-reader/blob/main/src/study/controller.js) (Study controller), [`src/app/documentController.js`](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/documentController.js) (Document workflow), [`src/app/settingsController.js`](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/settingsController.js) (Settings controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace and files"]
  node_app["App orchestrator<br/>[app.js]"]
  node_documents["Document workflow"]
  node_sources["Source catalog<br/>[sourceCatalog.js]"]
  node_filetree["File tree<br/>[filesTree.js]"]
  node_imports["File imports<br/>[fileImports.js]"]
end

subgraph group_reading["Reading and parsing"]
  node_parser["Document parser<br/>[parser.js]"]
  node_segmentation["Text segmentation"]
  node_reader["Reader view<br/>[readerView.js]"]
  node_vocabulary["Vocabulary view<br/>[vocabularyView.js]"]
end

subgraph group_practice["Playback and translation"]
  node_playback["Playback controller"]
  node_playlist["Playback playlist<br/>[playlist.js]"]
  node_speech["Speech synthesis<br/>[speech.js]"]
  node_translation["Translation UI<br/>[translationUi.js]"]
end

subgraph group_study["Study practice"]
  node_studycontroller["Study controller<br/>[controller.js]"]
  node_studymodel["Study model<br/>[model.js]"]
  node_studysession["Study session<br/>[session.js]"]
  node_studyview["Study view<br/>[view.js]"]
  node_studystorage[("Study progress storage<br/>[storage.js]")]
end

subgraph group_shared["Settings and persistence"]
  node_settings["Settings controller"]
  node_runtimeconfig["Runtime configuration<br/>[runtimeConfig.js]"]
  node_storage[("Browser state storage<br/>[storage.js]")]
  node_languages["Language utilities<br/>[languages.js]"]
end

node_learner(("Learner"))
node_translator["External translators"]
node_browservoices["Browser voices"]

node_learner -->|"uses"| node_app
node_app -->|"loads config"| node_runtimeconfig
node_app -->|"loads state"| node_storage
node_app -->|"loads sources"| node_sources
node_app -->|"parses documents"| node_parser
node_app -->|"creates view"| node_reader
node_app -->|"creates view"| node_vocabulary
node_app -->|"creates playlist"| node_playlist
node_app -->|"creates speech"| node_speech
node_app -->|"creates UI"| node_translation
node_app -->|"creates controller"| node_documents
node_documents -->|"labels sources"| node_sources
node_documents -->|"imports files"| node_imports
node_documents -.->|"renders files"| node_filetree
node_parser -->|"splits sentences"| node_segmentation
node_app -.->|"initializes study"| node_studycontroller
node_studycontroller -->|"builds documents"| node_studymodel
node_studycontroller -->|"advances sessions"| node_studysession
node_studycontroller -->|"renders workspace"| node_studyview
node_studycontroller -->|"stores progress"| node_studystorage
node_studysession -->|"updates progress"| node_studymodel
node_settings -->|"saves preferences"| node_storage
node_settings -->|"normalizes config"| node_runtimeconfig
node_playback -->|"controls playback"| node_playlist
node_playlist -->|"creates units"| node_segmentation
node_speech -->|"matches voices"| node_languages
node_speech -.->|"uses available voices"| node_browservoices
node_translation -.->|"opens translation tools"| node_translator
node_settings -->|"configures languages"| node_languages

click node_app "https://github.com/hao-yicheng/lang-reader/blob/main/src/app.js"
click node_documents "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/documentController.js"
click node_sources "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/sourceCatalog.js"
click node_filetree "https://github.com/hao-yicheng/lang-reader/blob/main/src/files/filesTree.js"
click node_imports "https://github.com/hao-yicheng/lang-reader/blob/main/src/files/fileImports.js"
click node_parser "https://github.com/hao-yicheng/lang-reader/blob/main/src/parsing/parser.js"
click node_segmentation "https://github.com/hao-yicheng/lang-reader/blob/main/src/parsing/textSegmentation.js"
click node_reader "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/readerView.js"
click node_vocabulary "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/vocabularyView.js"
click node_playback "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/playbackController.js"
click node_playlist "https://github.com/hao-yicheng/lang-reader/blob/main/src/playback/playlist.js"
click node_speech "https://github.com/hao-yicheng/lang-reader/blob/main/src/playback/speech.js"
click node_translation "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/translationUi.js"
click node_studycontroller "https://github.com/hao-yicheng/lang-reader/blob/main/src/study/controller.js"
click node_studymodel "https://github.com/hao-yicheng/lang-reader/blob/main/src/study/model.js"
click node_studysession "https://github.com/hao-yicheng/lang-reader/blob/main/src/study/session.js"
click node_studyview "https://github.com/hao-yicheng/lang-reader/blob/main/src/study/view.js"
click node_studystorage "https://github.com/hao-yicheng/lang-reader/blob/main/src/study/storage.js"
click node_settings "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/settingsController.js"
click node_runtimeconfig "https://github.com/hao-yicheng/lang-reader/blob/main/src/app/runtimeConfig.js"
click node_storage "https://github.com/hao-yicheng/lang-reader/blob/main/src/core/storage.js"
click node_languages "https://github.com/hao-yicheng/lang-reader/blob/main/src/i18n/languages.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_app,node_documents,node_sources,node_filetree,node_imports,node_browservoices toneBlue
class node_parser,node_segmentation,node_reader,node_vocabulary toneAmber
class node_playback,node_playlist,node_speech,node_translation toneMint
class node_studycontroller,node_studymodel,node_studysession,node_studyview,node_studystorage toneRose
class node_settings,node_runtimeconfig,node_storage,node_languages,node_learner,node_translator toneIndigo
```

## Components

### Workspace and files

- [App orchestrator](https://github.com/hao-yicheng/lang-reader/blob/main/src/app.js): `src/app.js`
- [Document workflow](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/documentController.js): `src/app/documentController.js`
- [Source catalog](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/sourceCatalog.js): `src/app/sourceCatalog.js`
- [File tree](https://github.com/hao-yicheng/lang-reader/blob/main/src/files/filesTree.js): `src/files/filesTree.js`
- [File imports](https://github.com/hao-yicheng/lang-reader/blob/main/src/files/fileImports.js): `src/files/fileImports.js`

### Reading and parsing

- [Document parser](https://github.com/hao-yicheng/lang-reader/blob/main/src/parsing/parser.js): `src/parsing/parser.js`
- [Text segmentation](https://github.com/hao-yicheng/lang-reader/blob/main/src/parsing/textSegmentation.js): `src/parsing/textSegmentation.js`
- [Reader view](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/readerView.js): `src/app/readerView.js`
- [Vocabulary view](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/vocabularyView.js): `src/app/vocabularyView.js`

### Playback and translation

- [Playback controller](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/playbackController.js): `src/app/playbackController.js`
- [Playback playlist](https://github.com/hao-yicheng/lang-reader/blob/main/src/playback/playlist.js): `src/playback/playlist.js`
- [Speech synthesis](https://github.com/hao-yicheng/lang-reader/blob/main/src/playback/speech.js): `src/playback/speech.js`
- [Translation UI](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/translationUi.js): `src/app/translationUi.js`

### Study practice

- [Study controller](https://github.com/hao-yicheng/lang-reader/blob/main/src/study/controller.js): `src/study/controller.js`
- [Study model](https://github.com/hao-yicheng/lang-reader/blob/main/src/study/model.js): `src/study/model.js`
- [Study session](https://github.com/hao-yicheng/lang-reader/blob/main/src/study/session.js): `src/study/session.js`
- [Study view](https://github.com/hao-yicheng/lang-reader/blob/main/src/study/view.js): `src/study/view.js`
- [Study progress storage](https://github.com/hao-yicheng/lang-reader/blob/main/src/study/storage.js): `src/study/storage.js`

### Settings and persistence

- [Settings controller](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/settingsController.js): `src/app/settingsController.js`
- [Runtime configuration](https://github.com/hao-yicheng/lang-reader/blob/main/src/app/runtimeConfig.js): `src/app/runtimeConfig.js`
- [Browser state storage](https://github.com/hao-yicheng/lang-reader/blob/main/src/core/storage.js): `src/core/storage.js`
- [Language utilities](https://github.com/hao-yicheng/lang-reader/blob/main/src/i18n/languages.js): `src/i18n/languages.js`

### Other components

- **Learner**
- **External translators**
- **Browser voices**

## Connections

- Learner → App orchestrator: uses (evidence: `README.md`)
- App orchestrator → Runtime configuration: loads config (evidence: `src/app.js`)
- App orchestrator → Browser state storage: loads state (evidence: `src/app.js`)
- App orchestrator → Source catalog: loads sources (evidence: `src/app.js`)
- App orchestrator → Document parser: parses documents (evidence: `src/app.js`)
- App orchestrator → Reader view: creates view (evidence: `src/app.js`)
- App orchestrator → Vocabulary view: creates view (evidence: `src/app.js`)
- App orchestrator → Playback playlist: creates playlist (evidence: `src/app.js`)
- App orchestrator → Speech synthesis: creates speech (evidence: `src/app.js`)
- App orchestrator → Translation UI: creates UI (evidence: `src/app.js`)
- App orchestrator → Document workflow: creates controller (evidence: `src/app.js`)
- Document workflow → Source catalog: labels sources (evidence: `src/app/documentController.js`)
- Document workflow → File imports: imports files (evidence: `src/app/documentController.js`)
- Document workflow → File tree: renders files
- Document parser → Text segmentation: splits sentences (evidence: `src/parsing/parser.js`)
- App orchestrator → Study controller: initializes study (evidence: `src/app.js`)
- Study controller → Study model: builds documents (evidence: `src/study/controller.js`)
- Study controller → Study session: advances sessions (evidence: `src/study/controller.js`)
- Study controller → Study view: renders workspace (evidence: `src/study/controller.js`)
- Study controller → Study progress storage: stores progress (evidence: `src/study/controller.js`)
- Study session → Study model: updates progress (evidence: `src/study/session.js`)
- Settings controller → Browser state storage: saves preferences (evidence: `src/app/settingsController.js`)
- Settings controller → Runtime configuration: normalizes config (evidence: `src/app/settingsController.js`)
- Playback controller → Playback playlist: controls playback (evidence: `src/app/playbackController.js`)
- Playback playlist → Text segmentation: creates units (evidence: `src/playback/playlist.js`)
- Speech synthesis → Language utilities: matches voices (evidence: `src/playback/speech.js`)
- Speech synthesis → Browser voices: uses available voices (evidence: `README.md`)
- Translation UI → External translators: opens translation tools (evidence: `README.md`)
- Settings controller → Language utilities: configures languages (evidence: `src/app/settingsController.js`)
