Skip to content

Architecture

This section gives you the picture you need before you open the code: what the parts of Music Assistant are and how they work together. Each page explains one part and then points you to the README next to the code that goes deeper.

flowchart LR
  subgraph C["Clients"]
    FE["Web frontend"]
    HA["Home Assistant integration"]
    APPS["Mobile and desktop apps"]
  end
  subgraph S["Music Assistant server"]
    WEB["webserver<br/>/ws and /api"]
    MASS["mass<br/>MusicAssistant"]
    CTRL["Core controllers<br/>music, players, player_queues, streams ..."]
    PROV["Providers<br/>music, player, metadata, plugin, audio analysis"]
  end
  SVC["Music services and local files"]
  SPK["Speakers"]
  FE --> WEB
  HA --> WEB
  APPS --> WEB
  WEB --> MASS
  MASS --> CTRL
  CTRL --> PROV
  PROV --> SVC
  PROV --> SPK

Read it from left to right. Clients only talk to the server over its API, which the webserver controller serves. Behind it sits one object, mass, that holds everything else. The core controllers do the work. They reach the outside world through providers: a music provider talks to a streaming service or reads local files, and a player provider talks to speakers.

One asyncio process. The server is one Python process with one event loop. Everything is async. Blocking IO inside a coroutine stalls every other task, so the code avoids it and a pre-commit check looks for it.

Controllers own state. Each core controller, such as mass.music, mass.players or mass.player_queues, owns one area and its data. Other code asks the controller instead of keeping its own copy.

Providers plug in. A provider adds a music source, a way to reach speakers, a metadata source, audio analysis, or an extra feature (a plugin). Each one is a folder with a manifest.json; the ones that ship with the server live under music_assistant/providers/. The server loads it, and the controllers use it through a fixed base class.

State changes travel as events. When something changes, the owner calls mass.signal_event with an EventType. Controllers and connected clients subscribe to those events instead of polling.

Clients talk over one API. The web frontend, the Home Assistant integration, the apps and third-party tools all use the same commands over the WebSocket at /ws (or HTTP at /api). A command is a method marked with @api_command.

Audio is streamed, never stored. The server fetches audio from the provider, processes it and streams it to the speaker while it plays. It is not a way to download or keep copies of music. Some guards in the code exist only for that reason. The server’s AGENTS.md lists them and the usage policy explains why.

  • The repositories: which repository holds what, and how they depend on each other.
  • Inside the server: the mass object, the core controllers, startup and the conventions that hold everywhere.
  • Providers: provider types, what a provider folder holds, and how a provider is loaded.
  • Players: how protocols from several providers become one player.
  • From play to sound: what happens between “play this album” and audio coming out of a speaker.
  • The API and events: how clients connect, send commands and get events.
  • Library, sync and metadata: how provider libraries end up in one library database.
  • Where data lives: the files the server keeps, and why a change to them needs a migration.

Music Assistant is a project of the Open Home Foundation.