# 14ag/dlna-server architecture

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

- Interactive diagram: https://gitdiagram.com/14ag/dlna-server
- Repository: https://github.com/14ag/dlna-server

## Overview

DLNA Server turns configured folders, playlists, and remote URLs into a persistent media catalog that DLNA players can browse and stream. The user configures sources and starts the server; it scans them, advertises itself on the network, and serves discovery, catalog, and media requests. Catalog updates can trigger notifications to subscribed players. The graph preserves documented playlist/HLS, remote-streaming, access-control, and companion-art/subtitle capabilities. Some subsystem links use README-level evidence because their implementation was not sampled.

Main entry points: [`src/media_sources_common.cpp`](https://github.com/14ag/dlna-server/blob/main/src/media_sources_common.cpp) (Source scanning), [`src/server.cpp`](https://github.com/14ag/dlna-server/blob/main/src/server.cpp) (Server lifecycle), [`src/httpserver.cpp`](https://github.com/14ag/dlna-server/blob/main/src/httpserver.cpp) (HTTP and streaming), [`src/config.h`](https://github.com/14ag/dlna-server/blob/main/src/config.h) (Configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and control"]
  node_config["Configuration<br/>[config.h]"]
  node_gui["Desktop controls<br/>[mainwindow.cpp]"]
  node_settings["Settings dialog<br/>[settingsdlg.cpp]"]
  node_startup["Application startup<br/>[main.cpp]"]
end

subgraph group_catalog["Media catalog"]
  node_scan["Source scanning"]
  node_network_sources["Remote and playlist handling"]
  node_catalog_index["Media catalog<br/>[media_sources.h]"]
  node_stable_ids[("Persistent media IDs<br/>[media_database.cpp]")]
end

subgraph group_serving["DLNA serving"]
  node_content_directory["Content Directory"]
  node_http["HTTP and streaming<br/>[httpserver.cpp]"]
  node_access["Client access rules<br/>[ipwhitelist.cpp]"]
  node_eventing["UPnP eventing<br/>[upnp_eventing.cpp]"]
end

subgraph group_network["Network presence"]
  node_server["Server lifecycle<br/>[server.cpp]"]
  node_ssdp["SSDP discovery<br/>[ssdp.cpp]"]
  node_endpoints["Network endpoints<br/>[netutils.cpp]"]
end

subgraph group_operations["Operations"]
  node_watchers["Change watchers<br/>[source_watcher.cpp]"]
  node_logging["Logging<br/>[log.cpp]"]
end

node_user(("User"))
node_players(("DLNA players"))
node_sources["Media sources"]
node_remote["FTP and web sources"]
node_filesystem["Local files"]

node_user -->|"configures sources"| node_gui
node_gui -->|"opens settings"| node_settings
node_settings -->|"updates settings"| node_config
node_startup -->|"loads configuration"| node_config
node_startup -->|"starts server"| node_server
node_config -->|"supplies sources"| node_scan
node_sources -->|"selects local media"| node_filesystem
node_sources -->|"selects remote media"| node_remote
node_server -->|"starts scans"| node_scan
node_scan -->|"parses remote playlists"| node_network_sources
node_network_sources -->|"fetches and streams"| node_remote
node_scan -->|"publishes media"| node_catalog_index
node_scan -->|"tracks stable IDs"| node_stable_ids
node_server -->|"starts discovery"| node_ssdp
node_ssdp -->|"uses network endpoints"| node_endpoints
node_players -->|"discovers server"| node_ssdp
node_server -->|"starts HTTP service"| node_http
node_players -->|"requests media"| node_http
node_http -->|"routes catalog requests"| node_content_directory
node_content_directory -->|"reads catalog"| node_catalog_index
node_http -->|"fetches HLS manifests"| node_network_sources
node_http -->|"checks client access"| node_access
node_http -->|"handles subscriptions"| node_eventing
node_scan -->|"notifies catalog updates"| node_eventing
node_server -->|"starts change watches"| node_watchers
node_watchers -.->|"triggers rescans"| node_scan
node_server -->|"records lifecycle"| node_logging

click node_config "https://github.com/14ag/dlna-server/blob/main/src/config.h"
click node_gui "https://github.com/14ag/dlna-server/blob/main/src/mainwindow.cpp"
click node_settings "https://github.com/14ag/dlna-server/blob/main/src/settingsdlg.cpp"
click node_startup "https://github.com/14ag/dlna-server/blob/main/src/main.cpp"
click node_server "https://github.com/14ag/dlna-server/blob/main/src/server.cpp"
click node_scan "https://github.com/14ag/dlna-server/blob/main/src/media_sources_common.cpp"
click node_network_sources "https://github.com/14ag/dlna-server/blob/main/src/network_sources.cpp"
click node_catalog_index "https://github.com/14ag/dlna-server/blob/main/src/media_sources.h"
click node_stable_ids "https://github.com/14ag/dlna-server/blob/main/src/media_database.cpp"
click node_content_directory "https://github.com/14ag/dlna-server/blob/main/src/contentdirectory.cpp"
click node_http "https://github.com/14ag/dlna-server/blob/main/src/httpserver.cpp"
click node_access "https://github.com/14ag/dlna-server/blob/main/src/ipwhitelist.cpp"
click node_eventing "https://github.com/14ag/dlna-server/blob/main/src/upnp_eventing.cpp"
click node_ssdp "https://github.com/14ag/dlna-server/blob/main/src/ssdp.cpp"
click node_endpoints "https://github.com/14ag/dlna-server/blob/main/src/netutils.cpp"
click node_watchers "https://github.com/14ag/dlna-server/blob/main/src/source_watcher.cpp"
click node_logging "https://github.com/14ag/dlna-server/blob/main/src/log.cpp"

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_config,node_gui,node_settings,node_startup,node_user toneBlue
class node_scan,node_network_sources,node_catalog_index,node_stable_ids toneAmber
class node_content_directory,node_http,node_access,node_eventing toneMint
class node_server,node_ssdp,node_endpoints toneRose
class node_watchers,node_logging,node_players,node_sources,node_remote,node_filesystem toneIndigo
```

## Components

### Setup and control

- [Configuration](https://github.com/14ag/dlna-server/blob/main/src/config.h): `src/config.h`
- [Desktop controls](https://github.com/14ag/dlna-server/blob/main/src/mainwindow.cpp): `src/mainwindow.cpp`
- [Settings dialog](https://github.com/14ag/dlna-server/blob/main/src/settingsdlg.cpp): `src/settingsdlg.cpp`
- [Application startup](https://github.com/14ag/dlna-server/blob/main/src/main.cpp): `src/main.cpp`

### Media catalog

- [Source scanning](https://github.com/14ag/dlna-server/blob/main/src/media_sources_common.cpp): `src/media_sources_common.cpp`
- [Remote and playlist handling](https://github.com/14ag/dlna-server/blob/main/src/network_sources.cpp): `src/network_sources.cpp`
- [Media catalog](https://github.com/14ag/dlna-server/blob/main/src/media_sources.h): `src/media_sources.h`
- [Persistent media IDs](https://github.com/14ag/dlna-server/blob/main/src/media_database.cpp): `src/media_database.cpp`

### DLNA serving

- [Content Directory](https://github.com/14ag/dlna-server/blob/main/src/contentdirectory.cpp): `src/contentdirectory.cpp`
- [HTTP and streaming](https://github.com/14ag/dlna-server/blob/main/src/httpserver.cpp): `src/httpserver.cpp`
- [Client access rules](https://github.com/14ag/dlna-server/blob/main/src/ipwhitelist.cpp): `src/ipwhitelist.cpp`
- [UPnP eventing](https://github.com/14ag/dlna-server/blob/main/src/upnp_eventing.cpp): `src/upnp_eventing.cpp`

### Network presence

- [Server lifecycle](https://github.com/14ag/dlna-server/blob/main/src/server.cpp): `src/server.cpp`
- [SSDP discovery](https://github.com/14ag/dlna-server/blob/main/src/ssdp.cpp): `src/ssdp.cpp`
- [Network endpoints](https://github.com/14ag/dlna-server/blob/main/src/netutils.cpp): `src/netutils.cpp`

### Operations

- [Change watchers](https://github.com/14ag/dlna-server/blob/main/src/source_watcher.cpp): `src/source_watcher.cpp`
- [Logging](https://github.com/14ag/dlna-server/blob/main/src/log.cpp): `src/log.cpp`

### Other components

- **User**
- **DLNA players**
- **Media sources**
- **FTP and web sources**
- **Local files**

## Connections

- User → Desktop controls: configures sources (evidence: `README.md`)
- Desktop controls → Settings dialog: opens settings (evidence: `src/mainwindow.cpp`)
- Settings dialog → Configuration: updates settings (evidence: `src/settingsdlg.cpp`)
- Application startup → Configuration: loads configuration (evidence: `src/main.cpp`)
- Application startup → Server lifecycle: starts server (evidence: `src/main.cpp`)
- Configuration → Source scanning: supplies sources (evidence: `src/media_sources_common.cpp`)
- Media sources → Local files: selects local media (evidence: `README.md`)
- Media sources → FTP and web sources: selects remote media (evidence: `README.md`)
- Server lifecycle → Source scanning: starts scans (evidence: `src/server.cpp`)
- Source scanning → Remote and playlist handling: parses remote playlists (evidence: `src/media_sources_common.cpp`)
- Remote and playlist handling → FTP and web sources: fetches and streams (evidence: `README.md`)
- Source scanning → Media catalog: publishes media (evidence: `src/media_sources_common.cpp`)
- Source scanning → Persistent media IDs: tracks stable IDs (evidence: `src/media_sources_common.cpp`)
- Server lifecycle → SSDP discovery: starts discovery (evidence: `src/server.cpp`)
- SSDP discovery → Network endpoints: uses network endpoints (evidence: `src/ssdp.cpp`)
- DLNA players → SSDP discovery: discovers server (evidence: `README.md`)
- Server lifecycle → HTTP and streaming: starts HTTP service (evidence: `src/server.cpp`)
- DLNA players → HTTP and streaming: requests media (evidence: `README.md`)
- HTTP and streaming → Content Directory: routes catalog requests (evidence: `src/httpserver.cpp`)
- Content Directory → Media catalog: reads catalog (evidence: `src/contentdirectory.cpp`)
- HTTP and streaming → Remote and playlist handling: fetches HLS manifests (evidence: `src/httpserver.cpp`)
- HTTP and streaming → Client access rules: checks client access (evidence: `src/httpserver.cpp`)
- HTTP and streaming → UPnP eventing: handles subscriptions (evidence: `src/httpserver.cpp`)
- Source scanning → UPnP eventing: notifies catalog updates (evidence: `src/media_sources_common.cpp`)
- Server lifecycle → Change watchers: starts change watches (evidence: `src/server.cpp`)
- Change watchers → Source scanning: triggers rescans
- Server lifecycle → Logging: records lifecycle (evidence: `src/server.cpp`)
