# ochichan/yututui architecture

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

## Overview

YuTuTui! is a terminal music player for YouTube Music and other catalogs. The main user workflow is to search a provider, choose a result, and play it through mpv while managing the queue. Distinct supporting capabilities include local-library search and imports, DJ Gem recommendations, listening-history signals, Spotify transfers, remote control, device sync, and scrobbling. Groups reflect these product areas; the README documents the primary playback workflow and capabilities, while source-index references support several internal module relationships. Unsampled implementation details and uncertain links are omitted.

Main entry points: [`src/app/reducer.rs`](https://github.com/ochichan/yututui/blob/main/src/app/reducer.rs) (App state and actions), [`src/api/ytmusic.rs`](https://github.com/ochichan/yututui/blob/main/src/api/ytmusic.rs) (Catalog search), [`src/queue.rs`](https://github.com/ochichan/yututui/blob/main/src/queue.rs) (Play queue), [`src/terminal_runtime/runner.rs`](https://github.com/ochichan/yututui/blob/main/src/terminal_runtime/runner.rs) (Terminal player)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Player interface"]
  node_terminal["Terminal player<br/>[runner.rs]"]
  node_app["App state and actions<br/>[reducer.rs]"]
  node_remote["Remote control<br/>[server.rs]"]
end

subgraph group_catalog["Catalog and library"]
  node_search["Catalog search<br/>[ytmusic.rs]"]
  node_sources["Search providers<br/>[search_source.rs]"]
  node_local["Local library<br/>[scan.rs]"]
  node_transfer["Import and transfer<br/>[engine.rs]"]
end

subgraph group_playback["Playback and recommendations"]
  node_queue["Play queue<br/>[queue.rs]"]
  node_player["Audio playback<br/>[mpv.rs]"]
  node_streaming["DJ Gem engine<br/>[mod.rs]"]
end

subgraph group_state["State and sync"]
  node_signals["Listening signals<br/>[signals.rs]"]
  node_persistence[("Persistent state<br/>[persist.rs]")]
  node_sync["Device sync<br/>[engine.rs]"]
end

subgraph group_integrations["External integrations"]
  node_scrobble["Scrobbling<br/>[mod.rs]"]
  node_media["OS media session<br/>[mod.rs]"]
  node_tools["yt-dlp management<br/>[ytdlp.rs]"]
  node_spotify["Spotify API<br/>[client.rs]"]
end

node_user(("Listener"))

node_user -->|"uses"| node_terminal
node_terminal -.->|"dispatches input"| node_app
node_user -->|"searches"| node_search
node_sources -->|"selects provider"| node_search
node_search -->|"plays result"| node_queue
node_user -->|"manages"| node_queue
node_queue -->|"plays track"| node_player
node_player -->|"resolves streams"| node_tools
node_local -.->|"provides tracks"| node_transfer
node_transfer -->|"transfers playlists"| node_spotify
node_streaming -->|"ranks using"| node_signals
node_app -.->|"persists state"| node_persistence
node_sync -->|"syncs personal state"| node_persistence
node_remote -.->|"controls player"| node_app
node_media -->|"provides snapshots"| node_scrobble
node_app -->|"publishes playback"| node_media

click node_terminal "https://github.com/ochichan/yututui/blob/main/src/terminal_runtime/runner.rs"
click node_app "https://github.com/ochichan/yututui/blob/main/src/app/reducer.rs"
click node_search "https://github.com/ochichan/yututui/blob/main/src/api/ytmusic.rs"
click node_sources "https://github.com/ochichan/yututui/blob/main/src/search_source.rs"
click node_local "https://github.com/ochichan/yututui/blob/main/src/local/scan.rs"
click node_transfer "https://github.com/ochichan/yututui/blob/main/src/transfer/engine.rs"
click node_queue "https://github.com/ochichan/yututui/blob/main/src/queue.rs"
click node_player "https://github.com/ochichan/yututui/blob/main/src/player/mpv.rs"
click node_streaming "https://github.com/ochichan/yututui/blob/main/src/streaming/mod.rs"
click node_signals "https://github.com/ochichan/yututui/blob/main/src/signals.rs"
click node_persistence "https://github.com/ochichan/yututui/blob/main/src/persist.rs"
click node_sync "https://github.com/ochichan/yututui/blob/main/src/sync/manual/engine.rs"
click node_remote "https://github.com/ochichan/yututui/blob/main/src/remote/server.rs"
click node_scrobble "https://github.com/ochichan/yututui/blob/main/src/scrobble/mod.rs"
click node_media "https://github.com/ochichan/yututui/blob/main/src/media/mod.rs"
click node_tools "https://github.com/ochichan/yututui/blob/main/src/tools/ytdlp.rs"
click node_spotify "https://github.com/ochichan/yututui/blob/main/src/spotify/client.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_terminal,node_app,node_remote toneBlue
class node_search,node_sources,node_local,node_transfer toneAmber
class node_queue,node_player,node_streaming toneMint
class node_signals,node_persistence,node_sync toneRose
class node_scrobble,node_media,node_tools,node_spotify,node_user toneIndigo
```

## Components

### Player interface

- [Terminal player](https://github.com/ochichan/yututui/blob/main/src/terminal_runtime/runner.rs): `src/terminal_runtime/runner.rs`
- [App state and actions](https://github.com/ochichan/yututui/blob/main/src/app/reducer.rs): `src/app/reducer.rs`
- [Remote control](https://github.com/ochichan/yututui/blob/main/src/remote/server.rs): `src/remote/server.rs`

### Catalog and library

- [Catalog search](https://github.com/ochichan/yututui/blob/main/src/api/ytmusic.rs): `src/api/ytmusic.rs`
- [Search providers](https://github.com/ochichan/yututui/blob/main/src/search_source.rs): `src/search_source.rs`
- [Local library](https://github.com/ochichan/yututui/blob/main/src/local/scan.rs): `src/local/scan.rs`
- [Import and transfer](https://github.com/ochichan/yututui/blob/main/src/transfer/engine.rs): `src/transfer/engine.rs`

### Playback and recommendations

- [Play queue](https://github.com/ochichan/yututui/blob/main/src/queue.rs): `src/queue.rs`
- [Audio playback](https://github.com/ochichan/yututui/blob/main/src/player/mpv.rs): `src/player/mpv.rs`
- [DJ Gem engine](https://github.com/ochichan/yututui/blob/main/src/streaming/mod.rs): `src/streaming/mod.rs`

### State and sync

- [Listening signals](https://github.com/ochichan/yututui/blob/main/src/signals.rs): `src/signals.rs`
- [Persistent state](https://github.com/ochichan/yututui/blob/main/src/persist.rs): `src/persist.rs`
- [Device sync](https://github.com/ochichan/yututui/blob/main/src/sync/manual/engine.rs): `src/sync/manual/engine.rs`

### External integrations

- [Scrobbling](https://github.com/ochichan/yututui/blob/main/src/scrobble/mod.rs): `src/scrobble/mod.rs`
- [OS media session](https://github.com/ochichan/yututui/blob/main/src/media/mod.rs): `src/media/mod.rs`
- [yt-dlp management](https://github.com/ochichan/yututui/blob/main/src/tools/ytdlp.rs): `src/tools/ytdlp.rs`
- [Spotify API](https://github.com/ochichan/yututui/blob/main/src/spotify/client.rs): `src/spotify/client.rs`

### Other components

- **Listener**

## Connections

- Listener → Terminal player: uses (evidence: `README.md`)
- Terminal player → App state and actions: dispatches input
- Listener → Catalog search: searches (evidence: `README.md`)
- Search providers → Catalog search: selects provider (evidence: `src/api/mod.rs`)
- Catalog search → Play queue: plays result (evidence: `README.md`)
- Listener → Play queue: manages (evidence: `README.md`)
- Play queue → Audio playback: plays track (evidence: `README.md`)
- Audio playback → yt-dlp management: resolves streams
- Local library → Import and transfer: provides tracks
- Import and transfer → Spotify API: transfers playlists (evidence: `README.md`)
- DJ Gem engine → Listening signals: ranks using (evidence: `src/streaming/mod.rs`)
- App state and actions → Persistent state: persists state
- Device sync → Persistent state: syncs personal state (evidence: `src/sync/manual/engine.rs`)
- Remote control → App state and actions: controls player
- OS media session → Scrobbling: provides snapshots (evidence: `src/scrobble/mod.rs`)
- App state and actions → OS media session: publishes playback (evidence: `src/media/mod.rs`)
