# cpuchalver/som-stream architecture

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

- Interactive diagram: https://gitdiagram.com/cpuchalver/som-stream
- Repository: https://github.com/cpuchalver/som-stream

## Overview

This Laravel application manages video libraries and playlists, then schedules and runs live broadcasts to configured destinations. The principal workflow is to upload and normalize videos, organize ready media into playlists, configure destinations and broadcasts, and let the broadcast engine stream and track playback. Separate branches handle Twitch chat-bot connections and commands, while Filament provides administration. The README is generic Laravel documentation; edges are limited to relationships supported by sampled source or the source index, with uncertain integrations left dashed.

Main entry points: [`app/Providers/Filament/AdminPanelProvider.php`](https://github.com/cpuchalver/som-stream/blob/main/app/Providers/Filament/AdminPanelProvider.php) (Filament Admin), [`app/Broadcasting/BroadcastEngine.php`](https://github.com/cpuchalver/som-stream/blob/main/app/Broadcasting/BroadcastEngine.php) (Broadcast Engine), [`app/Models/Video.php`](https://github.com/cpuchalver/som-stream/blob/main/app/Models/Video.php) (Video Library), [`app/Chat/Twitch/TwitchChatBot.php`](https://github.com/cpuchalver/som-stream/blob/main/app/Chat/Twitch/TwitchChatBot.php) (Twitch Chat Bot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin["Administration"]
  node_adminui["Filament Admin"]
  node_broadcastadmin["Broadcast Admin"]
  node_playlistadmin["Playlist Admin"]
  node_videoadmin["Video Admin<br/>[VideoResource.php]"]
  node_destinationadmin["Destination Admin"]
  node_chatadmin["Chat Command Admin"]
end

subgraph group_media["Media Library"]
  node_uploads["Chunked Uploads"]
  node_uploadrecords[("Upload Records<br/>[VideoUpload.php]")]
  node_videorecords[("Video Library<br/>[Video.php]")]
  node_normalizer["Video Normalizer<br/>[NormalizeVideo.php]"]
  node_playlistrecords[("Playlists<br/>[Playlist.php]")]
end

subgraph group_broadcast["Broadcast Runtime"]
  node_broadcastrecords[("Broadcast Records<br/>[Broadcast.php]")]
  node_destinationrecords[("Destinations<br/>[Destination.php]")]
  node_engine["Broadcast Engine"]
  node_cycle["Playlist Cycle<br/>[CyclePlaylist.php]"]
  node_running["Running State"]
  node_ffmpeg["FFmpeg Commands<br/>[FfmpegCommands.php]"]
end

subgraph group_chat["Twitch Chat"]
  node_twitchconnect["Twitch OAuth"]
  node_twitchcallback["Twitch Callback"]
  node_chataccounts[("Chat Accounts<br/>[ChatAccount.php]")]
  node_chatbot["Twitch Chat Bot<br/>[TwitchChatBot.php]"]
  node_chatcommands["Command Responder"]
end

subgraph group_platform["Application Services"]
  node_events["Change Events"]
  node_broadcastnotify["Broadcast Notifications"]
  node_videoevents["Video Change Event<br/>[VideoChanged.php]"]
  node_videonotify["Video Notifications"]
end

node_operator(("Administrator"))
node_streamdest(("Streaming Destinations"))
node_twitch(("Twitch Services"))

node_operator -.->|"manages"| node_adminui
node_adminui -.->|"offers"| node_broadcastadmin
node_adminui -.->|"offers"| node_playlistadmin
node_adminui -.->|"offers"| node_videoadmin
node_adminui -.->|"offers"| node_destinationadmin
node_adminui -.->|"offers"| node_chatadmin
node_uploads -->|"creates"| node_uploadrecords
node_uploads -->|"uses storage disk"| node_videorecords
node_normalizer -->|"updates"| node_videorecords
node_normalizer -->|"uses"| node_ffmpeg
node_playlistadmin -.->|"edits"| node_playlistrecords
node_videoadmin -.->|"edits"| node_videorecords
node_broadcastadmin -.->|"edits"| node_broadcastrecords
node_destinationadmin -.->|"edits"| node_destinationrecords
node_chatadmin -.->|"manages"| node_chatcommands
node_engine -->|"queries and updates"| node_broadcastrecords
node_engine -->|"builds cycle"| node_cycle
node_engine -->|"starts stream"| node_ffmpeg
node_engine -->|"tracks process"| node_running
node_cycle -->|"reads playlist"| node_playlistrecords
node_cycle -->|"selects videos"| node_videorecords
node_engine -->|"loads enabled targets"| node_destinationrecords
node_ffmpeg -.->|"streams to"| node_streamdest
node_twitchconnect -->|"redirects for OAuth"| node_twitch
node_twitchcallback -->|"exchanges code"| node_twitch
node_twitchcallback -->|"saves tokens"| node_chataccounts
node_chatbot -->|"reads account"| node_chataccounts
node_chatbot -->|"dispatches commands"| node_chatcommands
node_chatbot -.->|"connects chat"| node_twitch
node_broadcastrecords -->|"dispatches changes"| node_events
node_events -->|"handles status changes"| node_broadcastnotify
node_videorecords -->|"dispatches changes"| node_videoevents
node_videoevents -.->|"handles video changes"| node_videonotify

click node_adminui "https://github.com/cpuchalver/som-stream/blob/main/app/Providers/Filament/AdminPanelProvider.php"
click node_broadcastadmin "https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Broadcasts/BroadcastResource.php"
click node_playlistadmin "https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Playlists/PlaylistResource.php"
click node_videoadmin "https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Videos/VideoResource.php"
click node_destinationadmin "https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Destinations/DestinationResource.php"
click node_chatadmin "https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/ChatCommands/ChatCommandResource.php"
click node_uploads "https://github.com/cpuchalver/som-stream/blob/main/app/Http/Controllers/VideoUploadsController.php"
click node_uploadrecords "https://github.com/cpuchalver/som-stream/blob/main/app/Models/VideoUpload.php"
click node_videorecords "https://github.com/cpuchalver/som-stream/blob/main/app/Models/Video.php"
click node_normalizer "https://github.com/cpuchalver/som-stream/blob/main/app/Jobs/NormalizeVideo.php"
click node_playlistrecords "https://github.com/cpuchalver/som-stream/blob/main/app/Models/Playlist.php"
click node_broadcastrecords "https://github.com/cpuchalver/som-stream/blob/main/app/Models/Broadcast.php"
click node_destinationrecords "https://github.com/cpuchalver/som-stream/blob/main/app/Models/Destination.php"
click node_engine "https://github.com/cpuchalver/som-stream/blob/main/app/Broadcasting/BroadcastEngine.php"
click node_cycle "https://github.com/cpuchalver/som-stream/blob/main/app/Broadcasting/CyclePlaylist.php"
click node_running "https://github.com/cpuchalver/som-stream/blob/main/app/Broadcasting/RunningBroadcast.php"
click node_ffmpeg "https://github.com/cpuchalver/som-stream/blob/main/app/Support/Ffmpeg/FfmpegCommands.php"
click node_twitchconnect "https://github.com/cpuchalver/som-stream/blob/main/app/Http/Controllers/TwitchConnectionsController.php"
click node_twitchcallback "https://github.com/cpuchalver/som-stream/blob/main/app/Http/Controllers/TwitchConnectionCallbackController.php"
click node_chataccounts "https://github.com/cpuchalver/som-stream/blob/main/app/Models/ChatAccount.php"
click node_chatbot "https://github.com/cpuchalver/som-stream/blob/main/app/Chat/Twitch/TwitchChatBot.php"
click node_chatcommands "https://github.com/cpuchalver/som-stream/blob/main/app/Chat/ChatCommandResponder.php"
click node_events "https://github.com/cpuchalver/som-stream/blob/main/app/Events/BroadcastChanged.php"
click node_broadcastnotify "https://github.com/cpuchalver/som-stream/blob/main/app/Listeners/SendBroadcastStatusNotificationListener.php"
click node_videoevents "https://github.com/cpuchalver/som-stream/blob/main/app/Events/VideoChanged.php"
click node_videonotify "https://github.com/cpuchalver/som-stream/blob/main/app/Listeners/SendVideoStatusNotificationListener.php"

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_adminui,node_broadcastadmin,node_playlistadmin,node_videoadmin,node_destinationadmin,node_chatadmin toneBlue
class node_uploads,node_uploadrecords,node_videorecords,node_normalizer,node_playlistrecords toneAmber
class node_broadcastrecords,node_destinationrecords,node_engine,node_cycle,node_running,node_ffmpeg toneMint
class node_twitchconnect,node_twitchcallback,node_chataccounts,node_chatbot,node_chatcommands toneRose
class node_events,node_broadcastnotify,node_videoevents,node_videonotify,node_operator,node_streamdest,node_twitch toneIndigo
```

## Components

### Administration

- [Filament Admin](https://github.com/cpuchalver/som-stream/blob/main/app/Providers/Filament/AdminPanelProvider.php): `app/Providers/Filament/AdminPanelProvider.php`
- [Broadcast Admin](https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Broadcasts/BroadcastResource.php): `app/Filament/Resources/Broadcasts/BroadcastResource.php`
- [Playlist Admin](https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Playlists/PlaylistResource.php): `app/Filament/Resources/Playlists/PlaylistResource.php`
- [Video Admin](https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Videos/VideoResource.php): `app/Filament/Resources/Videos/VideoResource.php`
- [Destination Admin](https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/Destinations/DestinationResource.php): `app/Filament/Resources/Destinations/DestinationResource.php`
- [Chat Command Admin](https://github.com/cpuchalver/som-stream/blob/main/app/Filament/Resources/ChatCommands/ChatCommandResource.php): `app/Filament/Resources/ChatCommands/ChatCommandResource.php`

### Media Library

- [Chunked Uploads](https://github.com/cpuchalver/som-stream/blob/main/app/Http/Controllers/VideoUploadsController.php): `app/Http/Controllers/VideoUploadsController.php`
- [Upload Records](https://github.com/cpuchalver/som-stream/blob/main/app/Models/VideoUpload.php): `app/Models/VideoUpload.php`
- [Video Library](https://github.com/cpuchalver/som-stream/blob/main/app/Models/Video.php): `app/Models/Video.php`
- [Video Normalizer](https://github.com/cpuchalver/som-stream/blob/main/app/Jobs/NormalizeVideo.php): `app/Jobs/NormalizeVideo.php`
- [Playlists](https://github.com/cpuchalver/som-stream/blob/main/app/Models/Playlist.php): `app/Models/Playlist.php`

### Broadcast Runtime

- [Broadcast Records](https://github.com/cpuchalver/som-stream/blob/main/app/Models/Broadcast.php): `app/Models/Broadcast.php`
- [Destinations](https://github.com/cpuchalver/som-stream/blob/main/app/Models/Destination.php): `app/Models/Destination.php`
- [Broadcast Engine](https://github.com/cpuchalver/som-stream/blob/main/app/Broadcasting/BroadcastEngine.php): `app/Broadcasting/BroadcastEngine.php`
- [Playlist Cycle](https://github.com/cpuchalver/som-stream/blob/main/app/Broadcasting/CyclePlaylist.php): `app/Broadcasting/CyclePlaylist.php`
- [Running State](https://github.com/cpuchalver/som-stream/blob/main/app/Broadcasting/RunningBroadcast.php): `app/Broadcasting/RunningBroadcast.php`
- [FFmpeg Commands](https://github.com/cpuchalver/som-stream/blob/main/app/Support/Ffmpeg/FfmpegCommands.php): `app/Support/Ffmpeg/FfmpegCommands.php`

### Twitch Chat

- [Twitch OAuth](https://github.com/cpuchalver/som-stream/blob/main/app/Http/Controllers/TwitchConnectionsController.php): `app/Http/Controllers/TwitchConnectionsController.php`
- [Twitch Callback](https://github.com/cpuchalver/som-stream/blob/main/app/Http/Controllers/TwitchConnectionCallbackController.php): `app/Http/Controllers/TwitchConnectionCallbackController.php`
- [Chat Accounts](https://github.com/cpuchalver/som-stream/blob/main/app/Models/ChatAccount.php): `app/Models/ChatAccount.php`
- [Twitch Chat Bot](https://github.com/cpuchalver/som-stream/blob/main/app/Chat/Twitch/TwitchChatBot.php): `app/Chat/Twitch/TwitchChatBot.php`
- [Command Responder](https://github.com/cpuchalver/som-stream/blob/main/app/Chat/ChatCommandResponder.php): `app/Chat/ChatCommandResponder.php`

### Application Services

- [Change Events](https://github.com/cpuchalver/som-stream/blob/main/app/Events/BroadcastChanged.php): `app/Events/BroadcastChanged.php`
- [Broadcast Notifications](https://github.com/cpuchalver/som-stream/blob/main/app/Listeners/SendBroadcastStatusNotificationListener.php): `app/Listeners/SendBroadcastStatusNotificationListener.php`
- [Video Change Event](https://github.com/cpuchalver/som-stream/blob/main/app/Events/VideoChanged.php): `app/Events/VideoChanged.php`
- [Video Notifications](https://github.com/cpuchalver/som-stream/blob/main/app/Listeners/SendVideoStatusNotificationListener.php): `app/Listeners/SendVideoStatusNotificationListener.php`

### Other components

- **Administrator**
- **Streaming Destinations**
- **Twitch Services**

## Connections

- Administrator → Filament Admin: manages
- Filament Admin → Broadcast Admin: offers
- Filament Admin → Playlist Admin: offers
- Filament Admin → Video Admin: offers
- Filament Admin → Destination Admin: offers
- Filament Admin → Chat Command Admin: offers
- Chunked Uploads → Upload Records: creates (evidence: `app/Http/Controllers/VideoUploadsController.php`)
- Chunked Uploads → Video Library: uses storage disk (evidence: `app/Http/Controllers/VideoUploadsController.php`)
- Video Normalizer → Video Library: updates (evidence: `app/Jobs/NormalizeVideo.php`)
- Video Normalizer → FFmpeg Commands: uses (evidence: `app/Jobs/NormalizeVideo.php`)
- Playlist Admin → Playlists: edits
- Video Admin → Video Library: edits
- Broadcast Admin → Broadcast Records: edits
- Destination Admin → Destinations: edits
- Chat Command Admin → Command Responder: manages
- Broadcast Engine → Broadcast Records: queries and updates (evidence: `app/Broadcasting/BroadcastEngine.php`)
- Broadcast Engine → Playlist Cycle: builds cycle (evidence: `app/Broadcasting/BroadcastEngine.php`)
- Broadcast Engine → FFmpeg Commands: starts stream (evidence: `app/Broadcasting/BroadcastEngine.php`)
- Broadcast Engine → Running State: tracks process (evidence: `app/Broadcasting/BroadcastEngine.php`)
- Playlist Cycle → Playlists: reads playlist (evidence: `app/Broadcasting/CyclePlaylist.php`)
- Playlist Cycle → Video Library: selects videos (evidence: `app/Broadcasting/CyclePlaylist.php`)
- Broadcast Engine → Destinations: loads enabled targets (evidence: `app/Broadcasting/BroadcastEngine.php`)
- FFmpeg Commands → Streaming Destinations: streams to
- Twitch OAuth → Twitch Services: redirects for OAuth (evidence: `app/Http/Controllers/TwitchConnectionsController.php`)
- Twitch Callback → Twitch Services: exchanges code (evidence: `app/Http/Controllers/TwitchConnectionCallbackController.php`)
- Twitch Callback → Chat Accounts: saves tokens (evidence: `app/Http/Controllers/TwitchConnectionCallbackController.php`)
- Twitch Chat Bot → Chat Accounts: reads account (evidence: `app/Chat/Twitch/TwitchChatBot.php`)
- Twitch Chat Bot → Command Responder: dispatches commands (evidence: `app/Chat/Twitch/TwitchChatBot.php`)
- Twitch Chat Bot → Twitch Services: connects chat
- Broadcast Records → Change Events: dispatches changes (evidence: `app/Models/Broadcast.php`)
- Change Events → Broadcast Notifications: handles status changes (evidence: `app/Listeners/SendBroadcastStatusNotificationListener.php`)
- Video Library → Video Change Event: dispatches changes (evidence: `app/Models/Video.php`)
- Video Change Event → Video Notifications: handles video changes
