# avncharlie/spotify3ds architecture

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

- Interactive diagram: https://gitdiagram.com/avncharlie/spotify3ds
- Repository: https://github.com/avncharlie/spotify3ds

## Overview

Spotify3DS is a Nintendo 3DS Spotify remote, with a companion desktop setup app. The main workflow is account setup, then 3DS input through the player/library/lyrics screens, background Spotify and LRCLIB work, and updated displays. The graph preserves the README’s library browsing, search, artwork, synchronized lyrics, and volume features. Edges follow explicit README statements or the shown import/reference evidence; unsampled implementation details are not assumed.

Main entry points: [`source/worker.c`](https://github.com/avncharlie/spotify3ds/blob/main/source/worker.c) (Worker snapshots), [`source/main.c`](https://github.com/avncharlie/spotify3ds/blob/main/source/main.c) (App loop), [`cmd/spotify3ds-setup/main.go`](https://github.com/avncharlie/spotify3ds/blob/main/cmd/spotify3ds-setup/main.go) (Setup wizard), [`source/net/http.c`](https://github.com/avncharlie/spotify3ds/blob/main/source/net/http.c) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Account setup"]
  node_setupapp["Setup wizard<br/>[main.go]"]
  node_oauth["Setup OAuth<br/>[oauth.go]"]
  node_qr["QR generation<br/>[setupqr.go]"]
end

subgraph group_interface["3DS interface"]
  node_main["App loop<br/>[main.c]"]
  node_setupscan["Setup QR scan<br/>[setup_scanner.c]"]
  node_setupparse["Credential parser<br/>[setup_qr.c]"]
  node_playerui["Player screen<br/>[screen_player.c]"]
  node_libraryui["Library screen<br/>[screen_list.c]"]
  node_tracksui["Track browsing<br/>[screen_tracks.c]"]
  node_lyricsui["Lyrics screen<br/>[screen_lyrics.c]"]
  node_searchui["Search popover<br/>[search_popover.c]"]
end

subgraph group_background["Background work"]
  node_worker["Worker snapshots<br/>[worker.c]"]
end

subgraph group_spotify["Spotify services"]
  node_auth["Spotify auth<br/>[auth.c]"]
  node_player["Playback control<br/>[player.c]"]
  node_recents["Library data<br/>[recents.c]"]
  node_tracksearch["Track search<br/>[tracks_search.c]"]
  node_searchindex[("Search index<br/>[searchindex.c]")]
  node_art["Artwork retrieval<br/>[art.c]"]
  node_artcache[("Artwork cache<br/>[artcache.c]")]
  node_lyrics["Lyrics retrieval<br/>[lyrics.c]"]
end

subgraph group_transport["Network transport"]
  node_http["HTTP client<br/>[http.c]"]
  node_tls["TLS connection<br/>[tls.c]"]
  node_net["Network runtime<br/>[net.c]"]
end

node_user(("3DS user"))
node_spotifyservice{{"Spotify Web API"}}
node_lrclib{{"LRCLIB API"}}
node_sdcard[("3DS SD card")]

node_user -->|"configures account"| node_setupapp
node_setupapp -->|"authorizes"| node_oauth
node_setupapp -->|"creates setup QR"| node_qr
node_oauth -->|"passes credentials"| node_qr
node_user -->|"uses remote"| node_main
node_main -->|"opens setup scan"| node_setupscan
node_setupscan -.->|"parses QR payload"| node_setupparse
node_setupparse -->|"installs credentials"| node_sdcard
node_main -->|"starts background work"| node_worker
node_main -->|"shows player"| node_playerui
node_main -->|"shows library"| node_libraryui
node_main -->|"shows tracks"| node_tracksui
node_main -->|"shows lyrics"| node_lyricsui
node_playerui -.->|"requests playback"| node_worker
node_libraryui -.->|"requests collections"| node_worker
node_tracksui -.->|"requests tracks"| node_worker
node_lyricsui -.->|"requests lyrics"| node_worker
node_searchui -.->|"supports library search"| node_worker
node_worker -->|"uses credentials"| node_auth
node_worker -->|"coordinates playback"| node_player
node_worker -->|"loads library data"| node_recents
node_worker -->|"searches tracks"| node_tracksearch
node_worker -->|"builds cached corpus"| node_searchindex
node_worker -->|"loads artwork"| node_art
node_worker -->|"uses artwork cache"| node_artcache
node_worker -->|"fetches lyrics"| node_lyrics
node_auth -->|"sends API requests"| node_http
node_http -->|"exchanges encrypted data"| node_tls
node_tls -->|"uses network runtime"| node_net
node_http -.->|"calls API"| node_spotifyservice
node_lyrics -->|"queries lyrics"| node_lrclib
node_worker -->|"persists search cache"| node_sdcard

click node_setupapp "https://github.com/avncharlie/spotify3ds/blob/main/cmd/spotify3ds-setup/main.go"
click node_oauth "https://github.com/avncharlie/spotify3ds/blob/main/internal/setupoauth/oauth.go"
click node_qr "https://github.com/avncharlie/spotify3ds/blob/main/internal/setupqr/setupqr.go"
click node_main "https://github.com/avncharlie/spotify3ds/blob/main/source/main.c"
click node_setupscan "https://github.com/avncharlie/spotify3ds/blob/main/source/setup/setup_scanner.c"
click node_setupparse "https://github.com/avncharlie/spotify3ds/blob/main/source/setup/setup_qr.c"
click node_playerui "https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_player.c"
click node_libraryui "https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_list.c"
click node_tracksui "https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_tracks.c"
click node_lyricsui "https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_lyrics.c"
click node_worker "https://github.com/avncharlie/spotify3ds/blob/main/source/worker.c"
click node_searchui "https://github.com/avncharlie/spotify3ds/blob/main/source/ui/search_popover.c"
click node_auth "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/auth.c"
click node_player "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/player.c"
click node_recents "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/recents.c"
click node_tracksearch "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/tracks_search.c"
click node_searchindex "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/searchindex.c"
click node_art "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/art.c"
click node_artcache "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/artcache.c"
click node_lyrics "https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/lyrics.c"
click node_http "https://github.com/avncharlie/spotify3ds/blob/main/source/net/http.c"
click node_tls "https://github.com/avncharlie/spotify3ds/blob/main/source/net/tls.c"
click node_net "https://github.com/avncharlie/spotify3ds/blob/main/source/net/net.c"

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_setupapp,node_oauth,node_qr,node_user toneBlue
class node_main,node_setupscan,node_setupparse,node_playerui,node_libraryui,node_tracksui,node_lyricsui,node_searchui,node_sdcard toneAmber
class node_worker,node_spotifyservice,node_lrclib toneMint
class node_auth,node_player,node_recents,node_tracksearch,node_searchindex,node_art,node_artcache,node_lyrics toneRose
class node_http,node_tls,node_net toneIndigo
```

## Components

### Account setup

- [Setup wizard](https://github.com/avncharlie/spotify3ds/blob/main/cmd/spotify3ds-setup/main.go): `cmd/spotify3ds-setup/main.go`
- [Setup OAuth](https://github.com/avncharlie/spotify3ds/blob/main/internal/setupoauth/oauth.go): `internal/setupoauth/oauth.go`
- [QR generation](https://github.com/avncharlie/spotify3ds/blob/main/internal/setupqr/setupqr.go): `internal/setupqr/setupqr.go`

### 3DS interface

- [App loop](https://github.com/avncharlie/spotify3ds/blob/main/source/main.c): `source/main.c`
- [Setup QR scan](https://github.com/avncharlie/spotify3ds/blob/main/source/setup/setup_scanner.c): `source/setup/setup_scanner.c`
- [Credential parser](https://github.com/avncharlie/spotify3ds/blob/main/source/setup/setup_qr.c): `source/setup/setup_qr.c`
- [Player screen](https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_player.c): `source/ui/screen_player.c`
- [Library screen](https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_list.c): `source/ui/screen_list.c`
- [Track browsing](https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_tracks.c): `source/ui/screen_tracks.c`
- [Lyrics screen](https://github.com/avncharlie/spotify3ds/blob/main/source/ui/screen_lyrics.c): `source/ui/screen_lyrics.c`
- [Search popover](https://github.com/avncharlie/spotify3ds/blob/main/source/ui/search_popover.c): `source/ui/search_popover.c`

### Background work

- [Worker snapshots](https://github.com/avncharlie/spotify3ds/blob/main/source/worker.c): `source/worker.c`

### Spotify services

- [Spotify auth](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/auth.c): `source/spotify/auth.c`
- [Playback control](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/player.c): `source/spotify/player.c`
- [Library data](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/recents.c): `source/spotify/recents.c`
- [Track search](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/tracks_search.c): `source/spotify/tracks_search.c`
- [Search index](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/searchindex.c): `source/spotify/searchindex.c`
- [Artwork retrieval](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/art.c): `source/spotify/art.c`
- [Artwork cache](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/artcache.c): `source/spotify/artcache.c`
- [Lyrics retrieval](https://github.com/avncharlie/spotify3ds/blob/main/source/spotify/lyrics.c): `source/spotify/lyrics.c`

### Network transport

- [HTTP client](https://github.com/avncharlie/spotify3ds/blob/main/source/net/http.c): `source/net/http.c`
- [TLS connection](https://github.com/avncharlie/spotify3ds/blob/main/source/net/tls.c): `source/net/tls.c`
- [Network runtime](https://github.com/avncharlie/spotify3ds/blob/main/source/net/net.c): `source/net/net.c`

### Other components

- **3DS user**
- **Spotify Web API**
- **LRCLIB API**
- **3DS SD card**

## Connections

- 3DS user → Setup wizard: configures account
- Setup wizard → Setup OAuth: authorizes (evidence: `cmd/spotify3ds-setup/main.go`)
- Setup wizard → QR generation: creates setup QR (evidence: `cmd/spotify3ds-setup/main.go`)
- Setup OAuth → QR generation: passes credentials (evidence: `internal/setupoauth/oauth.go`)
- 3DS user → App loop: uses remote
- App loop → Setup QR scan: opens setup scan (evidence: `source/main.c`)
- Setup QR scan → Credential parser: parses QR payload
- Credential parser → 3DS SD card: installs credentials
- App loop → Worker snapshots: starts background work (evidence: `source/main.c`)
- App loop → Player screen: shows player
- App loop → Library screen: shows library
- App loop → Track browsing: shows tracks
- App loop → Lyrics screen: shows lyrics
- Player screen → Worker snapshots: requests playback
- Library screen → Worker snapshots: requests collections
- Track browsing → Worker snapshots: requests tracks
- Lyrics screen → Worker snapshots: requests lyrics
- Search popover → Worker snapshots: supports library search
- Worker snapshots → Spotify auth: uses credentials (evidence: `source/worker.c`)
- Worker snapshots → Playback control: coordinates playback
- Worker snapshots → Library data: loads library data (evidence: `source/worker.c`)
- Worker snapshots → Track search: searches tracks
- Worker snapshots → Search index: builds cached corpus (evidence: `source/worker.c`)
- Worker snapshots → Artwork retrieval: loads artwork (evidence: `source/worker.c`)
- Worker snapshots → Artwork cache: uses artwork cache (evidence: `source/worker.c`)
- Worker snapshots → Lyrics retrieval: fetches lyrics (evidence: `source/worker.c`)
- Spotify auth → HTTP client: sends API requests (evidence: `source/spotify/auth.c`)
- HTTP client → TLS connection: exchanges encrypted data (evidence: `source/net/http.c`)
- TLS connection → Network runtime: uses network runtime (evidence: `source/net/tls.c`)
- HTTP client → Spotify Web API: calls API
- Lyrics retrieval → LRCLIB API: queries lyrics
- Worker snapshots → 3DS SD card: persists search cache (evidence: `source/worker.c`)
