# twyora/douyinenhancer architecture

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

- Interactive diagram: https://gitdiagram.com/twyora/douyinenhancer
- Repository: https://github.com/twyora/douyinenhancer

## Overview

DouyinEnhancer is an Xposed module that hooks Douyin at runtime to add media-saving, feed, playback, and UI controls. Users enable it for Douyin in an Xposed manager; its hook entry installs behavior in the host app, with settings controlling optional features. The app also exposes settings dialogs and persists configuration. Feature coverage follows the README and tree; where hook registration or unsampled implementations are not shown, links are limited to documented runtime relationships.

Main entry points: [`app/src/main/java/io/github/twyora/douyinenhancer/hook/DouyinPackage.kt`](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/DouyinPackage.kt) (Host Signatures), [`app/src/main/java/io/github/twyora/douyinenhancer/config/ConfigManager.kt`](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/ConfigManager.kt) (Config Manager), [`app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentEmojiHooker.kt`](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentEmojiHooker.kt) (Comment Media), [`app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedMultiImageHooker.kt`](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedMultiImageHooker.kt) (Feed Downloads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Hook Runtime"]
  node_entry["Hook Entry<br/>[HookEntry.kt]"]
  node_package["Host Signatures<br/>[DouyinPackage.kt]"]
end

subgraph group_features["Douyin Features"]
  node_comment["Comment Media"]
  node_feed["Feed Features"]
  node_feedimage["Feed Downloads"]
  node_feedvideo["Feed Playback<br/>[FeedVideoHooker.kt]"]
  node_commentaudio["Audio Comments"]
  node_commentimage["Comment Images"]
  node_uihooks["Host UI Hooks"]
end

subgraph group_config["Configuration"]
  node_configmanager["Config Manager<br/>[ConfigManager.kt]"]
  node_providers["Config Providers"]
  node_gates["Rule Gates<br/>[RuleGate.kt]"]
  node_storage[("FastKV Storage<br/>[FastKVStorage.kt]")]
end

subgraph group_settings["Settings UI"]
  node_activity["Module Activity<br/>[MainActivity.kt]"]
  node_settingshook["Settings Entry Hook"]
  node_settingsdialog["Settings Dialogs<br/>[SettingsDialog.kt]"]
end

node_user(("User"))
node_xposed["Xposed Manager"]
node_douyin["Douyin App"]
node_album[("Device Album")]

node_user -->|"activates module"| node_xposed
node_xposed -->|"loads module"| node_entry
node_entry -->|"hooks process"| node_douyin
node_entry -->|"uses signatures"| node_package
node_comment -->|"resolves host APIs"| node_package
node_feed -->|"resolves host APIs"| node_package
node_feedimage -->|"resolves host APIs"| node_package
node_feedvideo -->|"resolves host APIs"| node_package
node_commentaudio -->|"resolves host APIs"| node_package
node_commentimage -->|"resolves host APIs"| node_package
node_uihooks -->|"resolves host APIs"| node_package
node_comment -->|"hooks comment saving"| node_douyin
node_commentimage -->|"hooks image saving"| node_douyin
node_commentaudio -->|"hooks audio saving"| node_douyin
node_feedimage -->|"hooks feed saving"| node_douyin
node_feedvideo -->|"hooks playback"| node_douyin
node_feed -->|"filters feed"| node_douyin
node_uihooks -->|"modifies host UI"| node_douyin
node_configmanager -->|"opens stores"| node_storage
node_configmanager -->|"creates providers"| node_providers
node_providers -->|"evaluates rules"| node_gates
node_comment -->|"reads options"| node_configmanager
node_feedimage -->|"reads options"| node_configmanager
node_user -->|"opens settings"| node_activity
node_activity -.->|"starts host settings"| node_settingshook
node_settingshook -->|"shows dialog"| node_settingsdialog
node_settingsdialog -->|"edits options"| node_configmanager
node_comment -->|"saves media"| node_album
node_feedimage -->|"saves media"| node_album

click node_entry "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/HookEntry.kt"
click node_package "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/DouyinPackage.kt"
click node_comment "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentEmojiHooker.kt"
click node_feed "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/RecommendedFeedHooker.kt"
click node_feedimage "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedMultiImageHooker.kt"
click node_feedvideo "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedVideoHooker.kt"
click node_commentaudio "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentAudioHooker.kt"
click node_commentimage "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentImageHooker.kt"
click node_uihooks "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/ui/FeedComponentHooker.kt"
click node_configmanager "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/ConfigManager.kt"
click node_providers "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/provider/FeedConfigProvider.kt"
click node_gates "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/gate/RuleGate.kt"
click node_storage "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/kvstorage/FastKVStorage.kt"
click node_activity "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/ui/MainActivity.kt"
click node_settingshook "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/ui/SettingsEntryHooker.kt"
click node_settingsdialog "https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/ui/SettingsDialog.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_entry,node_package,node_user toneBlue
class node_comment,node_feed,node_feedimage,node_feedvideo,node_commentaudio,node_commentimage,node_uihooks,node_album toneAmber
class node_configmanager,node_providers,node_gates,node_storage toneMint
class node_activity,node_settingshook,node_settingsdialog toneRose
class node_xposed,node_douyin toneIndigo
```

## Components

### Hook Runtime

- [Hook Entry](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/HookEntry.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/HookEntry.kt`
- [Host Signatures](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/DouyinPackage.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/DouyinPackage.kt`

### Douyin Features

- [Comment Media](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentEmojiHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentEmojiHooker.kt`
- [Feed Features](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/RecommendedFeedHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/RecommendedFeedHooker.kt`
- [Feed Downloads](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedMultiImageHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedMultiImageHooker.kt`
- [Feed Playback](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedVideoHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/feed/FeedVideoHooker.kt`
- [Audio Comments](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentAudioHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentAudioHooker.kt`
- [Comment Images](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentImageHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/comment/CommentImageHooker.kt`
- [Host UI Hooks](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/ui/FeedComponentHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/ui/FeedComponentHooker.kt`

### Configuration

- [Config Manager](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/ConfigManager.kt): `app/src/main/java/io/github/twyora/douyinenhancer/config/ConfigManager.kt`
- [Config Providers](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/provider/FeedConfigProvider.kt): `app/src/main/java/io/github/twyora/douyinenhancer/config/provider/FeedConfigProvider.kt`
- [Rule Gates](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/gate/RuleGate.kt): `app/src/main/java/io/github/twyora/douyinenhancer/config/gate/RuleGate.kt`
- [FastKV Storage](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/config/kvstorage/FastKVStorage.kt): `app/src/main/java/io/github/twyora/douyinenhancer/config/kvstorage/FastKVStorage.kt`

### Settings UI

- [Module Activity](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/ui/MainActivity.kt): `app/src/main/java/io/github/twyora/douyinenhancer/ui/MainActivity.kt`
- [Settings Entry Hook](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/hook/ui/SettingsEntryHooker.kt): `app/src/main/java/io/github/twyora/douyinenhancer/hook/ui/SettingsEntryHooker.kt`
- [Settings Dialogs](https://github.com/twyora/douyinenhancer/blob/main/app/src/main/java/io/github/twyora/douyinenhancer/ui/SettingsDialog.kt): `app/src/main/java/io/github/twyora/douyinenhancer/ui/SettingsDialog.kt`

### Other components

- **User**
- **Xposed Manager**
- **Douyin App**
- **Device Album**

## Connections

- User → Xposed Manager: activates module
- Xposed Manager → Hook Entry: loads module
- Hook Entry → Douyin App: hooks process
- Hook Entry → Host Signatures: uses signatures
- Comment Media → Host Signatures: resolves host APIs
- Feed Features → Host Signatures: resolves host APIs
- Feed Downloads → Host Signatures: resolves host APIs
- Feed Playback → Host Signatures: resolves host APIs
- Audio Comments → Host Signatures: resolves host APIs
- Comment Images → Host Signatures: resolves host APIs
- Host UI Hooks → Host Signatures: resolves host APIs
- Comment Media → Douyin App: hooks comment saving
- Comment Images → Douyin App: hooks image saving
- Audio Comments → Douyin App: hooks audio saving
- Feed Downloads → Douyin App: hooks feed saving
- Feed Playback → Douyin App: hooks playback
- Feed Features → Douyin App: filters feed
- Host UI Hooks → Douyin App: modifies host UI
- Config Manager → FastKV Storage: opens stores
- Config Manager → Config Providers: creates providers
- Config Providers → Rule Gates: evaluates rules
- Comment Media → Config Manager: reads options
- Feed Downloads → Config Manager: reads options
- User → Module Activity: opens settings
- Module Activity → Settings Entry Hook: starts host settings
- Settings Entry Hook → Settings Dialogs: shows dialog
- Settings Dialogs → Config Manager: edits options
- Comment Media → Device Album: saves media
- Feed Downloads → Device Album: saves media
