# rigellute/spotify-tui architecture

> Architecture diagram of the GitHub repository rigellute/spotify-tui, 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/rigellute/spotify-tui
- Repository: https://github.com/rigellute/spotify-tui

## Overview

Spotify TUI is a terminal client for browsing Spotify’s catalog and library, searching, and controlling playback. Its main interactive workflow is terminal input through routed handlers into application state and network actions, followed by UI rendering; a separate CLI supports search, listing, playback, and formatting. Authentication and user configuration prepare both modes. Several handler and CLI relationships are documented only at module level in the source index, so the graph omits uncertain internal calls rather than inferring a detailed pipeline.

Main entry points: [`src/main.rs`](https://github.com/rigellute/spotify-tui/blob/master/src/main.rs) (Program entry), [`src/handlers`](https://github.com/rigellute/spotify-tui/tree/master/src/handlers) (View handlers), [`src/network.rs`](https://github.com/rigellute/spotify-tui/blob/master/src/network.rs) (Network event dispatch), [`src/ui/mod.rs`](https://github.com/rigellute/spotify-tui/blob/master/src/ui/mod.rs) (Terminal rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_main["Program entry<br/>[main.rs]"]
  node_app["App state<br/>[app.rs]"]
  node_events["Input events<br/>[events.rs]"]
end

subgraph group_views["Terminal views"]
  node_handlers["View handlers"]
  node_search["Search results<br/>[search_results.rs]"]
  node_track["Track and album views<br/>[track_table.rs]"]
  node_artist["Artist views<br/>[artist.rs]"]
  node_library["Library views<br/>[library.rs]"]
  node_podcasts["Podcast views<br/>[episode_table.rs]"]
  node_recommendations["Recommendations<br/>[made_for_you.rs]"]
  node_render["Terminal rendering<br/>[mod.rs]"]
  node_analysis_view["Audio analysis view<br/>[audio_analysis.rs]"]
  node_help_view["Help view<br/>[help.rs]"]
end

subgraph group_spotify["Spotify access"]
  node_network["Network event dispatch<br/>[network.rs]"]
  node_spotify_api(("Spotify API"))
end

subgraph group_cli["Command line"]
  node_cli_args["CLI arguments<br/>[clap.rs]"]
  node_cli_app["CLI operations<br/>[cli_app.rs]"]
  node_cli_format["CLI formatting<br/>[util.rs]"]
end

subgraph group_setup["Authentication and settings"]
  node_client_config["Client configuration<br/>[config.rs]"]
  node_user_config[("User preferences<br/>[user_config.rs]")]
  node_redirect["OAuth redirect<br/>[redirect_uri.rs]"]
  node_oauth(("Spotify OAuth"))
end

node_user(("Terminal user"))

node_user -->|"starts"| node_main
node_main -->|"starts UI"| node_app
node_main -->|"parses options"| node_cli_args
node_main -->|"loads credentials"| node_client_config
node_main -->|"loads preferences"| node_user_config
node_main -->|"starts network"| node_network
node_main -->|"reads input"| node_events
node_main -->|"renders UI"| node_render
node_main -->|"uses OAuth redirect"| node_redirect
node_user -->|"provides keys"| node_events
node_events -->|"routes input"| node_handlers
node_handlers -->|"dispatches to"| node_search
node_handlers -->|"dispatches to"| node_track
node_handlers -->|"dispatches to"| node_artist
node_handlers -->|"dispatches to"| node_library
node_handlers -->|"dispatches to"| node_podcasts
node_handlers -->|"dispatches to"| node_recommendations
node_app -->|"sends actions"| node_network
node_network -->|"updates state"| node_app
node_network -->|"calls API"| node_spotify_api
node_render -->|"reads state"| node_app
node_render -->|"renders analysis"| node_analysis_view
node_render -->|"renders help"| node_help_view
node_cli_args -->|"configures commands"| node_cli_app
node_cli_app -->|"uses network"| node_network
node_cli_app -->|"formats output"| node_cli_format
node_main -->|"obtains token"| node_oauth
node_oauth -->|"redirects for consent"| node_redirect
node_main -->|"displays terminal UI"| node_user

click node_main "https://github.com/rigellute/spotify-tui/blob/master/src/main.rs"
click node_app "https://github.com/rigellute/spotify-tui/blob/master/src/app.rs"
click node_events "https://github.com/rigellute/spotify-tui/blob/master/src/event/events.rs"
click node_handlers "https://github.com/rigellute/spotify-tui/tree/master/src/handlers"
click node_search "https://github.com/rigellute/spotify-tui/blob/master/src/handlers/search_results.rs"
click node_track "https://github.com/rigellute/spotify-tui/blob/master/src/handlers/track_table.rs"
click node_artist "https://github.com/rigellute/spotify-tui/blob/master/src/handlers/artist.rs"
click node_library "https://github.com/rigellute/spotify-tui/blob/master/src/handlers/library.rs"
click node_podcasts "https://github.com/rigellute/spotify-tui/blob/master/src/handlers/episode_table.rs"
click node_recommendations "https://github.com/rigellute/spotify-tui/blob/master/src/handlers/made_for_you.rs"
click node_render "https://github.com/rigellute/spotify-tui/blob/master/src/ui/mod.rs"
click node_analysis_view "https://github.com/rigellute/spotify-tui/blob/master/src/ui/audio_analysis.rs"
click node_help_view "https://github.com/rigellute/spotify-tui/blob/master/src/ui/help.rs"
click node_network "https://github.com/rigellute/spotify-tui/blob/master/src/network.rs"
click node_cli_args "https://github.com/rigellute/spotify-tui/blob/master/src/cli/clap.rs"
click node_cli_app "https://github.com/rigellute/spotify-tui/blob/master/src/cli/cli_app.rs"
click node_cli_format "https://github.com/rigellute/spotify-tui/blob/master/src/cli/util.rs"
click node_client_config "https://github.com/rigellute/spotify-tui/blob/master/src/config.rs"
click node_user_config "https://github.com/rigellute/spotify-tui/blob/master/src/user_config.rs"
click node_redirect "https://github.com/rigellute/spotify-tui/blob/master/src/redirect_uri.rs"

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_main,node_app,node_events,node_user toneBlue
class node_handlers,node_search,node_track,node_artist,node_library,node_podcasts,node_recommendations,node_render,node_analysis_view,node_help_view toneAmber
class node_network,node_spotify_api toneMint
class node_cli_args,node_cli_app,node_cli_format toneRose
class node_client_config,node_user_config,node_redirect,node_oauth toneIndigo
```

## Components

### Application runtime

- [Program entry](https://github.com/rigellute/spotify-tui/blob/master/src/main.rs): `src/main.rs`
- [App state](https://github.com/rigellute/spotify-tui/blob/master/src/app.rs): `src/app.rs`
- [Input events](https://github.com/rigellute/spotify-tui/blob/master/src/event/events.rs): `src/event/events.rs`

### Terminal views

- [View handlers](https://github.com/rigellute/spotify-tui/tree/master/src/handlers): `src/handlers`
- [Search results](https://github.com/rigellute/spotify-tui/blob/master/src/handlers/search_results.rs): `src/handlers/search_results.rs`
- [Track and album views](https://github.com/rigellute/spotify-tui/blob/master/src/handlers/track_table.rs): `src/handlers/track_table.rs`
- [Artist views](https://github.com/rigellute/spotify-tui/blob/master/src/handlers/artist.rs): `src/handlers/artist.rs`
- [Library views](https://github.com/rigellute/spotify-tui/blob/master/src/handlers/library.rs): `src/handlers/library.rs`
- [Podcast views](https://github.com/rigellute/spotify-tui/blob/master/src/handlers/episode_table.rs): `src/handlers/episode_table.rs`
- [Recommendations](https://github.com/rigellute/spotify-tui/blob/master/src/handlers/made_for_you.rs): `src/handlers/made_for_you.rs`
- [Terminal rendering](https://github.com/rigellute/spotify-tui/blob/master/src/ui/mod.rs): `src/ui/mod.rs`
- [Audio analysis view](https://github.com/rigellute/spotify-tui/blob/master/src/ui/audio_analysis.rs): `src/ui/audio_analysis.rs`
- [Help view](https://github.com/rigellute/spotify-tui/blob/master/src/ui/help.rs): `src/ui/help.rs`

### Spotify access

- [Network event dispatch](https://github.com/rigellute/spotify-tui/blob/master/src/network.rs): `src/network.rs`
- **Spotify API**

### Command line

- [CLI arguments](https://github.com/rigellute/spotify-tui/blob/master/src/cli/clap.rs): `src/cli/clap.rs`
- [CLI operations](https://github.com/rigellute/spotify-tui/blob/master/src/cli/cli_app.rs): `src/cli/cli_app.rs`
- [CLI formatting](https://github.com/rigellute/spotify-tui/blob/master/src/cli/util.rs): `src/cli/util.rs`

### Authentication and settings

- [Client configuration](https://github.com/rigellute/spotify-tui/blob/master/src/config.rs): `src/config.rs`
- [User preferences](https://github.com/rigellute/spotify-tui/blob/master/src/user_config.rs): `src/user_config.rs`
- [OAuth redirect](https://github.com/rigellute/spotify-tui/blob/master/src/redirect_uri.rs): `src/redirect_uri.rs`
- **Spotify OAuth**

### Other components

- **Terminal user**

## Connections

- Terminal user → Program entry: starts (evidence: `README.md`)
- Program entry → App state: starts UI (evidence: `src/main.rs`)
- Program entry → CLI arguments: parses options (evidence: `src/main.rs`)
- Program entry → Client configuration: loads credentials (evidence: `src/main.rs`)
- Program entry → User preferences: loads preferences (evidence: `src/main.rs`)
- Program entry → Network event dispatch: starts network (evidence: `src/main.rs`)
- Program entry → Input events: reads input (evidence: `src/main.rs`)
- Program entry → Terminal rendering: renders UI (evidence: `src/main.rs`)
- Program entry → OAuth redirect: uses OAuth redirect (evidence: `src/main.rs`)
- Terminal user → Input events: provides keys (evidence: `README.md`)
- Input events → View handlers: routes input (evidence: `src/handlers/mod.rs`)
- View handlers → Search results: dispatches to (evidence: `src/handlers/mod.rs`)
- View handlers → Track and album views: dispatches to (evidence: `src/handlers/mod.rs`)
- View handlers → Artist views: dispatches to (evidence: `src/handlers/mod.rs`)
- View handlers → Library views: dispatches to (evidence: `src/handlers/mod.rs`)
- View handlers → Podcast views: dispatches to (evidence: `src/handlers/mod.rs`)
- View handlers → Recommendations: dispatches to (evidence: `src/handlers/mod.rs`)
- App state → Network event dispatch: sends actions (evidence: `src/app.rs`)
- Network event dispatch → App state: updates state (evidence: `src/network.rs`)
- Network event dispatch → Spotify API: calls API (evidence: `src/network.rs`)
- Terminal rendering → App state: reads state (evidence: `src/ui/mod.rs`)
- Terminal rendering → Audio analysis view: renders analysis (evidence: `src/ui/mod.rs`)
- Terminal rendering → Help view: renders help (evidence: `src/ui/mod.rs`)
- CLI arguments → CLI operations: configures commands (evidence: `src/cli/mod.rs`)
- CLI operations → Network event dispatch: uses network (evidence: `src/cli/cli_app.rs`)
- CLI operations → CLI formatting: formats output (evidence: `src/cli/cli_app.rs`)
- Program entry → Spotify OAuth: obtains token (evidence: `src/main.rs`)
- Spotify OAuth → OAuth redirect: redirects for consent (evidence: `README.md`)
- Program entry → Terminal user: displays terminal UI (evidence: `README.md`)
