# morpheusadam/playtube architecture

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

- Interactive diagram: https://gitdiagram.com/morpheusadam/playtube
- Repository: https://github.com/morpheusadam/playtube

## Overview

PlayTube is a self-hosted video-sharing CMS. A visitor enters through the PHP front controller, which dispatches page modules such as video listings; creators upload and stream media, while viewers browse and watch it. The README also documents mobile API access, monetization, community features, administration, themes, and optional real-time messaging. Relationships for sampled PHP routing and Node.js messaging are grounded in excerpts or the source index; broader product capabilities and integrations are represented from README statements, not unsampled implementation details.

Main entry points: [`index.php`](https://github.com/morpheusadam/playtube/blob/main/index.php) (PHP front controller), [`nodejs/server.js`](https://github.com/morpheusadam/playtube/blob/main/nodejs/server.js) (Socket.IO service), [`admin-panel/search-result.php`](https://github.com/morpheusadam/playtube/blob/main/admin-panel/search-result.php) (Admin dashboard), [`nodejs/functions.js`](https://github.com/morpheusadam/playtube/blob/main/nodejs/functions.js) (Realtime helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_front["PHP front controller<br/>[index.php]"]
  node_themes["Front-end themes"]
end

subgraph group_content["Content lifecycle"]
  node_video_catalog["Video discovery<br/>[content.php]"]
  node_watch["Video playback<br/>[content.php]"]
  node_upload["Video uploads<br/>[content.php]"]
  node_shorts["Short-form videos<br/>[content.php]"]
  node_live["Live streaming<br/>[content.php]"]
end

subgraph group_community["Community and revenue"]
  node_channels["Channels and subscriptions<br/>[content.php]"]
  node_social["Comments and timeline<br/>[content.php]"]
  node_articles["Articles and hashtags<br/>[content.php]"]
  node_history["History and likes<br/>[content.php]"]
  node_monetization["Paid videos and plans<br/>[content.php]"]
  node_transactions["Wallet transactions<br/>[content.php]"]
  node_ads["Ads and affiliates<br/>[content.php]"]
end

subgraph group_operations["Administration and API"]
  node_search_api["Mobile video search<br/>[search_videos.php]"]
  node_api["Mobile REST API<br/>[v1.0]"]
  node_admin["Admin dashboard<br/>[search-result.php]"]
  node_analytics["Video analytics<br/>[content.php]"]
  node_editor["CodeMirror editor<br/>[codemirror.js]"]
  node_xquery["XQuery syntax mode<br/>[xquery.js]"]
end

subgraph group_realtime["Real-time service"]
  node_node_server["Socket.IO service<br/>[server.js]"]
  node_node_config["Realtime configuration<br/>[app_start.js]"]
  node_node_functions["Realtime helpers<br/>[functions.js]"]
  node_node_db[("Realtime DB pool<br/>[DB.js]")]
end

node_visitor(("Visitor or creator"))
node_mysql[("MySQL database")]
node_ffmpeg["FFmpeg transcoder"]

node_visitor -->|"requests page"| node_front
node_front -->|"routes page"| node_video_catalog
node_front -.->|"routes page"| node_watch
node_front -.->|"routes page"| node_upload
node_front -.->|"routes page"| node_shorts
node_front -.->|"routes page"| node_live
node_video_catalog -->|"queries videos"| node_mysql
node_visitor -.->|"requests mobile data"| node_api
node_api -.->|"routes search"| node_search_api
node_search_api -->|"queries videos"| node_mysql
node_upload -.->|"transcodes media"| node_ffmpeg
node_watch -.->|"streams media"| node_ffmpeg
node_visitor -.->|"uses channels"| node_channels
node_visitor -.->|"posts and comments"| node_social
node_visitor -.->|"reads and publishes"| node_articles
node_visitor -.->|"browses activity"| node_history
node_visitor -.->|"buys plans"| node_monetization
node_monetization -.->|"records payments"| node_transactions
node_visitor -.->|"views promotions"| node_ads
node_visitor -.->|"administers site"| node_admin
node_admin -.->|"reviews metrics"| node_analytics
node_admin -.->|"uses editor"| node_editor
node_xquery -->|"registers syntax mode"| node_editor
node_node_server -->|"loads settings"| node_node_config
node_node_server -->|"calls helpers"| node_node_functions
node_node_server -->|"queries database"| node_node_db
node_node_functions -->|"loads settings"| node_node_config
node_node_functions -->|"queries database"| node_node_db
node_node_db -->|"connects pool"| node_mysql

click node_front "https://github.com/morpheusadam/playtube/blob/main/index.php"
click node_themes "https://github.com/morpheusadam/playtube/tree/main/themes/default"
click node_video_catalog "https://github.com/morpheusadam/playtube/blob/main/sources/videos/content.php"
click node_watch "https://github.com/morpheusadam/playtube/blob/main/sources/watch/content.php"
click node_upload "https://github.com/morpheusadam/playtube/blob/main/sources/upload-video/content.php"
click node_shorts "https://github.com/morpheusadam/playtube/blob/main/sources/shorts/content.php"
click node_live "https://github.com/morpheusadam/playtube/blob/main/sources/videos/content.php"
click node_search_api "https://github.com/morpheusadam/playtube/blob/main/app_api/v1.0/platform/mobile/search_videos.php"
click node_api "https://github.com/morpheusadam/playtube/tree/main/app_api/v1.0"
click node_channels "https://github.com/morpheusadam/playtube/blob/main/sources/popular_channels/content.php"
click node_social "https://github.com/morpheusadam/playtube/blob/main/sources/comments/content.php"
click node_articles "https://github.com/morpheusadam/playtube/blob/main/sources/articles/content.php"
click node_history "https://github.com/morpheusadam/playtube/blob/main/sources/history/content.php"
click node_monetization "https://github.com/morpheusadam/playtube/blob/main/sources/paid-videos/content.php"
click node_transactions "https://github.com/morpheusadam/playtube/blob/main/sources/transactions/content.php"
click node_ads "https://github.com/morpheusadam/playtube/blob/main/sources/ads_analytics/content.php"
click node_admin "https://github.com/morpheusadam/playtube/blob/main/admin-panel/search-result.php"
click node_analytics "https://github.com/morpheusadam/playtube/blob/main/sources/view_analytics/content.php"
click node_editor "https://github.com/morpheusadam/playtube/blob/main/admin-panel/vendors/codemirror-5.30.0/lib/codemirror.js"
click node_xquery "https://github.com/morpheusadam/playtube/blob/main/admin-panel/vendors/codemirror-5.30.0/mode/xquery/xquery.js"
click node_node_server "https://github.com/morpheusadam/playtube/blob/main/nodejs/server.js"
click node_node_config "https://github.com/morpheusadam/playtube/blob/main/nodejs/app_start.js"
click node_node_functions "https://github.com/morpheusadam/playtube/blob/main/nodejs/functions.js"
click node_node_db "https://github.com/morpheusadam/playtube/blob/main/nodejs/mysql/DB.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_front,node_themes toneBlue
class node_video_catalog,node_watch,node_upload,node_shorts,node_live,node_mysql toneAmber
class node_channels,node_social,node_articles,node_history,node_monetization,node_transactions,node_ads toneMint
class node_search_api,node_api,node_admin,node_analytics,node_editor,node_xquery toneRose
class node_node_server,node_node_config,node_node_functions,node_node_db,node_visitor,node_ffmpeg toneIndigo
```

## Components

### Web experience

- [PHP front controller](https://github.com/morpheusadam/playtube/blob/main/index.php): `index.php`
- [Front-end themes](https://github.com/morpheusadam/playtube/tree/main/themes/default): `themes/default`

### Content lifecycle

- [Video discovery](https://github.com/morpheusadam/playtube/blob/main/sources/videos/content.php): `sources/videos/content.php`
- [Video playback](https://github.com/morpheusadam/playtube/blob/main/sources/watch/content.php): `sources/watch/content.php`
- [Video uploads](https://github.com/morpheusadam/playtube/blob/main/sources/upload-video/content.php): `sources/upload-video/content.php`
- [Short-form videos](https://github.com/morpheusadam/playtube/blob/main/sources/shorts/content.php): `sources/shorts/content.php`
- [Live streaming](https://github.com/morpheusadam/playtube/blob/main/sources/videos/content.php): `sources/videos/content.php`

### Community and revenue

- [Channels and subscriptions](https://github.com/morpheusadam/playtube/blob/main/sources/popular_channels/content.php): `sources/popular_channels/content.php`
- [Comments and timeline](https://github.com/morpheusadam/playtube/blob/main/sources/comments/content.php): `sources/comments/content.php`
- [Articles and hashtags](https://github.com/morpheusadam/playtube/blob/main/sources/articles/content.php): `sources/articles/content.php`
- [History and likes](https://github.com/morpheusadam/playtube/blob/main/sources/history/content.php): `sources/history/content.php`
- [Paid videos and plans](https://github.com/morpheusadam/playtube/blob/main/sources/paid-videos/content.php): `sources/paid-videos/content.php`
- [Wallet transactions](https://github.com/morpheusadam/playtube/blob/main/sources/transactions/content.php): `sources/transactions/content.php`
- [Ads and affiliates](https://github.com/morpheusadam/playtube/blob/main/sources/ads_analytics/content.php): `sources/ads_analytics/content.php`

### Administration and API

- [Mobile video search](https://github.com/morpheusadam/playtube/blob/main/app_api/v1.0/platform/mobile/search_videos.php): `app_api/v1.0/platform/mobile/search_videos.php`
- [Mobile REST API](https://github.com/morpheusadam/playtube/tree/main/app_api/v1.0): `app_api/v1.0`
- [Admin dashboard](https://github.com/morpheusadam/playtube/blob/main/admin-panel/search-result.php): `admin-panel/search-result.php`
- [Video analytics](https://github.com/morpheusadam/playtube/blob/main/sources/view_analytics/content.php): `sources/view_analytics/content.php`
- [CodeMirror editor](https://github.com/morpheusadam/playtube/blob/main/admin-panel/vendors/codemirror-5.30.0/lib/codemirror.js): `admin-panel/vendors/codemirror-5.30.0/lib/codemirror.js`
- [XQuery syntax mode](https://github.com/morpheusadam/playtube/blob/main/admin-panel/vendors/codemirror-5.30.0/mode/xquery/xquery.js): `admin-panel/vendors/codemirror-5.30.0/mode/xquery/xquery.js`

### Real-time service

- [Socket.IO service](https://github.com/morpheusadam/playtube/blob/main/nodejs/server.js): `nodejs/server.js`
- [Realtime configuration](https://github.com/morpheusadam/playtube/blob/main/nodejs/app_start.js): `nodejs/app_start.js`
- [Realtime helpers](https://github.com/morpheusadam/playtube/blob/main/nodejs/functions.js): `nodejs/functions.js`
- [Realtime DB pool](https://github.com/morpheusadam/playtube/blob/main/nodejs/mysql/DB.js): `nodejs/mysql/DB.js`

### Other components

- **Visitor or creator**
- **MySQL database**
- **FFmpeg transcoder**

## Connections

- Visitor or creator → PHP front controller: requests page (evidence: `index.php`)
- PHP front controller → Video discovery: routes page (evidence: `index.php`)
- PHP front controller → Video playback: routes page
- PHP front controller → Video uploads: routes page
- PHP front controller → Short-form videos: routes page
- PHP front controller → Live streaming: routes page
- Video discovery → MySQL database: queries videos (evidence: `sources/videos/content.php`)
- Visitor or creator → Mobile REST API: requests mobile data
- Mobile REST API → Mobile video search: routes search
- Mobile video search → MySQL database: queries videos (evidence: `app_api/v1.0/platform/mobile/search_videos.php`)
- Video uploads → FFmpeg transcoder: transcodes media
- Video playback → FFmpeg transcoder: streams media
- Visitor or creator → Channels and subscriptions: uses channels
- Visitor or creator → Comments and timeline: posts and comments
- Visitor or creator → Articles and hashtags: reads and publishes
- Visitor or creator → History and likes: browses activity
- Visitor or creator → Paid videos and plans: buys plans
- Paid videos and plans → Wallet transactions: records payments
- Visitor or creator → Ads and affiliates: views promotions
- Visitor or creator → Admin dashboard: administers site
- Admin dashboard → Video analytics: reviews metrics
- Admin dashboard → CodeMirror editor: uses editor
- XQuery syntax mode → CodeMirror editor: registers syntax mode (evidence: `admin-panel/vendors/codemirror-5.30.0/mode/xquery/xquery.js`)
- Socket.IO service → Realtime configuration: loads settings (evidence: `nodejs/server.js`)
- Socket.IO service → Realtime helpers: calls helpers (evidence: `nodejs/server.js`)
- Socket.IO service → Realtime DB pool: queries database (evidence: `nodejs/server.js`)
- Realtime helpers → Realtime configuration: loads settings (evidence: `nodejs/functions.js`)
- Realtime helpers → Realtime DB pool: queries database (evidence: `nodejs/functions.js`)
- Realtime DB pool → MySQL database: connects pool (evidence: `nodejs/mysql/DB.js`)
