# devine-dl/devine architecture

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

- Interactive diagram: https://gitdiagram.com/devine-dl/devine
- Repository: https://github.com/devine-dl/devine

## Overview

Devine is a modular media-archival CLI and framework: users invoke download or search commands, service plugins resolve titles and tracks, and the download workflow fetches, decrypts, processes, and names media output. The README also documents DASH/HLS parsing, Widevine and ClearKey, proxy providers, key vaults, remote CDMs, and serving. Edges are limited to relationships visible in excerpts, SOURCE INDEX references, or README statements; unsampled implementations are represented by their exact tree paths without asserting internal call sequences.

Main entry points: [`devine/commands/dl.py`](https://github.com/devine-dl/devine/blob/master/devine/commands/dl.py) (Download workflow), [`devine/core/service.py`](https://github.com/devine-dl/devine/blob/master/devine/core/service.py) (Service framework), [`devine/commands`](https://github.com/devine-dl/devine/tree/master/devine/commands) (Command entrypoints), [`devine/core/tracks`](https://github.com/devine-dl/devine/tree/master/devine/core/tracks) (Track processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and configuration"]
  node_commands["Command entrypoints"]
  node_download["Download workflow<br/>[dl.py]"]
  node_search["Search command<br/>[search.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_service["Services and discovery"]
  node_services["Service registry<br/>[services.py]"]
  node_servicebase["Service framework<br/>[service.py]"]
  node_titles["Title models"]
end

subgraph group_media["Media acquisition"]
  node_manifests["DASH and HLS"]
  node_tracks["Track processing"]
  node_downloaders["HTTP downloaders"]
  node_binaries["Media utilities<br/>[binaries.py]"]
  node_output["Archived media"]
end

subgraph group_security["DRM and vaults"]
  node_drm["DRM handlers"]
  node_vaults["Vault adapters"]
  node_vaultmanager["Vault registry<br/>[vaults.py]"]
end

subgraph group_support["Runtime integrations"]
  node_proxies["Proxy providers"]
  node_serve["Remote serving<br/>[serve.py]"]
  node_events["Event hooks<br/>[events.py]"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_commands
node_commands -->|"routes downloads"| node_download
node_commands -->|"routes searches"| node_search
node_download -->|"reads settings"| node_config
node_download -->|"selects service"| node_services
node_search -->|"selects service"| node_services
node_services -->|"loads plugins"| node_servicebase
node_servicebase -->|"reads settings"| node_config
node_servicebase -->|"returns title models"| node_titles
node_download -->|"gets tracks"| node_servicebase
node_download -->|"assembles tracks"| node_tracks
node_manifests -->|"fetches manifests"| node_downloaders
node_manifests -->|"creates tracks"| node_tracks
node_tracks -->|"downloads media"| node_downloaders
node_tracks -->|"uses DRM handlers"| node_drm
node_download -->|"uses media tools"| node_binaries
node_download -->|"writes archive"| node_output
node_download -->|"handles protected media"| node_drm
node_drm -.->|"uses key vaults"| node_vaultmanager
node_vaultmanager -->|"loads adapters"| node_vaults
node_vaults -->|"uses HTTP client"| node_downloaders
node_servicebase -->|"supports proxies"| node_proxies
node_commands -->|"offers serving"| node_serve
node_download -->|"emits events"| node_events

click node_commands "https://github.com/devine-dl/devine/tree/master/devine/commands"
click node_download "https://github.com/devine-dl/devine/blob/master/devine/commands/dl.py"
click node_search "https://github.com/devine-dl/devine/blob/master/devine/commands/search.py"
click node_config "https://github.com/devine-dl/devine/blob/master/devine/core/config.py"
click node_services "https://github.com/devine-dl/devine/blob/master/devine/core/services.py"
click node_servicebase "https://github.com/devine-dl/devine/blob/master/devine/core/service.py"
click node_titles "https://github.com/devine-dl/devine/tree/master/devine/core/titles"
click node_manifests "https://github.com/devine-dl/devine/tree/master/devine/core/manifests"
click node_tracks "https://github.com/devine-dl/devine/tree/master/devine/core/tracks"
click node_downloaders "https://github.com/devine-dl/devine/tree/master/devine/core/downloaders"
click node_binaries "https://github.com/devine-dl/devine/blob/master/devine/core/binaries.py"
click node_drm "https://github.com/devine-dl/devine/tree/master/devine/core/drm"
click node_vaults "https://github.com/devine-dl/devine/tree/master/devine/vaults"
click node_vaultmanager "https://github.com/devine-dl/devine/blob/master/devine/core/vaults.py"
click node_proxies "https://github.com/devine-dl/devine/tree/master/devine/core/proxies"
click node_serve "https://github.com/devine-dl/devine/blob/master/devine/commands/serve.py"
click node_events "https://github.com/devine-dl/devine/blob/master/devine/core/events.py"

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_commands,node_download,node_search,node_config,node_user toneBlue
class node_services,node_servicebase,node_titles toneAmber
class node_manifests,node_tracks,node_downloaders,node_binaries,node_output toneMint
class node_drm,node_vaults,node_vaultmanager toneRose
class node_proxies,node_serve,node_events toneIndigo
```

## Components

### CLI and configuration

- [Command entrypoints](https://github.com/devine-dl/devine/tree/master/devine/commands): `devine/commands`
- [Download workflow](https://github.com/devine-dl/devine/blob/master/devine/commands/dl.py): `devine/commands/dl.py`
- [Search command](https://github.com/devine-dl/devine/blob/master/devine/commands/search.py): `devine/commands/search.py`
- [Configuration](https://github.com/devine-dl/devine/blob/master/devine/core/config.py): `devine/core/config.py`

### Services and discovery

- [Service registry](https://github.com/devine-dl/devine/blob/master/devine/core/services.py): `devine/core/services.py`
- [Service framework](https://github.com/devine-dl/devine/blob/master/devine/core/service.py): `devine/core/service.py`
- [Title models](https://github.com/devine-dl/devine/tree/master/devine/core/titles): `devine/core/titles`

### Media acquisition

- [DASH and HLS](https://github.com/devine-dl/devine/tree/master/devine/core/manifests): `devine/core/manifests`
- [Track processing](https://github.com/devine-dl/devine/tree/master/devine/core/tracks): `devine/core/tracks`
- [HTTP downloaders](https://github.com/devine-dl/devine/tree/master/devine/core/downloaders): `devine/core/downloaders`
- [Media utilities](https://github.com/devine-dl/devine/blob/master/devine/core/binaries.py): `devine/core/binaries.py`
- **Archived media**

### DRM and vaults

- [DRM handlers](https://github.com/devine-dl/devine/tree/master/devine/core/drm): `devine/core/drm`
- [Vault adapters](https://github.com/devine-dl/devine/tree/master/devine/vaults): `devine/vaults`
- [Vault registry](https://github.com/devine-dl/devine/blob/master/devine/core/vaults.py): `devine/core/vaults.py`

### Runtime integrations

- [Proxy providers](https://github.com/devine-dl/devine/tree/master/devine/core/proxies): `devine/core/proxies`
- [Remote serving](https://github.com/devine-dl/devine/blob/master/devine/commands/serve.py): `devine/commands/serve.py`
- [Event hooks](https://github.com/devine-dl/devine/blob/master/devine/core/events.py): `devine/core/events.py`

### Other components

- **CLI user**

## Connections

- CLI user → Command entrypoints: invokes (evidence: `README.md`)
- Command entrypoints → Download workflow: routes downloads (evidence: `devine/commands/dl.py`)
- Command entrypoints → Search command: routes searches (evidence: `devine/commands/search.py`)
- Download workflow → Configuration: reads settings (evidence: `devine/commands/dl.py`)
- Download workflow → Service registry: selects service (evidence: `devine/commands/dl.py`)
- Search command → Service registry: selects service (evidence: `devine/commands/search.py`)
- Service registry → Service framework: loads plugins (evidence: `devine/core/services.py`)
- Service framework → Configuration: reads settings (evidence: `devine/core/service.py`)
- Service framework → Title models: returns title models (evidence: `devine/core/service.py`)
- Download workflow → Service framework: gets tracks (evidence: `devine/commands/dl.py`)
- Download workflow → Track processing: assembles tracks (evidence: `devine/commands/dl.py`)
- DASH and HLS → HTTP downloaders: fetches manifests (evidence: `devine/core/manifests/dash.py`)
- DASH and HLS → Track processing: creates tracks (evidence: `devine/core/manifests/dash.py`)
- Track processing → HTTP downloaders: downloads media (evidence: `devine/core/tracks/track.py`)
- Track processing → DRM handlers: uses DRM handlers (evidence: `devine/core/tracks/track.py`)
- Download workflow → Media utilities: uses media tools (evidence: `devine/commands/dl.py`)
- Download workflow → Archived media: writes archive (evidence: `devine/commands/dl.py`)
- Download workflow → DRM handlers: handles protected media (evidence: `devine/commands/dl.py`)
- DRM handlers → Vault registry: uses key vaults
- Vault registry → Vault adapters: loads adapters (evidence: `devine/core/vaults.py`)
- Vault adapters → HTTP downloaders: uses HTTP client (evidence: `devine/vaults/API.py`)
- Service framework → Proxy providers: supports proxies (evidence: `devine/core/service.py`)
- Command entrypoints → Remote serving: offers serving (evidence: `README.md`)
- Download workflow → Event hooks: emits events (evidence: `devine/commands/dl.py`)
