# alexballas/go2tv architecture

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

- Interactive diagram: https://gitdiagram.com/alexballas/go2tv
- Repository: https://github.com/alexballas/go2tv

## Overview

Go2TV casts local or remote media to DLNA/UPnP and Chromecast receivers. The main workflow is to choose media and a discovered device, prepare a stream (including optional transcoding or subtitles), then control playback. The GUI, CLI, and server-mode Web UI are distinct entry points; playback adapters bridge shared orchestration to device protocols. The README documents additional playlist, seek, RTMP, and desktop-casting capabilities. Connections reflect excerpts and documented behavior; unsampled implementation details are not inferred.

Main entry points: [`internal/webui/handler.go`](https://github.com/alexballas/go2tv/blob/main/internal/webui/handler.go) (Web UI API), [`internal/playbackadapter/adapters.go`](https://github.com/alexballas/go2tv/blob/main/internal/playbackadapter/adapters.go) (Playback adapters), [`internal/gui/main.go`](https://github.com/alexballas/go2tv/blob/main/internal/gui/main.go) (Desktop GUI), [`cmd/go2tv/go2tv.go`](https://github.com/alexballas/go2tv/blob/main/cmd/go2tv/go2tv.go) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_gui["Desktop GUI<br/>[main.go]"]
  node_cli["CLI<br/>[go2tv.go]"]
  node_lite["Lite CLI<br/>[go2tv.go]"]
  node_webclient["Web UI client<br/>[client.js]"]
end

subgraph group_media["Media preparation"]
  node_library["Media library<br/>[library.go]"]
  node_httpmedia["Media HTTP server<br/>[server.go]"]
  node_httphandlers["CLI media server<br/>[httphandlers.go]"]
  node_artwork["Artwork resolution<br/>[mediaartwork.go]"]
  node_transcode["Transcoding tools<br/>[transcode.go]"]
  node_rtmp["RTMP streaming<br/>[server.go]"]
end

subgraph group_playback["Playback control"]
  node_controller["Playback controller<br/>[controller.go]"]
  node_queue["Playlists<br/>[playlists.go]"]
end

subgraph group_devices["Device protocols"]
  node_discovery["Device discovery<br/>[devices.go]"]
  node_adapter["Playback adapters<br/>[adapters.go]"]
  node_castclient["Cast client<br/>[client.go]"]
  node_castapp["Cast application<br/>[application.go]"]
  node_soap["DLNA control<br/>[soapcallers.go]"]
end

subgraph group_remote["Remote services"]
  node_webhandler["Web UI API<br/>[handler.go]"]
  node_remote["Remote session"]
end

node_user(("User"))
node_browser(("Browser"))
node_receiver(("TV or Chromecast"))

node_user -->|"selects and plays"| node_gui
node_user -->|"invokes playback"| node_cli
node_user -->|"invokes playback"| node_lite
node_user -->|"requests discovery"| node_discovery
node_gui -->|"shows devices"| node_discovery
node_cli -->|"lists devices"| node_discovery
node_lite -->|"lists devices"| node_discovery
node_cli -->|"serves media"| node_httphandlers
node_lite -->|"serves media"| node_httphandlers
node_gui -.->|"controls playback"| node_controller
node_cli -.->|"controls device"| node_adapter
node_lite -.->|"controls device"| node_adapter
node_browser -->|"controls casting"| node_webclient
node_webclient -->|"sends commands"| node_webhandler
node_webhandler -->|"browses media"| node_library
node_webhandler -->|"executes commands"| node_controller
node_webhandler -->|"resolves artwork"| node_artwork
node_gui -->|"starts session"| node_remote
node_remote -.->|"configures server"| node_webhandler
node_controller -->|"routes media"| node_httpmedia
node_controller -.->|"dispatches playback"| node_adapter
node_adapter -->|"creates client"| node_castclient
node_castclient -->|"starts receiver"| node_castapp
node_adapter -->|"opens DLNA transport"| node_soap
node_httpmedia -->|"streams media"| node_receiver
node_soap -->|"controls playback"| node_receiver
node_castclient -->|"controls casting"| node_receiver
node_user -->|"manages playlist"| node_queue
node_user -->|"enables transcoding"| node_transcode
node_user -->|"starts live stream"| node_rtmp
node_user -.->|"views artwork"| node_artwork
node_user -.->|"casts desktop"| node_httpmedia

click node_gui "https://github.com/alexballas/go2tv/blob/main/internal/gui/main.go"
click node_cli "https://github.com/alexballas/go2tv/blob/main/cmd/go2tv/go2tv.go"
click node_lite "https://github.com/alexballas/go2tv/blob/main/cmd/go2tv-lite/go2tv.go"
click node_webclient "https://github.com/alexballas/go2tv/blob/main/internal/webui/src/client.js"
click node_webhandler "https://github.com/alexballas/go2tv/blob/main/internal/webui/handler.go"
click node_discovery "https://github.com/alexballas/go2tv/blob/main/devices/devices.go"
click node_library "https://github.com/alexballas/go2tv/blob/main/internal/library/library.go"
click node_controller "https://github.com/alexballas/go2tv/blob/main/internal/controller/controller.go"
click node_queue "https://github.com/alexballas/go2tv/blob/main/castprotocol/v2/playlists/playlists.go"
click node_adapter "https://github.com/alexballas/go2tv/blob/main/internal/playbackadapter/adapters.go"
click node_castclient "https://github.com/alexballas/go2tv/blob/main/castprotocol/client.go"
click node_castapp "https://github.com/alexballas/go2tv/blob/main/castprotocol/v2/application/application.go"
click node_soap "https://github.com/alexballas/go2tv/blob/main/soapcalls/soapcallers.go"
click node_httpmedia "https://github.com/alexballas/go2tv/blob/main/internal/mediaserver/server.go"
click node_httphandlers "https://github.com/alexballas/go2tv/blob/main/httphandlers/httphandlers.go"
click node_artwork "https://github.com/alexballas/go2tv/blob/main/internal/mediaartwork/mediaartwork.go"
click node_transcode "https://github.com/alexballas/go2tv/blob/main/utils/transcode.go"
click node_rtmp "https://github.com/alexballas/go2tv/blob/main/rtmp/server.go"
click node_remote "https://github.com/alexballas/go2tv/blob/main/internal/gui/remote_web_session.go"

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_gui,node_cli,node_lite,node_webclient,node_user,node_browser toneBlue
class node_library,node_httpmedia,node_httphandlers,node_artwork,node_transcode,node_rtmp toneAmber
class node_controller,node_queue toneMint
class node_discovery,node_adapter,node_castclient,node_castapp,node_soap toneRose
class node_webhandler,node_remote,node_receiver toneIndigo
```

## Components

### User interfaces

- [Desktop GUI](https://github.com/alexballas/go2tv/blob/main/internal/gui/main.go): `internal/gui/main.go`
- [CLI](https://github.com/alexballas/go2tv/blob/main/cmd/go2tv/go2tv.go): `cmd/go2tv/go2tv.go`
- [Lite CLI](https://github.com/alexballas/go2tv/blob/main/cmd/go2tv-lite/go2tv.go): `cmd/go2tv-lite/go2tv.go`
- [Web UI client](https://github.com/alexballas/go2tv/blob/main/internal/webui/src/client.js): `internal/webui/src/client.js`

### Media preparation

- [Media library](https://github.com/alexballas/go2tv/blob/main/internal/library/library.go): `internal/library/library.go`
- [Media HTTP server](https://github.com/alexballas/go2tv/blob/main/internal/mediaserver/server.go): `internal/mediaserver/server.go`
- [CLI media server](https://github.com/alexballas/go2tv/blob/main/httphandlers/httphandlers.go): `httphandlers/httphandlers.go`
- [Artwork resolution](https://github.com/alexballas/go2tv/blob/main/internal/mediaartwork/mediaartwork.go): `internal/mediaartwork/mediaartwork.go`
- [Transcoding tools](https://github.com/alexballas/go2tv/blob/main/utils/transcode.go): `utils/transcode.go`
- [RTMP streaming](https://github.com/alexballas/go2tv/blob/main/rtmp/server.go): `rtmp/server.go`

### Playback control

- [Playback controller](https://github.com/alexballas/go2tv/blob/main/internal/controller/controller.go): `internal/controller/controller.go`
- [Playlists](https://github.com/alexballas/go2tv/blob/main/castprotocol/v2/playlists/playlists.go): `castprotocol/v2/playlists/playlists.go`

### Device protocols

- [Device discovery](https://github.com/alexballas/go2tv/blob/main/devices/devices.go): `devices/devices.go`
- [Playback adapters](https://github.com/alexballas/go2tv/blob/main/internal/playbackadapter/adapters.go): `internal/playbackadapter/adapters.go`
- [Cast client](https://github.com/alexballas/go2tv/blob/main/castprotocol/client.go): `castprotocol/client.go`
- [Cast application](https://github.com/alexballas/go2tv/blob/main/castprotocol/v2/application/application.go): `castprotocol/v2/application/application.go`
- [DLNA control](https://github.com/alexballas/go2tv/blob/main/soapcalls/soapcallers.go): `soapcalls/soapcallers.go`

### Remote services

- [Web UI API](https://github.com/alexballas/go2tv/blob/main/internal/webui/handler.go): `internal/webui/handler.go`
- [Remote session](https://github.com/alexballas/go2tv/blob/main/internal/gui/remote_web_session.go): `internal/gui/remote_web_session.go`

### Other components

- **User**
- **Browser**
- **TV or Chromecast**

## Connections

- User → Desktop GUI: selects and plays
- User → CLI: invokes playback
- User → Lite CLI: invokes playback
- User → Device discovery: requests discovery
- Desktop GUI → Device discovery: shows devices (evidence: `internal/gui/main.go`)
- CLI → Device discovery: lists devices (evidence: `cmd/go2tv/go2tv.go`)
- Lite CLI → Device discovery: lists devices (evidence: `cmd/go2tv-lite/go2tv.go`)
- CLI → CLI media server: serves media (evidence: `cmd/go2tv/go2tv.go`)
- Lite CLI → CLI media server: serves media (evidence: `cmd/go2tv-lite/go2tv.go`)
- Desktop GUI → Playback controller: controls playback
- CLI → Playback adapters: controls device
- Lite CLI → Playback adapters: controls device
- Browser → Web UI client: controls casting
- Web UI client → Web UI API: sends commands
- Web UI API → Media library: browses media (evidence: `internal/webui/handler.go`)
- Web UI API → Playback controller: executes commands (evidence: `internal/webui/handler.go`)
- Web UI API → Artwork resolution: resolves artwork (evidence: `internal/webui/handler.go`)
- Desktop GUI → Remote session: starts session (evidence: `internal/gui/remote_web_session.go`)
- Remote session → Web UI API: configures server
- Playback controller → Media HTTP server: routes media (evidence: `internal/controller/controller.go`)
- Playback controller → Playback adapters: dispatches playback
- Playback adapters → Cast client: creates client (evidence: `internal/playbackadapter/adapters.go`)
- Cast client → Cast application: starts receiver (evidence: `castprotocol/client.go`)
- Playback adapters → DLNA control: opens DLNA transport (evidence: `internal/playbackadapter/adapters.go`)
- Media HTTP server → TV or Chromecast: streams media
- DLNA control → TV or Chromecast: controls playback
- Cast client → TV or Chromecast: controls casting
- User → Playlists: manages playlist
- User → Transcoding tools: enables transcoding
- User → RTMP streaming: starts live stream
- User → Artwork resolution: views artwork
- User → Media HTTP server: casts desktop
