# manhhao/hoshi-reader architecture

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

- Interactive diagram: https://gitdiagram.com/manhhao/hoshi-reader
- Repository: https://github.com/manhhao/hoshi-reader

## Overview

Hoshi Reader is an iOS Japanese EPUB reader for immersion learning. The principal workflow is importing and organizing EPUBs, reading and navigating their contents, then looking up selected text in Yomitan-style dictionaries and optionally mining it to Anki. Separate capabilities include audio-assisted reading, statistics, and ッツ Reader sync. The graph combines documented product features with relationships visible in the supplied source index; reader internals were not sampled, so uncertain connections are omitted or marked unverified.

Main entry points: [`Features/Bookshelf/BookshelfViewModel.swift`](https://github.com/manhhao/hoshi-reader/blob/main/Features/Bookshelf/BookshelfViewModel.swift) (Shelf management), [`Features/Sync/SyncManager.swift`](https://github.com/manhhao/hoshi-reader/blob/main/Features/Sync/SyncManager.swift) (Sync orchestration), [`Features/Popup/PopupWebView.swift`](https://github.com/manhhao/hoshi-reader/blob/main/Features/Popup/PopupWebView.swift) (Lookup popup), [`App/HoshiReader.swift`](https://github.com/manhhao/hoshi-reader/blob/main/App/HoshiReader.swift) (App entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_library["EPUB processing"]
  node_epubimport["EPUB import<br/>[EPUBParser.swift]"]
  node_epubdoc["EPUB document model<br/>[EPUBDocument.swift]"]
end

subgraph group_reading["Bookshelf and reading"]
  node_app["App entry<br/>[HoshiReader.swift]"]
  node_shelf["Bookshelf"]
  node_shelfvm["Shelf management"]
  node_reader["EPUB reader<br/>[ReaderView.swift]"]
  node_readerweb["Reader web view"]
  node_contents["Contents and search<br/>[BookSearch.swift]"]
end

subgraph group_lookup["Lookup and mining"]
  node_dictui["Dictionary search"]
  node_popup["Lookup popup<br/>[PopupWebView.swift]"]
  node_lookupengine["Dictionary lookup engine<br/>[LookupEngine.swift]"]
  node_dictmanager["Dictionary management"]
end

subgraph group_state["Local data and settings"]
  node_bookstore[("Book storage<br/>[BookStorage.swift]")]
  node_config[("User preferences<br/>[UserConfig.swift]")]
end

subgraph group_services["Integrations and insights"]
  node_anki["Anki mining<br/>[AnkiManager.swift]"]
  node_audio["Sasayaki audio"]
  node_stats[("Reading statistics")]
  node_sync["Sync orchestration<br/>[SyncManager.swift]"]
  node_drive["Google Drive"]
  node_tokens[("Credential storage<br/>[TokenStorage.swift]")]
end

node_user(("Reader"))

node_user -->|"opens"| node_app
node_app -->|"shows"| node_shelf
node_shelf -->|"uses"| node_shelfvm
node_shelfvm -->|"manages books"| node_bookstore
node_shelfvm -->|"updates stats"| node_stats
node_shelfvm -->|"requests sync"| node_sync
node_shelfvm -->|"uses document"| node_epubdoc
node_epubimport -->|"builds document"| node_epubdoc
node_bookstore -->|"parses EPUB"| node_epubimport
node_reader -.->|"renders through"| node_readerweb
node_reader -.->|"offers navigation"| node_contents
node_dictui -->|"shows lookup"| node_popup
node_popup -->|"queries"| node_lookupengine
node_dictmanager -->|"provides dictionaries"| node_lookupengine
node_dictui -->|"mines entries"| node_anki
node_popup -->|"supports mining"| node_anki
node_popup -->|"plays word audio"| node_audio
node_sync -->|"transfers data"| node_drive
node_sync -->|"reads book data"| node_bookstore
node_sync -->|"syncs statistics"| node_stats
node_drive -->|"uses credentials"| node_tokens
node_app -->|"loads preferences"| node_config
node_user -.->|"enables sync"| node_sync

click node_app "https://github.com/manhhao/hoshi-reader/blob/main/App/HoshiReader.swift"
click node_shelf "https://github.com/manhhao/hoshi-reader/blob/main/Features/Bookshelf/BookshelfView.swift"
click node_shelfvm "https://github.com/manhhao/hoshi-reader/blob/main/Features/Bookshelf/BookshelfViewModel.swift"
click node_reader "https://github.com/manhhao/hoshi-reader/blob/main/Features/Reader/ReaderView/ReaderView.swift"
click node_readerweb "https://github.com/manhhao/hoshi-reader/blob/main/Features/Reader/ReaderWebView/ReaderWebView.swift"
click node_contents "https://github.com/manhhao/hoshi-reader/blob/main/Features/Reader/Contents/BookSearch.swift"
click node_epubimport "https://github.com/manhhao/hoshi-reader/blob/main/Libraries/EPUBKit/Sources/EPUBKit/Parser/EPUBParser.swift"
click node_epubdoc "https://github.com/manhhao/hoshi-reader/blob/main/Libraries/EPUBKit/Sources/EPUBKit/Model/EPUBDocument.swift"
click node_bookstore "https://github.com/manhhao/hoshi-reader/blob/main/Core/BookStorage.swift"
click node_config "https://github.com/manhhao/hoshi-reader/blob/main/Core/UserConfig.swift"
click node_dictui "https://github.com/manhhao/hoshi-reader/blob/main/Features/Dictionary/DictionarySearchView.swift"
click node_popup "https://github.com/manhhao/hoshi-reader/blob/main/Features/Popup/PopupWebView.swift"
click node_lookupengine "https://github.com/manhhao/hoshi-reader/blob/main/Core/LookupEngine.swift"
click node_dictmanager "https://github.com/manhhao/hoshi-reader/blob/main/Core/DictionaryManager.swift"
click node_anki "https://github.com/manhhao/hoshi-reader/blob/main/Core/AnkiManager.swift"
click node_audio "https://github.com/manhhao/hoshi-reader/blob/main/Features/Sasayaki/SasayakiPlayer.swift"
click node_stats "https://github.com/manhhao/hoshi-reader/blob/main/Core/StatisticsStorage.swift"
click node_sync "https://github.com/manhhao/hoshi-reader/blob/main/Features/Sync/SyncManager.swift"
click node_drive "https://github.com/manhhao/hoshi-reader/blob/main/Features/Sync/GoogleDriveHandler.swift"
click node_tokens "https://github.com/manhhao/hoshi-reader/blob/main/Features/Sync/TokenStorage.swift"

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_epubimport,node_epubdoc toneBlue
class node_app,node_shelf,node_shelfvm,node_reader,node_readerweb,node_contents toneAmber
class node_dictui,node_popup,node_lookupengine,node_dictmanager toneMint
class node_bookstore,node_config toneRose
class node_anki,node_audio,node_stats,node_sync,node_drive,node_tokens,node_user toneIndigo
```

## Components

### EPUB processing

- [EPUB import](https://github.com/manhhao/hoshi-reader/blob/main/Libraries/EPUBKit/Sources/EPUBKit/Parser/EPUBParser.swift): `Libraries/EPUBKit/Sources/EPUBKit/Parser/EPUBParser.swift`
- [EPUB document model](https://github.com/manhhao/hoshi-reader/blob/main/Libraries/EPUBKit/Sources/EPUBKit/Model/EPUBDocument.swift): `Libraries/EPUBKit/Sources/EPUBKit/Model/EPUBDocument.swift`

### Bookshelf and reading

- [App entry](https://github.com/manhhao/hoshi-reader/blob/main/App/HoshiReader.swift): `App/HoshiReader.swift`
- [Bookshelf](https://github.com/manhhao/hoshi-reader/blob/main/Features/Bookshelf/BookshelfView.swift): `Features/Bookshelf/BookshelfView.swift`
- [Shelf management](https://github.com/manhhao/hoshi-reader/blob/main/Features/Bookshelf/BookshelfViewModel.swift): `Features/Bookshelf/BookshelfViewModel.swift`
- [EPUB reader](https://github.com/manhhao/hoshi-reader/blob/main/Features/Reader/ReaderView/ReaderView.swift): `Features/Reader/ReaderView/ReaderView.swift`
- [Reader web view](https://github.com/manhhao/hoshi-reader/blob/main/Features/Reader/ReaderWebView/ReaderWebView.swift): `Features/Reader/ReaderWebView/ReaderWebView.swift`
- [Contents and search](https://github.com/manhhao/hoshi-reader/blob/main/Features/Reader/Contents/BookSearch.swift): `Features/Reader/Contents/BookSearch.swift`

### Lookup and mining

- [Dictionary search](https://github.com/manhhao/hoshi-reader/blob/main/Features/Dictionary/DictionarySearchView.swift): `Features/Dictionary/DictionarySearchView.swift`
- [Lookup popup](https://github.com/manhhao/hoshi-reader/blob/main/Features/Popup/PopupWebView.swift): `Features/Popup/PopupWebView.swift`
- [Dictionary lookup engine](https://github.com/manhhao/hoshi-reader/blob/main/Core/LookupEngine.swift): `Core/LookupEngine.swift`
- [Dictionary management](https://github.com/manhhao/hoshi-reader/blob/main/Core/DictionaryManager.swift): `Core/DictionaryManager.swift`

### Local data and settings

- [Book storage](https://github.com/manhhao/hoshi-reader/blob/main/Core/BookStorage.swift): `Core/BookStorage.swift`
- [User preferences](https://github.com/manhhao/hoshi-reader/blob/main/Core/UserConfig.swift): `Core/UserConfig.swift`

### Integrations and insights

- [Anki mining](https://github.com/manhhao/hoshi-reader/blob/main/Core/AnkiManager.swift): `Core/AnkiManager.swift`
- [Sasayaki audio](https://github.com/manhhao/hoshi-reader/blob/main/Features/Sasayaki/SasayakiPlayer.swift): `Features/Sasayaki/SasayakiPlayer.swift`
- [Reading statistics](https://github.com/manhhao/hoshi-reader/blob/main/Core/StatisticsStorage.swift): `Core/StatisticsStorage.swift`
- [Sync orchestration](https://github.com/manhhao/hoshi-reader/blob/main/Features/Sync/SyncManager.swift): `Features/Sync/SyncManager.swift`
- [Google Drive](https://github.com/manhhao/hoshi-reader/blob/main/Features/Sync/GoogleDriveHandler.swift): `Features/Sync/GoogleDriveHandler.swift`
- [Credential storage](https://github.com/manhhao/hoshi-reader/blob/main/Features/Sync/TokenStorage.swift): `Features/Sync/TokenStorage.swift`

### Other components

- **Reader**

## Connections

- Reader → App entry: opens
- App entry → Bookshelf: shows (evidence: `App/HoshiReader.swift`)
- Bookshelf → Shelf management: uses (evidence: `Features/Bookshelf/BookshelfView.swift`)
- Shelf management → Book storage: manages books (evidence: `Features/Bookshelf/BookshelfViewModel.swift`)
- Shelf management → Reading statistics: updates stats (evidence: `Features/Bookshelf/BookshelfViewModel.swift`)
- Shelf management → Sync orchestration: requests sync (evidence: `Features/Bookshelf/BookshelfViewModel.swift`)
- Shelf management → EPUB document model: uses document (evidence: `Features/Bookshelf/BookshelfViewModel.swift`)
- EPUB import → EPUB document model: builds document (evidence: `Libraries/EPUBKit/Sources/EPUBKit/Parser/EPUBParser.swift`)
- Book storage → EPUB import: parses EPUB (evidence: `Core/BookStorage.swift`)
- EPUB reader → Reader web view: renders through
- EPUB reader → Contents and search: offers navigation
- Dictionary search → Lookup popup: shows lookup (evidence: `Features/Dictionary/DictionarySearchView.swift`)
- Lookup popup → Dictionary lookup engine: queries (evidence: `Features/Popup/PopupWebView.swift`)
- Dictionary management → Dictionary lookup engine: provides dictionaries (evidence: `Core/DictionaryManager.swift`)
- Dictionary search → Anki mining: mines entries (evidence: `Features/Dictionary/DictionarySearchView.swift`)
- Lookup popup → Anki mining: supports mining (evidence: `Features/Popup/PopupWebView.swift`)
- Lookup popup → Sasayaki audio: plays word audio (evidence: `Features/Popup/PopupWebView.swift`)
- Sync orchestration → Google Drive: transfers data (evidence: `Features/Sync/SyncManager.swift`)
- Sync orchestration → Book storage: reads book data (evidence: `Features/Sync/SyncManager.swift`)
- Sync orchestration → Reading statistics: syncs statistics (evidence: `Features/Sync/SyncManager.swift`)
- Google Drive → Credential storage: uses credentials (evidence: `Features/Sync/GoogleDriveHandler.swift`)
- App entry → User preferences: loads preferences (evidence: `App/HoshiReader.swift`)
- Reader → Sync orchestration: enables sync
