# inside4ndroid/tmdb-embed-api architecture

> Architecture diagram of the GitHub repository inside4ndroid/tmdb-embed-api, 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/inside4ndroid/tmdb-embed-api
- Repository: https://github.com/inside4ndroid/tmdb-embed-api

## Overview

TMDB Embed API accepts a media type and TMDB ID, gathers streams from enabled source providers, and returns an aggregate or provider-specific result. Its product also includes TMDB metadata/key handling, title and episode matching, configurable quality and codec filtering, an authenticated runtime configuration interface, health/status reporting, and an optional stream proxy. The API server is the principal orchestrator; provider implementations and supporting utilities form the internal layers. Some provider and route internals were not excerpted, so those relationships are included only where documented.

Main entry points: [`apiServer.js`](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/apiServer.js) (API server), [`providers/registry.js`](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/registry.js) (Provider registry), [`providers/onetouchtv.js`](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/onetouchtv.js) (OneTouchTV), [`utils/tmdbKey.js`](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/tmdbKey.js) (TMDB key rotation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and control"]
  node_server["API server<br/>[apiServer.js]"]
  node_proxy["Stream proxy<br/>[proxyServer.js]"]
end

subgraph group_sources["Stream sources"]
  node_provider_registry["Provider registry<br/>[registry.js]"]
  node_provider_4k["4KHDHub<br/>[4khdhub.js]"]
  node_provider_showbox["Showbox<br/>[Showbox.js]"]
  node_provider_onetouch["OneTouchTV<br/>[onetouchtv.js]"]
  node_provider_others["Other providers"]
  node_unpack["Script unpacking<br/>[jsunpack.js]"]
end

subgraph group_metadata["Metadata matching"]
  node_tmdb["TMDB metadata<br/>[tmdb.js]"]
  node_tmdb_key["TMDB key rotation<br/>[tmdbKey.js]"]
  node_title_match["Title matching<br/>[titleMatch.js]"]
  node_title_verify["TMDB title verification<br/>[tmdbTitleToImdb.js]"]
  node_episode_map["Episode mapping"]
  node_stream_filters["Stream filters<br/>[streamFilters.js]"]
end

subgraph group_operations["Runtime operations"]
  node_config["Runtime config<br/>[config.js]"]
  node_auth["Session authentication<br/>[auth.js]"]
  node_admin_ui["Admin dashboard<br/>[index.js]"]
  node_login_ui["Login interface<br/>[login.js]"]
  node_config_ui["Config interface<br/>[config.html]"]
end

node_consumer(("API client"))

node_consumer -->|"requests streams"| node_server
node_server -->|"dispatches providers"| node_provider_registry
node_provider_registry -.->|"registers provider"| node_provider_4k
node_provider_registry -.->|"registers provider"| node_provider_showbox
node_provider_registry -.->|"registers provider"| node_provider_onetouch
node_provider_registry -->|"registers providers"| node_provider_others
node_server -->|"uses metadata"| node_tmdb
node_server -->|"filters streams"| node_stream_filters
node_server -->|"loads config"| node_config
node_server -->|"uses sessions"| node_auth
node_server -->|"mounts routes"| node_proxy
node_tmdb -->|"gets API key"| node_tmdb_key
node_provider_4k -->|"gets API key"| node_tmdb_key
node_provider_showbox -->|"gets API key"| node_tmdb_key
node_provider_onetouch -->|"fetches details"| node_tmdb
node_provider_onetouch -->|"maps episodes"| node_episode_map
node_provider_onetouch -->|"matches titles"| node_title_match
node_provider_onetouch -->|"verifies title"| node_title_verify
node_title_verify -->|"gets API key"| node_tmdb_key
node_title_verify -->|"ranks candidates"| node_title_match
node_admin_ui -.->|"calls config API"| node_server
node_login_ui -.->|"calls auth API"| node_server
node_config_ui -->|"uses admin routes"| node_server
node_server -->|"saves overrides"| node_config
node_proxy -->|"serves proxied media"| node_consumer

click node_server "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/apiServer.js"
click node_provider_registry "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/registry.js"
click node_provider_4k "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/4khdhub.js"
click node_provider_showbox "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/Showbox.js"
click node_provider_onetouch "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/onetouchtv.js"
click node_provider_others "https://github.com/inside4ndroid/tmdb-embed-api/tree/main/providers"
click node_tmdb "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/tmdb.js"
click node_tmdb_key "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/tmdbKey.js"
click node_title_match "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/titleMatch.js"
click node_title_verify "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/tmdbTitleToImdb.js"
click node_episode_map "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/cinemetaEpisodes.js"
click node_stream_filters "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/streamFilters.js"
click node_proxy "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/proxy/proxyServer.js"
click node_config "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/config.js"
click node_auth "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/auth.js"
click node_admin_ui "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/public/index.js"
click node_login_ui "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/public/login.js"
click node_config_ui "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/public/config.html"
click node_unpack "https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/jsunpack.js"

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_server,node_proxy,node_consumer toneBlue
class node_provider_registry,node_provider_4k,node_provider_showbox,node_provider_onetouch,node_provider_others,node_unpack toneAmber
class node_tmdb,node_tmdb_key,node_title_match,node_title_verify,node_episode_map,node_stream_filters toneMint
class node_config,node_auth,node_admin_ui,node_login_ui,node_config_ui toneRose
```

## Components

### API and control

- [API server](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/apiServer.js): `apiServer.js`
- [Stream proxy](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/proxy/proxyServer.js): `proxy/proxyServer.js`

### Stream sources

- [Provider registry](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/registry.js): `providers/registry.js`
- [4KHDHub](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/4khdhub.js): `providers/4khdhub.js`
- [Showbox](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/Showbox.js): `providers/Showbox.js`
- [OneTouchTV](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/providers/onetouchtv.js): `providers/onetouchtv.js`
- [Other providers](https://github.com/inside4ndroid/tmdb-embed-api/tree/main/providers): `providers`
- [Script unpacking](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/jsunpack.js): `utils/jsunpack.js`

### Metadata matching

- [TMDB metadata](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/tmdb.js): `utils/tmdb.js`
- [TMDB key rotation](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/tmdbKey.js): `utils/tmdbKey.js`
- [Title matching](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/titleMatch.js): `utils/titleMatch.js`
- [TMDB title verification](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/tmdbTitleToImdb.js): `utils/tmdbTitleToImdb.js`
- [Episode mapping](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/cinemetaEpisodes.js): `utils/cinemetaEpisodes.js`
- [Stream filters](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/streamFilters.js): `utils/streamFilters.js`

### Runtime operations

- [Runtime config](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/config.js): `utils/config.js`
- [Session authentication](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/utils/auth.js): `utils/auth.js`
- [Admin dashboard](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/public/index.js): `public/index.js`
- [Login interface](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/public/login.js): `public/login.js`
- [Config interface](https://github.com/inside4ndroid/tmdb-embed-api/blob/main/public/config.html): `public/config.html`

### Other components

- **API client**

## Connections

- API client → API server: requests streams (evidence: `README.md`)
- API server → Provider registry: dispatches providers (evidence: `README.md`)
- Provider registry → 4KHDHub: registers provider
- Provider registry → Showbox: registers provider
- Provider registry → OneTouchTV: registers provider
- Provider registry → Other providers: registers providers (evidence: `README.md`)
- API server → TMDB metadata: uses metadata (evidence: `apiServer.js`)
- API server → Stream filters: filters streams (evidence: `apiServer.js`)
- API server → Runtime config: loads config (evidence: `apiServer.js`)
- API server → Session authentication: uses sessions (evidence: `apiServer.js`)
- API server → Stream proxy: mounts routes (evidence: `apiServer.js`)
- TMDB metadata → TMDB key rotation: gets API key (evidence: `utils/tmdb.js`)
- 4KHDHub → TMDB key rotation: gets API key (evidence: `providers/4khdhub.js`)
- Showbox → TMDB key rotation: gets API key (evidence: `providers/Showbox.js`)
- OneTouchTV → TMDB metadata: fetches details (evidence: `providers/onetouchtv.js`)
- OneTouchTV → Episode mapping: maps episodes (evidence: `providers/onetouchtv.js`)
- OneTouchTV → Title matching: matches titles (evidence: `providers/onetouchtv.js`)
- OneTouchTV → TMDB title verification: verifies title (evidence: `providers/onetouchtv.js`)
- TMDB title verification → TMDB key rotation: gets API key (evidence: `utils/tmdbTitleToImdb.js`)
- TMDB title verification → Title matching: ranks candidates (evidence: `utils/tmdbTitleToImdb.js`)
- Admin dashboard → API server: calls config API
- Login interface → API server: calls auth API
- Config interface → API server: uses admin routes (evidence: `README.md`)
- API server → Runtime config: saves overrides (evidence: `apiServer.js`)
- Stream proxy → API client: serves proxied media (evidence: `README.md`)
