# justshivv/opentune architecture

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

- Interactive diagram: https://gitdiagram.com/justshivv/opentune
- Repository: https://github.com/justshivv/opentune

## Overview

OpenTune is an Android YouTube Music player. The main journey runs from browsing or searching music, through Innertube retrieval and stream resolution, into background playback and the player UI. Separate capabilities include offline downloads and lyrics, local library and account features, radio, podcasts, casting, and synchronized listening. The graph combines sampled source references with README-documented capabilities; several feature implementations were not sampled, so their internal calls are intentionally not inferred.

Main entry points: [`app/src/main/java/com/opentune/playback/PlaybackService.kt`](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/playback/PlaybackService.kt) (Playback service), [`app/src/main/java/com/opentune/data/MusicRepository.kt`](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/MusicRepository.kt) (Music repository), [`app/src/main/java/com/opentune/ui/search/SearchViewModel.kt`](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/search/SearchViewModel.kt) (Search logic), [`app/src/main/java/com/opentune/ui/player/PlayerScreen.kt`](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/player/PlayerScreen.kt) (Player screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and UI"]
  node_activity["Android activity<br/>[MainActivity.kt]"]
  node_approot["App navigation<br/>[AppRoot.kt]"]
  node_searchui["Search screens<br/>[SearchScreen.kt]"]
  node_searchvm["Search logic<br/>[SearchViewModel.kt]"]
  node_browseui["Browse screens<br/>[BrowseScreens.kt]"]
  node_playerui["Player screens<br/>[PlayerScreen.kt]"]
end

subgraph group_music["Music discovery"]
  node_repository["Music repository<br/>[MusicRepository.kt]"]
  node_innertube["Innertube API<br/>[Innertube.kt]"]
  node_parser["Response parser<br/>[InnertubeParser.kt]"]
  node_resolver["Stream resolver<br/>[StreamResolver.kt]"]
end

subgraph group_playback["Playback and audio"]
  node_playback["Playback service<br/>[PlaybackService.kt]"]
  node_queue["Playback queue<br/>[QueueStore.kt]"]
  node_settings[("Playback settings<br/>[AppSettings.kt]")]
end

subgraph group_personal["Personal library"]
  node_downloads["Offline downloads<br/>[Downloads.kt]"]
  node_lyrics["Lyrics lookup"]
  node_history[("Listening history<br/>[History.kt]")]
end

subgraph group_extras["Listening extras"]
  node_radio["Live radio<br/>[Radio.kt]"]
  node_podcasts["Podcasts<br/>[Podcasts.kt]"]
  node_cast["Device casting<br/>[Cast.kt]"]
  node_together["Listen together<br/>[RoomSession.kt]"]
end

node_listener(("Listener"))
node_youtube{{"YouTube Music"}}
node_lyricsources{{"Lyrics providers"}}
node_radioindex{{"Radio directory"}}
node_castdevice{{"Cast devices"}}

node_listener -->|"opens app"| node_activity
node_activity -->|"shows UI"| node_approot
node_listener -->|"searches music"| node_searchui
node_searchui -->|"dispatches search"| node_searchvm
node_searchvm -->|"requests results"| node_repository
node_listener -->|"browses catalog"| node_browseui
node_browseui -->|"loads shelves"| node_repository
node_repository -->|"requests catalog"| node_innertube
node_repository -->|"parses responses"| node_parser
node_innertube -.->|"queries catalog"| node_youtube
node_searchvm -->|"resolves stream"| node_resolver
node_listener -->|"controls playback"| node_playerui
node_playerui -->|"controls session"| node_playback
node_playback -->|"resolves media"| node_resolver
node_playback -.->|"updates queue"| node_queue
node_settings -->|"configures sound"| node_playback
node_listener -->|"downloads tracks"| node_downloads
node_downloads -->|"fetches audio"| node_resolver
node_downloads -->|"saves offline lyrics"| node_lyrics
node_lyrics -.->|"queries providers"| node_lyricsources
node_listener -->|"tunes radio"| node_radio
node_radio -->|"searches stations"| node_radioindex
node_listener -->|"browses podcasts"| node_podcasts
node_playback -->|"plays stations"| node_radio
node_playback -->|"plays episodes"| node_podcasts
node_listener -->|"starts casting"| node_cast
node_playerui -->|"opens cast controls"| node_cast
node_cast -.->|"streams audio"| node_castdevice
node_listener -->|"joins room"| node_together
node_together -->|"synchronizes session"| node_playback
node_playback -->|"records listens"| node_history

click node_activity "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/MainActivity.kt"
click node_approot "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/AppRoot.kt"
click node_searchui "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/search/SearchScreen.kt"
click node_searchvm "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/search/SearchViewModel.kt"
click node_browseui "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/browse/BrowseScreens.kt"
click node_playerui "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/player/PlayerScreen.kt"
click node_repository "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/MusicRepository.kt"
click node_innertube "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/innertube/Innertube.kt"
click node_parser "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/innertube/InnertubeParser.kt"
click node_resolver "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/innertube/StreamResolver.kt"
click node_playback "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/playback/PlaybackService.kt"
click node_queue "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/playback/QueueStore.kt"
click node_settings "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/settings/AppSettings.kt"
click node_downloads "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/download/Downloads.kt"
click node_lyrics "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/lyrics/LyricsRepository.kt"
click node_history "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/history/History.kt"
click node_radio "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/radio/Radio.kt"
click node_podcasts "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/podcasts/Podcasts.kt"
click node_cast "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/cast/Cast.kt"
click node_together "https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/together/RoomSession.kt"

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_activity,node_approot,node_searchui,node_searchvm,node_browseui,node_playerui toneBlue
class node_repository,node_innertube,node_parser,node_resolver toneAmber
class node_playback,node_queue,node_settings toneMint
class node_downloads,node_lyrics,node_history toneRose
class node_radio,node_podcasts,node_cast,node_together,node_listener,node_youtube,node_lyricsources,node_radioindex,node_castdevice toneIndigo
```

## Components

### App and UI

- [Android activity](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/MainActivity.kt): `app/src/main/java/com/opentune/MainActivity.kt`
- [App navigation](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/AppRoot.kt): `app/src/main/java/com/opentune/ui/AppRoot.kt`
- [Search screens](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/search/SearchScreen.kt): `app/src/main/java/com/opentune/ui/search/SearchScreen.kt`
- [Search logic](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/search/SearchViewModel.kt): `app/src/main/java/com/opentune/ui/search/SearchViewModel.kt`
- [Browse screens](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/browse/BrowseScreens.kt): `app/src/main/java/com/opentune/ui/browse/BrowseScreens.kt`
- [Player screens](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/ui/player/PlayerScreen.kt): `app/src/main/java/com/opentune/ui/player/PlayerScreen.kt`

### Music discovery

- [Music repository](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/MusicRepository.kt): `app/src/main/java/com/opentune/data/MusicRepository.kt`
- [Innertube API](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/innertube/Innertube.kt): `app/src/main/java/com/opentune/data/innertube/Innertube.kt`
- [Response parser](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/innertube/InnertubeParser.kt): `app/src/main/java/com/opentune/data/innertube/InnertubeParser.kt`
- [Stream resolver](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/innertube/StreamResolver.kt): `app/src/main/java/com/opentune/data/innertube/StreamResolver.kt`

### Playback and audio

- [Playback service](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/playback/PlaybackService.kt): `app/src/main/java/com/opentune/playback/PlaybackService.kt`
- [Playback queue](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/playback/QueueStore.kt): `app/src/main/java/com/opentune/playback/QueueStore.kt`
- [Playback settings](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/settings/AppSettings.kt): `app/src/main/java/com/opentune/data/settings/AppSettings.kt`

### Personal library

- [Offline downloads](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/download/Downloads.kt): `app/src/main/java/com/opentune/data/download/Downloads.kt`
- [Lyrics lookup](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/lyrics/LyricsRepository.kt): `app/src/main/java/com/opentune/data/lyrics/LyricsRepository.kt`
- [Listening history](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/history/History.kt): `app/src/main/java/com/opentune/data/history/History.kt`

### Listening extras

- [Live radio](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/radio/Radio.kt): `app/src/main/java/com/opentune/data/radio/Radio.kt`
- [Podcasts](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/podcasts/Podcasts.kt): `app/src/main/java/com/opentune/data/podcasts/Podcasts.kt`
- [Device casting](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/cast/Cast.kt): `app/src/main/java/com/opentune/cast/Cast.kt`
- [Listen together](https://github.com/justshivv/opentune/blob/main/app/src/main/java/com/opentune/data/together/RoomSession.kt): `app/src/main/java/com/opentune/data/together/RoomSession.kt`

### Other components

- **Listener**
- **YouTube Music**
- **Lyrics providers**
- **Radio directory**
- **Cast devices**

## Connections

- Listener → Android activity: opens app (evidence: `app/src/main/java/com/opentune/MainActivity.kt`)
- Android activity → App navigation: shows UI (evidence: `app/src/main/java/com/opentune/MainActivity.kt`)
- Listener → Search screens: searches music (evidence: `README.md`)
- Search screens → Search logic: dispatches search (evidence: `app/src/main/java/com/opentune/ui/search/SearchScreen.kt`)
- Search logic → Music repository: requests results (evidence: `app/src/main/java/com/opentune/ui/search/SearchViewModel.kt`)
- Listener → Browse screens: browses catalog (evidence: `README.md`)
- Browse screens → Music repository: loads shelves (evidence: `app/src/main/java/com/opentune/ui/browse/BrowseScreens.kt`)
- Music repository → Innertube API: requests catalog (evidence: `app/src/main/java/com/opentune/data/MusicRepository.kt`)
- Music repository → Response parser: parses responses (evidence: `app/src/main/java/com/opentune/data/MusicRepository.kt`)
- Innertube API → YouTube Music: queries catalog (evidence: `README.md`)
- Search logic → Stream resolver: resolves stream (evidence: `app/src/main/java/com/opentune/ui/search/SearchViewModel.kt`)
- Listener → Player screens: controls playback (evidence: `README.md`)
- Player screens → Playback service: controls session (evidence: `app/src/main/java/com/opentune/ui/player/PlayerScreen.kt`)
- Playback service → Stream resolver: resolves media (evidence: `app/src/main/java/com/opentune/playback/PlaybackService.kt`)
- Playback service → Playback queue: updates queue (evidence: `app/src/main/java/com/opentune/playback/PlaybackService.kt`)
- Playback settings → Playback service: configures sound (evidence: `app/src/main/java/com/opentune/playback/PlaybackService.kt`)
- Listener → Offline downloads: downloads tracks (evidence: `README.md`)
- Offline downloads → Stream resolver: fetches audio (evidence: `app/src/main/java/com/opentune/data/download/Downloads.kt`)
- Offline downloads → Lyrics lookup: saves offline lyrics (evidence: `app/src/main/java/com/opentune/data/download/Downloads.kt`)
- Lyrics lookup → Lyrics providers: queries providers (evidence: `README.md`)
- Listener → Live radio: tunes radio (evidence: `README.md`)
- Live radio → Radio directory: searches stations (evidence: `app/src/main/java/com/opentune/data/radio/Radio.kt`)
- Listener → Podcasts: browses podcasts (evidence: `README.md`)
- Playback service → Live radio: plays stations (evidence: `app/src/main/java/com/opentune/playback/PlaybackService.kt`)
- Playback service → Podcasts: plays episodes (evidence: `app/src/main/java/com/opentune/playback/PlaybackService.kt`)
- Listener → Device casting: starts casting (evidence: `README.md`)
- Player screens → Device casting: opens cast controls (evidence: `app/src/main/java/com/opentune/ui/player/PlayerScreen.kt`)
- Device casting → Cast devices: streams audio (evidence: `README.md`)
- Listener → Listen together: joins room (evidence: `README.md`)
- Listen together → Playback service: synchronizes session (evidence: `app/src/main/java/com/opentune/data/together/RoomSession.kt`)
- Playback service → Listening history: records listens (evidence: `app/src/main/java/com/opentune/playback/PlaybackService.kt`)
