# webhtv/webhtv architecture

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

- Interactive diagram: https://gitdiagram.com/webhtv/webhtv
- Repository: https://github.com/webhtv/webhtv

## Overview

WebHomeTV is an Android TV and mobile media app built on the FongMi/CatVod ecosystem. A user selects a live channel or on-demand title in the app or custom WebHome, which uses app capabilities to search, resolve and play media through the playback service and player engines. The product also includes local management and HTTP APIs, device synchronization, remote hosting, and playback-history synchronization. The graph preserves major README-described capabilities; beyond the sampled playback and drive-check code, those subsystem links are documented in the README rather than verified against their implementation.

Main entry points: [`app/src/leanback/java/com/fongmi/android/tv/ui/activity`](https://github.com/webhtv/webhtv/tree/main/app/src/leanback/java/com/fongmi/android/tv/ui/activity) (TV and mobile UI), [`app/src/main/java/com/fongmi/android/tv/api`](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/api) (CSP and Spider runtime), [`webhome-devkit`](https://github.com/webhtv/webhtv/tree/main/webhome-devkit) (Custom WebHome), [`app/src/main/java/com/fongmi/android/tv`](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv) (Device and history sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_custom_home["Custom WebHome"]
  node_app_ui["TV and mobile UI"]
end

subgraph group_media["Media runtime"]
  node_playback_service["Playback service"]
  node_player_manager["Player manager<br/>[PlayerManager.java]"]
  node_player_engines["Player engines"]
end

subgraph group_webhome["WebHome and APIs"]
  node_site_runtime["CSP and Spider runtime"]
  node_native_sdk["Native SDK"]
  node_local_api["Local HTTP services"]
  node_live_vod["Live and VOD<br/>[LiveApi.java]"]
  node_drive_check["Drive link checks"]
  node_health["Site health ranking"]
  node_management["LAN management"]
end

subgraph group_state["State and sync"]
  node_local_state[("App state")]
  node_sync["Device and history sync"]
end

subgraph group_integrations["External services"]
  node_remote_agent["Remote device agent"]
  node_relay["Remote relay services"]
  node_cloud_git["Git cloud providers"]
end

node_user(("Viewer"))
node_content_sources{{"Media and site sources"}}
node_remote_admin(("Remote administrator"))

node_user -->|"browses"| node_app_ui
node_user -->|"opens"| node_custom_home
node_app_ui -->|"selects sources"| node_site_runtime
node_custom_home -->|"calls capabilities"| node_native_sdk
node_native_sdk -->|"uses APIs"| node_local_api
node_site_runtime -->|"requests media"| node_content_sources
node_site_runtime -->|"loads live and VOD"| node_live_vod
node_app_ui -->|"starts playback"| node_playback_service
node_playback_service -->|"controls playback"| node_player_manager
node_player_manager -->|"selects engine"| node_player_engines
node_player_engines -.->|"plays streams"| node_content_sources
node_custom_home -->|"checks links"| node_drive_check
node_local_api -->|"checks links"| node_drive_check
node_site_runtime -->|"uses site ranking"| node_health
node_app_ui -->|"opens management"| node_management
node_management -->|"manages data"| node_local_state
node_sync -->|"merges state"| node_local_state
node_user -->|"starts sync"| node_sync
node_remote_admin -->|"manages devices"| node_relay
node_relay -->|"relays requests"| node_remote_agent
node_remote_agent -->|"triggers search and push"| node_app_ui
node_sync -->|"syncs playback history"| node_relay
node_app_ui -.->|"uses hosted config"| node_cloud_git

click node_custom_home "https://github.com/webhtv/webhtv/tree/main/webhome-devkit"
click node_app_ui "https://github.com/webhtv/webhtv/tree/main/app/src/leanback/java/com/fongmi/android/tv/ui/activity"
click node_site_runtime "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/api"
click node_native_sdk "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/web"
click node_local_api "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/server"
click node_playback_service "https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/service/PlaybackService.java"
click node_player_manager "https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/player/PlayerManager.java"
click node_player_engines "https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/player/engine/ExoPlayerEngine.java"
click node_live_vod "https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/api/LiveApi.java"
click node_drive_check "https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/service/DriveCheckService.java"
click node_health "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/api"
click node_management "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/server"
click node_local_state "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/db"
click node_sync "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv"
click node_remote_agent "https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/remote/RemoteAgentService.java"
click node_relay "https://github.com/webhtv/webhtv/tree/main/serverless"
click node_cloud_git "https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/gitcloud"

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_custom_home,node_app_ui,node_user toneBlue
class node_playback_service,node_player_manager,node_player_engines toneAmber
class node_site_runtime,node_native_sdk,node_local_api,node_live_vod,node_drive_check,node_health,node_management toneMint
class node_local_state,node_sync toneRose
class node_remote_agent,node_relay,node_cloud_git,node_content_sources,node_remote_admin toneIndigo
```

## Components

### App experience

- [Custom WebHome](https://github.com/webhtv/webhtv/tree/main/webhome-devkit): `webhome-devkit`
- [TV and mobile UI](https://github.com/webhtv/webhtv/tree/main/app/src/leanback/java/com/fongmi/android/tv/ui/activity): `app/src/leanback/java/com/fongmi/android/tv/ui/activity`

### Media runtime

- [Playback service](https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/service/PlaybackService.java): `app/src/main/java/com/fongmi/android/tv/service/PlaybackService.java`
- [Player manager](https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/player/PlayerManager.java): `app/src/main/java/com/fongmi/android/tv/player/PlayerManager.java`
- [Player engines](https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/player/engine/ExoPlayerEngine.java): `app/src/main/java/com/fongmi/android/tv/player/engine/ExoPlayerEngine.java`

### WebHome and APIs

- [CSP and Spider runtime](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/api): `app/src/main/java/com/fongmi/android/tv/api`
- [Native SDK](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/web): `app/src/main/java/com/fongmi/android/tv/web`
- [Local HTTP services](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/server): `app/src/main/java/com/fongmi/android/tv/server`
- [Live and VOD](https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/api/LiveApi.java): `app/src/main/java/com/fongmi/android/tv/api/LiveApi.java`
- [Drive link checks](https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/service/DriveCheckService.java): `app/src/main/java/com/fongmi/android/tv/service/DriveCheckService.java`
- [Site health ranking](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/api): `app/src/main/java/com/fongmi/android/tv/api`
- [LAN management](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/server): `app/src/main/java/com/fongmi/android/tv/server`

### State and sync

- [App state](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/db): `app/src/main/java/com/fongmi/android/tv/db`
- [Device and history sync](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv): `app/src/main/java/com/fongmi/android/tv`

### External services

- [Remote device agent](https://github.com/webhtv/webhtv/blob/main/app/src/main/java/com/fongmi/android/tv/remote/RemoteAgentService.java): `app/src/main/java/com/fongmi/android/tv/remote/RemoteAgentService.java`
- [Remote relay services](https://github.com/webhtv/webhtv/tree/main/serverless): `serverless`
- [Git cloud providers](https://github.com/webhtv/webhtv/tree/main/app/src/main/java/com/fongmi/android/tv/gitcloud): `app/src/main/java/com/fongmi/android/tv/gitcloud`

### Other components

- **Viewer**
- **Media and site sources**
- **Remote administrator**

## Connections

- Viewer → TV and mobile UI: browses (evidence: `README.md`)
- Viewer → Custom WebHome: opens (evidence: `README.md`)
- TV and mobile UI → CSP and Spider runtime: selects sources (evidence: `README.md`)
- Custom WebHome → Native SDK: calls capabilities (evidence: `README.md`)
- Native SDK → Local HTTP services: uses APIs (evidence: `README.md`)
- CSP and Spider runtime → Media and site sources: requests media (evidence: `README.md`)
- CSP and Spider runtime → Live and VOD: loads live and VOD (evidence: `README.md`)
- TV and mobile UI → Playback service: starts playback (evidence: `README.md`)
- Playback service → Player manager: controls playback (evidence: `app/src/main/java/com/fongmi/android/tv/service/PlaybackService.java`)
- Player manager → Player engines: selects engine (evidence: `app/src/main/java/com/fongmi/android/tv/player/PlayerManager.java`)
- Player engines → Media and site sources: plays streams
- Custom WebHome → Drive link checks: checks links (evidence: `README.md`)
- Local HTTP services → Drive link checks: checks links (evidence: `README.md`)
- CSP and Spider runtime → Site health ranking: uses site ranking (evidence: `README.md`)
- TV and mobile UI → LAN management: opens management (evidence: `README.md`)
- LAN management → App state: manages data (evidence: `README.md`)
- Device and history sync → App state: merges state (evidence: `README.md`)
- Viewer → Device and history sync: starts sync (evidence: `README.md`)
- Remote administrator → Remote relay services: manages devices (evidence: `README.md`)
- Remote relay services → Remote device agent: relays requests (evidence: `README.md`)
- Remote device agent → TV and mobile UI: triggers search and push (evidence: `README.md`)
- Device and history sync → Remote relay services: syncs playback history (evidence: `README.md`)
- TV and mobile UI → Git cloud providers: uses hosted config
