How tomahawk-player/tomahawk works
Main Logical Layers & Components
• Presentation Layer (Qt UI)
– TomahawkApp, TomahawkWindow, dialogs, viewpages, widgets
– Event handling, user interactions, view controllers
• Core Layer (libtomahawk)
– PluginLoader & ModuleManager
– AccountManager & account plugins (Spotify, Google, XMPP, Zeroconf, etc.)
– ResolverEngine & script/native resolvers (JS, playdar, external)
– InfoSystem & info plugins (MusicBrainz, Echonest, Discogs…)
– Pipeline (job queue / asynchronous tasks)
– AudioEngine (wraps libVLC, output streams)
– Network layer (ConnectionManager, Servent for P2P, HTTP, WebSocket)
– Database subsystem (SQLite via DatabaseWorker, commands, schema, migrations, fuzzy index)
– Collection & Metadata modules (MusicScanner, Tag handlers, Collection API)
• External Interfaces
– Local file system (scanning local library)
– Subscription services (Spotify, Beats, Google Music, TIDAL…)
– Free platforms (SoundCloud, YouTube, Bandcamp…)
– P2P network of other Tomahawk peers (Servent)
– System services (notifications, media keys, UPower)
• Support Tools & Build Infrastructure
– CrashReporter (separate process)
– CMake / CPack build scripts, packaging modules, Docker scripts
– Tests (unit tests for database, network, etc.)
Relationships & Data Flows
• UI → Core
– User actions (search, play, browse) invoke Core APIs (Pipeline)
– Core pushes updates (model changes, job status) back to UI viewpages
• Core → Database
– Queries & commands flow from Pipeline to DatabaseWorker (SQLite)
– Database schema updates, migrations under data/sql
• Core → Network & External Services
– ResolverEngine dispatches network requests (HTTP, WebSocket) via ConnectionManager
– Servent handles P2P discovery and streaming
• Core → AudioEngine
– Pipeline tasks hand off media URLs/streams to AudioEngine for playback
• Plugin Loader → Plugins
– Dynamically loads account, info, resolver, viewpage, widget plugins at runtime
Architectural Patterns
• Plugin architecture (DLLs / Qt plugins) – dynamic extension points for accounts, resolvers, info, viewpages
• Model-View-Controller / Model-View-Delegate in UI (Qt’s MVC using models, views, delegates)
• Pipeline / Job queue pattern for async tasks (indexing, network calls, database commands)
• Layered separation (UI / Core / Data / External)
• Repository + Factory patterns in resolvers and accounts