Architecture
Understand the services, data flow, and playback state behind Music Box.
Services
| Component | Responsibility |
|---|---|
| Caddy | Public HTTPS and reverse proxy. |
| Flask and Waitress | Catalog and account endpoints, playback arbitration, Jam state, and web player. |
| YouTube.js worker | Resolves playable URLs using a persistent private Node process. |
| Browser sidecar | Runs the protected Chromium sign-in flow for YouTube Music. |
| SQLite | Persists account and application state, including Jam records. |
| Alexa skill | Issues Alexa AudioPlayer directives and reports playback events to the backend. |
Playback state
Outside a Jam the backend coordinates the selected renderer and queue. It tracks queue occurrences and revisions so a late command cannot silently replace newer playback state. Browser clients combine periodic reads with bounded presence waits. The Alexa skill uses the live queue for successor decisions.
Audio delivery
The resolver prepares signed upstream URLs. Flask relays audio bytes as they arrive. The current-track buffer can keep received bytes temporarily for retries and handoff. Metadata and URL caches serve different purposes and do not store an offline music library.
Jam state
Jam sessions maintain a separate shared queue and position. The server tracks the invite, membership, and selected browser outputs. The invite and guest session scope access to the room.