How vicrodh/qbz works
1. Repository shape
This is a Rust + TypeScript monorepo for QBZ, a native desktop music client. The top-level architecture splits into a Tauri desktop app, a Rust daemon/service (qbzd), a SvelteKit frontend, and a set of reusable Rust crates for audio, playback, metadata, casting, and remote control.
2. Desktop shell vs UI
The user-facing app is the src-tauri Tauri 2 shell paired with the Svelte frontend in src/. The frontend owns the presentation layer, stores, and UI state, while Rust handles privileged/system tasks, audio, local services, and external integrations. Frontend-to-backend interaction is primarily via Tauri commands and a newer commands_v2 API surface.
3. Core playback pipeline
Playback is centered in the Rust crates qbz-player, qbz-audio, qbz-cache, and qbz-core. The flow is: track/stream selection → queue/playback engine → streaming source/cache → decoder/audio backend → output device. qbz-audio handles device control, backend selection, loudness normalization, and visualizer taps; qbz-player manages queue and playback state; qbz-cache provides memory/disk audio caching and prefetch.
4. Audio subsystem boundaries
Audio is designed around native, bit-perfect output rather than browser playback. The codebase supports PipeWire, ALSA, ALSA Direct, and PulseAudio, with per-track sample rate switching and device passthrough. Visualizer and loudness analysis are integrated into the audio tap path so they observe playback without becoming part of the UI layer.
5. Qobuz API and account flow
qbz-qobuz is the dedicated client/auth layer for Qobuz requests, link resolution, bundle parsing, and endpoint modeling. In the app, Qobuz-facing command modules expose catalog, search, playlists, favorites, discovery, and session/login operations. The frontend does not call Qobuz directly; it goes through backend commands and cached state.
6. Local library and metadata
qbz-library is the local music library subsystem. It scans folders, parses tags and CUE sheets, builds a SQLite-backed index, manages thumbnails, and supports sidecar tags so the original audio files remain untouched. In the app, this feeds the “local library” views, tag editing, and related metadata screens.
7. Offline and cache layers
There are two distinct caching concerns: playback/audio caching in qbz-cache, and application/offline caching in src-tauri/src/offline_cache and related config stores. The app also keeps image/cache layers for artwork and thumbnails. These caches support offline listening, faster browsing, and partial playback before full download completion.
8. Remote control and Qobuz Connect
Qobuz Connect is implemented as a separate protocol stack: qconnect-protocol, qconnect-core, qconnect-app, and qconnect-transport-ws. This layer models renderer/controller roles, queue synchronization, and websocket transport. In the desktop app, qconnect_service, qconnect, and related command paths bridge that protocol into playback and UI state.
9. Casting and device handoff
Casting is handled by qbz-cast and the app’s src-tauri/src/cast tree. It covers Chromecast, DLNA/UPnP, and AirPlay discovery plus device/session control. This is a separate boundary from local playback: the app can either render locally through the audio stack or hand off streams to a network device.
10. Integrations and enrichment
Third-party metadata and scrobbling live in qbz-integrations and matching app-side modules. The main external services are Last.fm, ListenBrainz, MusicBrainz, and Discogs, plus playlist import from Spotify, Apple Music, Tidal, and Deezer. The README also describes a hosted API proxy used to hide API keys for some integrations in prebuilt releases.
11. Backend orchestration in src-tauri
The Tauri backend is not just a thin bridge; it contains substantial domain logic: playback, queue, search, library, radio/recommendations, lyrics, share links, auto-theme, device monitoring, updates, and system integration. The commands/ and commands_v2/ folders are the primary API boundary to the frontend, while stores and services in src/lib/ coordinate UI state with those backend capabilities.
12. Daemon and local service surface
qbzd is the service-oriented backend binary. It includes a local API server, middleware, config, login/session management, MPRIS integration, wizard/setup flows, and the same domain areas exposed to the desktop app. This suggests the app can operate both as an interactive desktop client and as a local service endpoint for other components or remote control features.
13. Frontend state model
The Svelte frontend is organized around stores and service modules rather than direct RPC calls from components. Stores capture playback, queue, session, sidebar/navigation, themes, offline state, updates, and remote control state; services encapsulate command routing, remote API access, playback coordination, and image caching. The UI layer is therefore mostly declarative, with orchestration pushed into stores/services.
14. Build, packaging, and runtime boundaries
The repo is structured for multi-platform packaging: Linux native packages, Flatpak, Snap, AppImage, Gentoo, Nix, and an experimental macOS build. CI/CD workflows and packaging manifests live alongside the source, but the architecture remains centered on a native Rust backend plus a SvelteKit UI. The important runtime boundary is still local-process UI ↔ Rust backend ↔ external music/services, not a browser/webserver split.
Main entry points: commands_v2 Commands v2 · src qbzd · player App Player · library App Library
Components 23
Frontend
SvelteKit UI, stores, and browser-side orchestration.
- Svelte UI · Presentation layer, routes, components, stores, and services.
src - Stores & Services · Frontend state model and command-routing services that coordinate playback, remote state, caching, and updates.
src/lib/stores - Views · Primary app screens and modals for library, playback, search, settings, and onboarding.
src/lib/components/views - Remote Runtime · Frontend-side queue/runtime bridge for remote control and Qobuz Connect state.
src/lib/services/qconnectRuntime.ts
Desktop App
Tauri shell and Rust app backend for the native client.
- Tauri Backend · Desktop shell backend that exposes commands, stores, system integration, and app-specific orchestration.
src-tauri/src - Commands v2 · Primary command surface for auth, catalog, playback, queue, library, integrations, search, and settings.
src-tauri/src/commands_v2 - Legacy Commands · Older command boundary retained for backwards compatibility.
src-tauri/src/commands - App Audio · App-level audio integration, device watching, and bridge into the shared playback stack.
src-tauri/src/audio - App Player · App-side playback engine and streaming source coordination.
src-tauri/src/player - App Library · Local library commands plus remote metadata and thumbnails for UI consumption.
src-tauri/src/library - Offline Cache · Application offline/download cache with metadata, downloader, and path validation.
src-tauri/src/offline_cache - Casting · Chromecast, DLNA, and AirPlay discovery and session control.
src-tauri/src/cast - Qconnect Service · Desktop bridge into Qobuz Connect protocol state and runtime.
src-tauri/src/qconnect_service.rs
Rust Crates
Reusable Rust subsystems for playback, audio, metadata, casting, and remote control.
- qbz-player · Queue and playback state machine plus streaming source handling.
crates/qbz-player/src - qbz-audio · Native device output, backend selection, loudness, analyzer taps, and visualizer feed.
crates/qbz-audio/src - qbz-cache · Memory/disk playback caching and prefetch support.
crates/qbz-cache/src - qbz-qobuz · Qobuz auth, client, endpoint modeling, link resolution, and bundle parsing.
crates/qbz-qobuz/src - qbz-library · Folder scanning, cue parsing, SQLite index, tags, thumbnails, and sidecar metadata.
crates/qbz-library/src - qbz-cast · Reusable casting stack for Chromecast, DLNA/UPnP, and AirPlay.
crates/qbz-cast/src - qconnect stack · Protocol, core reducer, app state, and websocket transport for Qobuz Connect.
crates/qconnect-protocol/src - qbz-integrations · Last.fm, ListenBrainz, and MusicBrainz clients plus caches and models.
crates/qbz-integrations/src
Daemon
qbzd local service and API surface.
- qbzd · Service-oriented backend with API server, middleware, login, MPRIS, wizard flows, and session management.
crates/qbzd/src
Packaging
Release, distro, and CI packaging artifacts.
- Packaging & CI · Build workflows, distro packaging, manifests, and release automation.
.github/workflows
Connections 25
- Svelte UI → Stores & Services: uses · Routes and components depend on stores/services for app behavior.
- Svelte UI → Views: renders · The UI is composed of reusable views and modal components.
- Stores & Services → Commands v2: calls · Frontend orchestration primarily talks to the v2 backend command surface.
- Stores & Services → Remote Runtime: syncs · State services coordinate local and remote queue/runtime state.
- Remote Runtime → Qconnect Service: bridges · Remote runtime state is backed by the desktop Qconnect bridge.
- Tauri Backend → Commands v2: exposes · The Tauri backend publishes the primary command API to the frontend.
- Tauri Backend → Legacy Commands: keeps · Legacy commands remain for compatibility.
- Commands v2 → App Player: drives · Playback, queue, and source actions are coordinated through the app player.
- Commands v2 → App Library: queries · Library views and metadata screens use backend library services.
- Commands v2 → Offline Cache: reads/writes · Offline and download state is managed through the app cache layer.
- Commands v2 → Casting: controls · Device discovery and handoff flow through the cast subsystem.
- Commands v2 → qbz-integrations: syncs · Metadata enrichment and scrobbling/integration actions reach external services.
- App Player → qbz-player: uses · The app player delegates core queue and playback behavior to the shared crate.
- App Audio → qbz-audio: uses · Device output and analyzer taps are implemented in the shared audio crate.
- App Player → qbz-cache: prefetches · Playback uses shared caching for streaming, prefetch, and partial download.
- App Library → qbz-library: indexes · Local library scanning and indexing are handled by the shared library crate.
- App Library → qbz-qobuz: enriches · Remote metadata and link resolution rely on the Qobuz client layer.
- Casting → qbz-cast: delegates · The app cast tree is a thin bridge over the reusable cast stack.
- Qconnect Service → qconnect stack: implements · Desktop remote-control behavior is backed by the Qconnect protocol stack.
- qbzd → App Player: coordinates · The daemon exposes playback and queue capabilities through its service API.
- qbzd → App Library: serves · Local service endpoints provide library and metadata access.
- qbzd → Qconnect Service: hosts · Qconnect-related service paths are surfaced from the daemon.
- Packaging & CI → Tauri Backend: builds · Release automation packages the desktop backend and app shell.
- Packaging & CI → qbzd: packages · Separate workflows ship the qbzd service binary and manifests.
- Packaging & CI → Svelte UI: bundles · Frontend assets are bundled into desktop and distro artifacts.