# neworin/tvbox architecture

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

- Interactive diagram: https://gitdiagram.com/neworin/tvbox
- Repository: https://github.com/neworin/tvbox

## Overview

##### Project type and purpose
- This is an open‑source “resource repository” for the Android TVBox application. It does not contain full application code, but instead hosts JSON and JAR‑based scraper definitions (“crawlers”), live EPG sources, extension scripts, and VOD metadata. Clients (Android app, Web editor) dynamically load these resources to aggregate video sources without any built‑in backend.

##### File structure
- Top level:
- README.md, m.json, dm.txt, dc.txt — bootstrap manifests and documentation
- sub/ — primary module folder
- vod/ — offline VOD metadata folder
- xiaopingguo.json — single “small Apple” manifest
- sub/:
- MeowXB/, MeowXP/ — two large sets of JSON crawler definitions, each with hundreds of files
- ext/ — additional JSON/​TXT definitions for sports, music, token lists, etc.
- jar/ — Java .jar crawler packages used by the Android app at runtime
- live/ — live EPG playlist text files and metadata
- dr/ — one or more JavaScript-based extension scripts (e.g., 豆瓣.js)
- vod/:
- A hierarchy by numeric IDs (501, 601, 701…) containing JSON/TXT metadata and a README.md.

##### README for additional insights
- Confirms the repo powers TVBox OSC (Android), Web JSON editor, and supplies unlimited scraper sources (no ads).
- Supports multiple JAR‑based crawlers, EPG XML sources for live TV guides.

##### Components
a. Main components
1. Client Apps
- Android TVBoxOSC App
- CatVodTVJsonEditor (Web/PC)
2. CDN / Git Raw Hosting
- raw.liucn.cc, jsdelivr, ghproxy, etc.
3. Resource Repository
- m.json (master manifest)
- dm.txt, dc.txt (alternative manifests)
- sub/ (MeowXB, MeowXP, ext, jar, live, dr)
- vod/ (offline metadata sets)
4. External Target Sites
- Various third‑party video websites (defined by JSON/JAR modules)
5. EPG Services
- epg.51zmt.top, epg.112114.xyz
6. Runtime Environment
- Android WebView / JavaScript engine / Java runtime for JARs
b. Relationships & interactions
- Client → HTTP GET m.json from CDN
→ parse manifest → discover module URLs
→ fetch JSON modules (sub/MeowXB, ext/, vod/) & JARs
→ load scraper definitions into runtime
→ at user request, scraper logic issues HTTP calls to External Target Sites
→ parse HTML/JSON → return video listings/streams
- Client → fetch live EPG XML from EPG Services
- Editor App → HTTP GET manifests & JSON → present in GUI for editing
c. Architectural patterns & design principles
- Plugin/Module‑based architecture: JSON + JAR modules define crawling logic, loaded at runtime
- Content Delivery via CDN: static files hosted on Git/raw hosts for global access
- Schema‑driven parsing: JSON files define selectors, endpoints, parse rules
- Separation of concerns:
- Manifest (m.json) drives module discovery
- sub/ modules hold discrete sets of sources
- vod/ offline VOD served by metadata files
d. Key technologies & frameworks
- HTTP/HTTPS for content delivery
- JSON schema for scraper definitions
- Java/.jar packages for advanced crawling in Android
- JavaScript for small extensions (dr/豆瓣.js)
- CDN accelerators (jsdelivr, rawfast, ghproxy, GitCDN)

##### Elements
- Clear labels:
- “Client Apps” (Android, Editor)
- “CDN / Git Raw Hosts”
- “Resource Repository” (m.json, sub/, vod/)
- “External Video Sites”
- “EPG Services”
1. App → CDN (manifests, modules)
2. App → External Sites → App (scraped data)
3. App → EPG Service → App
- Orange clouds for external dependencies (Video Sites, EPG Services)
- Clients in purple

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Applications
    subgraph "Client Apps" 
        direction TB
        AndroidApp["Android TVBoxOSC App"]:::client
        EditorApp["CatVodTVJsonEditor (Web)"]:::client
        subgraph "Android App Runtime"
            direction TB
            UI["UI Layer"]:::client
            PluginMgr["Plugin Manager"]:::runtime
            ScraperEngine["Scraper Engine"]:::runtime
            VideoPlayer["Video Player"]:::client
        end
    end

    %% CDN and Repository
    subgraph "CDN / Git Raw Hosts" 
        direction TB
        CDN["raw.liucn.cc/jsdelivr/ghproxy/etc."]:::external
    end

    subgraph "Resource Repository" 
        direction TB
        ManifestGroup["Manifest Files"]:::static
        subgraph "Manifests"
            direction TB
            MasterManifest["m.json"]:::static
            AltManifest1["dm.txt"]:::static
            AltManifest2["dc.txt"]:::static
            SmallApple["xiaopingguo.json"]:::static
        end
        subgraph "Modules (sub/)"
            direction TB
            SubFolder["sub/"]:::static
            MeowXB["MeowXB Module"]:::static
            MeowXP["MeowXP Module"]:::static
            ExtMod["ext/ Definitions"]:::static
            JarMod["jar/ JAR Packages"]:::static
            LiveMod["live/ EPG Files"]:::static
            DRMod["dr/ JS Extensions"]:::static
        end
        subgraph "VOD Metadata (vod/)"
            direction TB
            VODFolder["vod/"]:::static
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        VideoSites["External Video Sites"]:::external
        EPGServices["EPG Services"]:::external
    end

    %% Connections: Android App
    AndroidApp --> UI
    UI --> PluginMgr
    PluginMgr -->|Fetch master manifest| CDN
    CDN --> MasterManifest
    CDN --> AltManifest1
    CDN --> AltManifest2
    CDN --> SmallApple

    PluginMgr -->|Load manifest modules| MasterManifest
    MasterManifest --> SubFolder
    SubFolder --> MeowXB
    SubFolder --> MeowXP
    SubFolder --> ExtMod
    SubFolder --> JarMod
    SubFolder --> LiveMod
    SubFolder --> DRMod
    SubFolder --> VODFolder

    PluginMgr -->|Fetch JSON modules| MeowXB
    PluginMgr -->|Fetch JSON modules| MeowXP
    PluginMgr -->|Fetch JSON modules| ExtMod
    PluginMgr -->|Fetch JARs| JarMod
    PluginMgr -->|Fetch EPG files| LiveMod
    PluginMgr -->|Fetch JS extensions| DRMod
    PluginMgr -->|Fetch VOD metadata| VODFolder

    PluginMgr --> ScraperEngine
    ScraperEngine -->|HTTP scrape request| VideoSites
    ScraperEngine -->|Fetch EPG XML| EPGServices
    ScraperEngine --> UI
    UI -->|Play stream| VideoPlayer

    %% Editor App Flow
    EditorApp -->|Fetch manifests & JSON| CDN
    CDN --> MasterManifest
    CDN --> SubFolder
    EditorApp -->|Present modules in GUI| MasterManifest

    %% Click Events
    click MasterManifest "https://github.com/neworin/tvbox/blob/main/m.json"
    click AltManifest1 "https://github.com/neworin/tvbox/blob/main/dm.txt"
    click AltManifest2 "https://github.com/neworin/tvbox/blob/main/dc.txt"
    click SmallApple "https://github.com/neworin/tvbox/blob/main/xiaopingguo.json"
    click SubFolder "https://github.com/neworin/tvbox/tree/main/sub/"
    click MeowXB "https://github.com/neworin/tvbox/tree/main/sub/MeowXB/"
    click MeowXP "https://github.com/neworin/tvbox/tree/main/sub/MeowXP/"
    click ExtMod "https://github.com/neworin/tvbox/tree/main/sub/ext/"
    click JarMod "https://github.com/neworin/tvbox/tree/main/sub/jar/"
    click LiveMod "https://github.com/neworin/tvbox/tree/main/sub/live/"
    click DRMod "https://github.com/neworin/tvbox/tree/main/sub/dr/"
    click VODFolder "https://github.com/neworin/tvbox/tree/main/vod/"

    %% Styles
    classDef static fill:#e0f7fa,stroke:#0087a3,color:#000
    classDef runtime fill:#e0ffe0,stroke:#2e7d32,color:#000
    classDef client fill:#f3e5f5,stroke:#6a1b9a,color:#000
    classDef external fill:#ffecb3,stroke:#ef6c00,color:#000
```
