# ch6vip/fqapp architecture

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

- Interactive diagram: https://gitdiagram.com/ch6vip/fqapp
- Repository: https://github.com/ch6vip/fqapp

## Overview

fqapp is an Android-local client for discovering and consuming novels, short dramas, audio books, and manga from upstream services. The documented user flow is browse/search, open a work, then read or play it online or from cache; the app also supports listening, progress/history, downloads, and backup. The tree exposes the Android host and Rust core, but not the Flutter UI or its local persistence implementation, so those are not expanded into speculative components. Endpoint coverage is represented at the subsystem level where source was not sampled.

Main entry points: [`rust/src/upstream/client.rs`](https://github.com/ch6vip/fqapp/blob/master/rust/src/upstream/client.rs) (Upstream client), [`android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt) (Android host), [`rust/src/endpoints/mod.rs`](https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/mod.rs) (Endpoint registry), [`rust/src/dispatch.rs`](https://github.com/ch6vip/fqapp/blob/master/rust/src/dispatch.rs) (Request dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Android app"]
  node_android_host["Android host<br/>[MainActivity.kt]"]
  node_native_playback["Native playback"]
  node_background_audio["Background audio"]
  node_reader_device["Reader device controls"]
  node_system_tts["System TTS<br/>[SystemTtsPlugin.kt]"]
  node_local_books["Local book import"]
  node_backup["Library backup"]
  node_downloads["Book export<br/>[DownloadsPlugin.kt]"]
end

subgraph group_core["Rust core"]
  node_ffi_api["Flutter Rust API<br/>[mod.rs]"]
  node_loopback_server["Loopback server<br/>[server.rs]"]
  node_dispatcher["Request dispatcher<br/>[dispatch.rs]"]
  node_route_matcher["REST route matcher<br/>[router.rs]"]
end

subgraph group_content["Content services"]
  node_endpoint_registry["Endpoint registry<br/>[mod.rs]"]
  node_catalog["Discovery and catalog"]
  node_novel_reading["Novel reading"]
  node_drama_video["Drama video<br/>[video.rs]"]
  node_manga_reading["Manga reading<br/>[manga.rs]"]
  node_audio_books["Audio books"]
end

subgraph group_security["Device and signing"]
  node_upstream_client["Upstream client<br/>[client.rs]"]
  node_device_pool[("Device pool<br/>[mod.rs]")]
  node_device_registration["Device registration<br/>[register.rs]"]
  node_request_signing["Request signing<br/>[mod.rs]"]
  node_http_transport["HTTP transport<br/>[http.rs]"]
end

subgraph group_media["Media support"]
  node_native_crypto["Native CENC crypto<br/>[mp4_cenc.c]"]
  node_jni["JNI bridge<br/>[jni_bridge.c]"]
end

node_user(("Reader"))
node_upstream_service["Upstream content service"]

node_user -->|"uses"| node_android_host
node_android_host -->|"registers"| node_native_playback
node_android_host -->|"registers"| node_reader_device
node_android_host -->|"registers"| node_system_tts
node_android_host -->|"registers"| node_local_books
node_android_host -->|"registers"| node_backup
node_android_host -->|"registers"| node_downloads
node_native_playback -->|"dispatches controls"| node_background_audio
node_native_playback -.->|"decrypts media"| node_native_crypto
node_ffi_api -->|"dispatches requests"| node_dispatcher
node_loopback_server -->|"dispatches requests"| node_dispatcher
node_dispatcher -->|"matches paths"| node_route_matcher
node_dispatcher -->|"dispatches handlers"| node_endpoint_registry
node_dispatcher -->|"serves web UI"| node_loopback_server
node_endpoint_registry -->|"registers handlers"| node_catalog
node_endpoint_registry -->|"registers handlers"| node_novel_reading
node_endpoint_registry -->|"registers handlers"| node_drama_video
node_endpoint_registry -->|"registers handlers"| node_manga_reading
node_endpoint_registry -->|"registers handlers"| node_audio_books
node_catalog -.->|"requests content"| node_upstream_client
node_novel_reading -.->|"requests chapters"| node_upstream_client
node_drama_video -.->|"requests media"| node_upstream_client
node_manga_reading -.->|"requests pages"| node_upstream_client
node_audio_books -.->|"requests audio"| node_upstream_client
node_upstream_client -->|"generates signatures"| node_request_signing
node_upstream_client -->|"selects device"| node_device_pool
node_upstream_client -.->|"sends requests"| node_http_transport
node_device_pool -->|"refills pool"| node_device_registration
node_http_transport -.->|"sends HTTP"| node_upstream_service
node_native_crypto -->|"exposes native crypto"| node_jni

click node_android_host "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt"
click node_native_playback "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/NativePlayerPlugin.kt"
click node_background_audio "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/ListenKeepAliveService.kt"
click node_reader_device "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/ReaderDevicePlugin.kt"
click node_system_tts "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/SystemTtsPlugin.kt"
click node_local_books "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/LocalBookPickerPlugin.kt"
click node_backup "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/LibraryBackupPlugin.kt"
click node_downloads "https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/DownloadsPlugin.kt"
click node_native_crypto "https://github.com/ch6vip/fqapp/blob/master/native/crypto_core/mp4_cenc.c"
click node_jni "https://github.com/ch6vip/fqapp/blob/master/native/android/jni_bridge.c"
click node_ffi_api "https://github.com/ch6vip/fqapp/blob/master/rust/src/api/mod.rs"
click node_loopback_server "https://github.com/ch6vip/fqapp/blob/master/rust/src/server.rs"
click node_dispatcher "https://github.com/ch6vip/fqapp/blob/master/rust/src/dispatch.rs"
click node_route_matcher "https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/router.rs"
click node_endpoint_registry "https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/mod.rs"
click node_catalog "https://github.com/ch6vip/fqapp/tree/master/rust/src/endpoints"
click node_novel_reading "https://github.com/ch6vip/fqapp/tree/master/rust/src/endpoints"
click node_drama_video "https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/video.rs"
click node_manga_reading "https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/manga.rs"
click node_audio_books "https://github.com/ch6vip/fqapp/tree/master/rust/src/endpoints"
click node_upstream_client "https://github.com/ch6vip/fqapp/blob/master/rust/src/upstream/client.rs"
click node_device_pool "https://github.com/ch6vip/fqapp/blob/master/rust/src/device/mod.rs"
click node_device_registration "https://github.com/ch6vip/fqapp/blob/master/rust/src/device/register.rs"
click node_request_signing "https://github.com/ch6vip/fqapp/blob/master/rust/src/sign/mod.rs"
click node_http_transport "https://github.com/ch6vip/fqapp/blob/master/rust/src/upstream/http.rs"

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_android_host,node_native_playback,node_background_audio,node_reader_device,node_system_tts,node_local_books,node_backup,node_downloads toneBlue
class node_ffi_api,node_loopback_server,node_dispatcher,node_route_matcher toneAmber
class node_endpoint_registry,node_catalog,node_novel_reading,node_drama_video,node_manga_reading,node_audio_books toneMint
class node_upstream_client,node_device_pool,node_device_registration,node_request_signing,node_http_transport toneRose
class node_native_crypto,node_jni,node_user,node_upstream_service toneIndigo
```

## Components

### Android app

- [Android host](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`
- [Native playback](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/NativePlayerPlugin.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/NativePlayerPlugin.kt`
- [Background audio](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/ListenKeepAliveService.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/ListenKeepAliveService.kt`
- [Reader device controls](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/ReaderDevicePlugin.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/ReaderDevicePlugin.kt`
- [System TTS](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/SystemTtsPlugin.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/SystemTtsPlugin.kt`
- [Local book import](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/LocalBookPickerPlugin.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/LocalBookPickerPlugin.kt`
- [Library backup](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/LibraryBackupPlugin.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/LibraryBackupPlugin.kt`
- [Book export](https://github.com/ch6vip/fqapp/blob/master/android/app/src/main/kotlin/com/fqapp/fqapp/DownloadsPlugin.kt): `android/app/src/main/kotlin/com/fqapp/fqapp/DownloadsPlugin.kt`

### Rust core

- [Flutter Rust API](https://github.com/ch6vip/fqapp/blob/master/rust/src/api/mod.rs): `rust/src/api/mod.rs`
- [Loopback server](https://github.com/ch6vip/fqapp/blob/master/rust/src/server.rs): `rust/src/server.rs`
- [Request dispatcher](https://github.com/ch6vip/fqapp/blob/master/rust/src/dispatch.rs): `rust/src/dispatch.rs`
- [REST route matcher](https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/router.rs): `rust/src/endpoints/router.rs`

### Content services

- [Endpoint registry](https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/mod.rs): `rust/src/endpoints/mod.rs`
- [Discovery and catalog](https://github.com/ch6vip/fqapp/tree/master/rust/src/endpoints): `rust/src/endpoints`
- [Novel reading](https://github.com/ch6vip/fqapp/tree/master/rust/src/endpoints): `rust/src/endpoints`
- [Drama video](https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/video.rs): `rust/src/endpoints/video.rs`
- [Manga reading](https://github.com/ch6vip/fqapp/blob/master/rust/src/endpoints/manga.rs): `rust/src/endpoints/manga.rs`
- [Audio books](https://github.com/ch6vip/fqapp/tree/master/rust/src/endpoints): `rust/src/endpoints`

### Device and signing

- [Upstream client](https://github.com/ch6vip/fqapp/blob/master/rust/src/upstream/client.rs): `rust/src/upstream/client.rs`
- [Device pool](https://github.com/ch6vip/fqapp/blob/master/rust/src/device/mod.rs): `rust/src/device/mod.rs`
- [Device registration](https://github.com/ch6vip/fqapp/blob/master/rust/src/device/register.rs): `rust/src/device/register.rs`
- [Request signing](https://github.com/ch6vip/fqapp/blob/master/rust/src/sign/mod.rs): `rust/src/sign/mod.rs`
- [HTTP transport](https://github.com/ch6vip/fqapp/blob/master/rust/src/upstream/http.rs): `rust/src/upstream/http.rs`

### Media support

- [Native CENC crypto](https://github.com/ch6vip/fqapp/blob/master/native/crypto_core/mp4_cenc.c): `native/crypto_core/mp4_cenc.c`
- [JNI bridge](https://github.com/ch6vip/fqapp/blob/master/native/android/jni_bridge.c): `native/android/jni_bridge.c`

### Other components

- **Reader**
- **Upstream content service**

## Connections

- Reader → Android host: uses (evidence: `README.md`)
- Android host → Native playback: registers (evidence: `android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`)
- Android host → Reader device controls: registers (evidence: `android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`)
- Android host → System TTS: registers (evidence: `android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`)
- Android host → Local book import: registers (evidence: `android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`)
- Android host → Library backup: registers (evidence: `android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`)
- Android host → Book export: registers (evidence: `android/app/src/main/kotlin/com/fqapp/fqapp/MainActivity.kt`)
- Native playback → Background audio: dispatches controls (evidence: `android/app/src/main/kotlin/com/fqapp/fqapp/ListenKeepAliveService.kt`)
- Native playback → Native CENC crypto: decrypts media
- Flutter Rust API → Request dispatcher: dispatches requests (evidence: `rust/src/api/mod.rs`)
- Loopback server → Request dispatcher: dispatches requests (evidence: `rust/src/server.rs`)
- Request dispatcher → REST route matcher: matches paths (evidence: `rust/src/dispatch.rs`)
- Request dispatcher → Endpoint registry: dispatches handlers (evidence: `rust/src/dispatch.rs`)
- Request dispatcher → Loopback server: serves web UI (evidence: `rust/src/dispatch.rs`)
- Endpoint registry → Discovery and catalog: registers handlers (evidence: `rust/src/endpoints/mod.rs`)
- Endpoint registry → Novel reading: registers handlers (evidence: `rust/src/endpoints/mod.rs`)
- Endpoint registry → Drama video: registers handlers (evidence: `rust/src/endpoints/mod.rs`)
- Endpoint registry → Manga reading: registers handlers (evidence: `rust/src/endpoints/mod.rs`)
- Endpoint registry → Audio books: registers handlers (evidence: `rust/src/endpoints/mod.rs`)
- Discovery and catalog → Upstream client: requests content
- Novel reading → Upstream client: requests chapters
- Drama video → Upstream client: requests media
- Manga reading → Upstream client: requests pages
- Audio books → Upstream client: requests audio
- Upstream client → Request signing: generates signatures (evidence: `rust/src/upstream/client.rs`)
- Upstream client → Device pool: selects device (evidence: `rust/src/upstream/client.rs`)
- Upstream client → HTTP transport: sends requests (evidence: `rust/src/upstream/client.rs`)
- Device pool → Device registration: refills pool (evidence: `rust/src/device/mod.rs`)
- HTTP transport → Upstream content service: sends HTTP
- Native CENC crypto → JNI bridge: exposes native crypto (evidence: `native/android/jni_bridge.c`)
