# spotdl/spotify-downloader architecture

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

- Interactive diagram: https://gitdiagram.com/spotdl/spotify-downloader
- Repository: https://github.com/spotdl/spotify-downloader

## Overview

spotDL turns Spotify track, album, playlist, or search queries into song metadata, finds matching audio on YouTube-oriented providers, downloads and converts it, then embeds metadata and optionally lyrics. Its CLI also supports metadata-only save, playlist sync, URL lookup, metadata updates, and a limited single-song web interface. The graph reflects documented capabilities and indexed module references; several provider and command implementations were not excerpted, so their detailed runtime wiring is left out.

Main entry points: [`spotdl/download/downloader.py`](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/download/downloader.py) (Download orchestration), [`spotdl/utils/search.py`](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/search.py) (Query resolution), [`spotdl/console/entry_point.py`](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/entry_point.py) (CLI dispatch), [`spotdl/console/sync.py`](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/sync.py) (Playlist sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["User interfaces"]
  node_commands["CLI dispatch<br/>[entry_point.py]"]
  node_download_cmd["Download command<br/>[download.py]"]
  node_save["Save metadata<br/>[save.py]"]
  node_sync["Playlist sync<br/>[sync.py]"]
  node_meta["Metadata update<br/>[meta.py]"]
  node_url["URL lookup<br/>[url.py]"]
end

subgraph group_catalog["Music catalog"]
  node_search["Query resolution<br/>[search.py]"]
  node_spotify["Spotify client<br/>[spotify.py]"]
  node_song["Song metadata<br/>[song.py]"]
  node_catalog_types["Album and playlists<br/>[album.py]"]
end

subgraph group_media["Audio and metadata"]
  node_downloader["Download orchestration<br/>[downloader.py]"]
  node_audio["Audio providers<br/>[base.py]"]
  node_lyrics["Lyrics providers<br/>[base.py]"]
  node_ffmpeg["Audio conversion<br/>[ffmpeg.py]"]
  node_metadata["Tag and artwork<br/>[metadata.py]"]
  node_formatter["Filename formatting<br/>[formatter.py]"]
end

subgraph group_web["Web interface"]
  node_web_cmd["Web command<br/>[web.py]"]
  node_web_server["Web server utilities<br/>[web.py]"]
  node_web_api["Web API<br/>[api.py]"]
  node_web_routes["Web routes<br/>[routes.py]"]
end

subgraph group_support["Runtime support"]
  node_config["Settings and config<br/>[config.py]"]
  node_options["Option types<br/>[options.py]"]
end

node_user(("User"))
node_spotify_service(("Spotify"))
node_audio_sources(("Audio sources"))
node_files[("Local music files")]

node_user -->|"runs operation"| node_commands
node_commands -->|"dispatches download"| node_download_cmd
node_commands -->|"dispatches save"| node_save
node_commands -->|"dispatches sync"| node_sync
node_commands -->|"dispatches meta"| node_meta
node_commands -->|"dispatches URL"| node_url
node_download_cmd -->|"starts download"| node_downloader
node_save -->|"resolves query"| node_search
node_sync -->|"resolves playlist"| node_search
node_meta -->|"resolves songs"| node_search
node_url -.->|"resolves query"| node_search
node_search -->|"queries catalog"| node_spotify
node_spotify -->|"requests catalog data"| node_spotify_service
node_search -->|"creates songs"| node_song
node_search -->|"creates collections"| node_catalog_types
node_save -->|"saves metadata"| node_song
node_sync -->|"downloads additions"| node_downloader
node_meta -->|"updates tags"| node_metadata
node_downloader -->|"fetches audio"| node_audio
node_audio -.->|"searches and downloads"| node_audio_sources
node_downloader -->|"fetches lyrics"| node_lyrics
node_downloader -->|"converts audio"| node_ffmpeg
node_downloader -->|"embeds metadata"| node_metadata
node_downloader -->|"formats output paths"| node_formatter
node_downloader -->|"writes downloads"| node_files
node_sync -.->|"compares directory"| node_files
node_commands -->|"loads settings"| node_config
node_config -->|"builds typed settings"| node_options
node_user -->|"starts web mode"| node_web_cmd
node_web_cmd -->|"starts interface"| node_web_server
node_web_cmd -->|"uses API"| node_web_api
node_web_cmd -->|"registers routes"| node_web_routes
node_web_routes -->|"downloads song"| node_downloader
node_web_routes -->|"parses song URL"| node_song
node_web_api -->|"resolves queries"| node_search
node_web_routes -.->|"serves interface"| node_user

click node_commands "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/entry_point.py"
click node_download_cmd "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/download.py"
click node_save "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/save.py"
click node_sync "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/sync.py"
click node_meta "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/meta.py"
click node_url "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/url.py"
click node_search "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/search.py"
click node_spotify "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/spotify.py"
click node_song "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/types/song.py"
click node_catalog_types "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/types/album.py"
click node_downloader "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/download/downloader.py"
click node_audio "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/providers/audio/base.py"
click node_lyrics "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/providers/lyrics/base.py"
click node_ffmpeg "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/ffmpeg.py"
click node_metadata "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/metadata.py"
click node_formatter "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/formatter.py"
click node_config "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/config.py"
click node_options "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/types/options.py"
click node_web_cmd "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/web.py"
click node_web_server "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/web.py"
click node_web_api "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/web/api.py"
click node_web_routes "https://github.com/spotdl/spotify-downloader/blob/master/spotdl/web/routes.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_cmd,node_save,node_sync,node_meta,node_url,node_user toneBlue
class node_search,node_spotify,node_song,node_catalog_types,node_files toneAmber
class node_downloader,node_audio,node_lyrics,node_ffmpeg,node_metadata,node_formatter toneMint
class node_web_cmd,node_web_server,node_web_api,node_web_routes toneRose
class node_config,node_options,node_spotify_service,node_audio_sources toneIndigo
```

## Components

### User interfaces

- [CLI dispatch](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/entry_point.py): `spotdl/console/entry_point.py`
- [Download command](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/download.py): `spotdl/console/download.py`
- [Save metadata](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/save.py): `spotdl/console/save.py`
- [Playlist sync](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/sync.py): `spotdl/console/sync.py`
- [Metadata update](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/meta.py): `spotdl/console/meta.py`
- [URL lookup](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/url.py): `spotdl/console/url.py`

### Music catalog

- [Query resolution](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/search.py): `spotdl/utils/search.py`
- [Spotify client](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/spotify.py): `spotdl/utils/spotify.py`
- [Song metadata](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/types/song.py): `spotdl/types/song.py`
- [Album and playlists](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/types/album.py): `spotdl/types/album.py`

### Audio and metadata

- [Download orchestration](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/download/downloader.py): `spotdl/download/downloader.py`
- [Audio providers](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/providers/audio/base.py): `spotdl/providers/audio/base.py`
- [Lyrics providers](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/providers/lyrics/base.py): `spotdl/providers/lyrics/base.py`
- [Audio conversion](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/ffmpeg.py): `spotdl/utils/ffmpeg.py`
- [Tag and artwork](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/metadata.py): `spotdl/utils/metadata.py`
- [Filename formatting](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/formatter.py): `spotdl/utils/formatter.py`

### Web interface

- [Web command](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/console/web.py): `spotdl/console/web.py`
- [Web server utilities](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/web.py): `spotdl/utils/web.py`
- [Web API](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/web/api.py): `spotdl/web/api.py`
- [Web routes](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/web/routes.py): `spotdl/web/routes.py`

### Runtime support

- [Settings and config](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/utils/config.py): `spotdl/utils/config.py`
- [Option types](https://github.com/spotdl/spotify-downloader/blob/master/spotdl/types/options.py): `spotdl/types/options.py`

### Other components

- **User**
- **Spotify**
- **Audio sources**
- **Local music files**

## Connections

- User → CLI dispatch: runs operation (evidence: `README.md`)
- CLI dispatch → Download command: dispatches download (evidence: `spotdl/console/entry_point.py`)
- CLI dispatch → Save metadata: dispatches save (evidence: `spotdl/console/entry_point.py`)
- CLI dispatch → Playlist sync: dispatches sync (evidence: `spotdl/console/entry_point.py`)
- CLI dispatch → Metadata update: dispatches meta (evidence: `spotdl/console/entry_point.py`)
- CLI dispatch → URL lookup: dispatches URL (evidence: `spotdl/console/entry_point.py`)
- Download command → Download orchestration: starts download (evidence: `spotdl/console/entry_point.py`)
- Save metadata → Query resolution: resolves query (evidence: `spotdl/console/save.py`)
- Playlist sync → Query resolution: resolves playlist (evidence: `spotdl/console/sync.py`)
- Metadata update → Query resolution: resolves songs (evidence: `spotdl/console/meta.py`)
- URL lookup → Query resolution: resolves query
- Query resolution → Spotify client: queries catalog (evidence: `spotdl/utils/search.py`)
- Spotify client → Spotify: requests catalog data (evidence: `spotdl/utils/spotify.py`)
- Query resolution → Song metadata: creates songs (evidence: `spotdl/utils/search.py`)
- Query resolution → Album and playlists: creates collections (evidence: `spotdl/utils/search.py`)
- Save metadata → Song metadata: saves metadata (evidence: `spotdl/console/save.py`)
- Playlist sync → Download orchestration: downloads additions (evidence: `spotdl/console/sync.py`)
- Metadata update → Tag and artwork: updates tags (evidence: `spotdl/console/meta.py`)
- Download orchestration → Audio providers: fetches audio (evidence: `spotdl/download/downloader.py`)
- Audio providers → Audio sources: searches and downloads
- Download orchestration → Lyrics providers: fetches lyrics (evidence: `spotdl/download/downloader.py`)
- Download orchestration → Audio conversion: converts audio (evidence: `spotdl/download/downloader.py`)
- Download orchestration → Tag and artwork: embeds metadata (evidence: `spotdl/download/downloader.py`)
- Download orchestration → Filename formatting: formats output paths (evidence: `spotdl/download/downloader.py`)
- Download orchestration → Local music files: writes downloads (evidence: `spotdl/download/downloader.py`)
- Playlist sync → Local music files: compares directory
- CLI dispatch → Settings and config: loads settings (evidence: `spotdl/console/entry_point.py`)
- Settings and config → Option types: builds typed settings (evidence: `spotdl/utils/config.py`)
- User → Web command: starts web mode (evidence: `README.md`)
- Web command → Web server utilities: starts interface (evidence: `spotdl/console/web.py`)
- Web command → Web API: uses API (evidence: `spotdl/console/web.py`)
- Web command → Web routes: registers routes (evidence: `spotdl/console/web.py`)
- Web routes → Download orchestration: downloads song (evidence: `spotdl/web/routes.py`)
- Web routes → Song metadata: parses song URL (evidence: `spotdl/web/routes.py`)
- Web API → Query resolution: resolves queries (evidence: `spotdl/web/api.py`)
- Web routes → User: serves interface
