# spotiflacapp/spotiflac-mobile architecture

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

- Interactive diagram: https://gitdiagram.com/spotiflacapp/spotiflac-mobile
- Repository: https://github.com/spotiflacapp/spotiflac-mobile

## Overview

1. **Repository shape**
   - This is a cross-platform Flutter mobile app with native Android and iOS host projects, plus a substantial Go backend under `go_backend`.
   - The app is packaged for Android, iOS, and likely alternative distribution channels via `apps.json` and GitHub release workflows.

2. **Primary UI layer**
   - `lib/screens` contains the user-facing flows: home, search, queue, repo/store, album/artist/playlist views, local library views, and a large settings area.
   - `lib/widgets` provides reusable UI building blocks such as cover images, pickers, dialogs, progress views, and settings scaffolding.
   - `lib/app.dart` and `lib/main.dart` are the app entry points, with `main_shell.dart` acting as the main navigation container.

3. **State management and app orchestration**
   - `lib/providers` is the main coordination layer between UI and business logic.
   - Providers are split by concern: downloads, playback, search/explore, extensions/store, library collections, local library, recent access, settings, theme, and tracks.
   - This suggests a reactive architecture where screens read state from providers and invoke actions that mutate provider-managed state.

4. **Core domain models**
   - `lib/models` defines the app’s persisted and runtime entities: tracks, download items, settings, and theme settings.
   - Generated `*.g.dart` files indicate codegen-backed serialization/storage for these models.
   - These models are used across UI, local databases, and the backend bridge, so they form the main shared contract inside the Flutter layer.

5. **Go backend as the heavy-lifting engine**
   - `go_backend` is the main non-UI subsystem and appears to implement the download/search/metadata engine.
   - It includes providers for external music services such as `deezer.go`, `qobuz.go`, and `tidal.go`, plus lyrics providers and Song.link integration.
   - The Go layer also handles metadata extraction, filename generation, duplicates, cover art, CUE parsing, progress reporting, and rate limiting.

6. **Extension system**
   - The extension architecture is a major boundary in the app.
   - Files like `extension_manager.go`, `extension_store.go`, `extension_manifest.go`, `extension_runtime_*`, and `extension_provider*` indicate a plugin runtime that loads external extensions, exposes auth/http/file/storage helpers, and mediates provider priority.
   - The Flutter side has corresponding UI for browsing, installing, configuring, and prioritizing extensions under the Store and Settings screens.

7. **Download pipeline**
   - Downloads are coordinated across Flutter providers, the Go backend, and native platform services.
   - `download_queue_provider.dart`, `download_request_payload.dart`, `download_service_picker.dart`, and `DownloadService.kt` indicate a queued download flow with platform-specific execution support.
   - The system likely resolves track metadata, selects a provider/extension, fetches audio and artwork, and writes files through platform-aware storage logic.

8. **Local persistence and caches**
   - Several services manage on-device databases: `app_state_database.dart`, `history_database.dart`, `library_database.dart`, and `library_collections_database.dart`.
   - Caching is explicit for covers and embedded artwork via `cover_cache_manager.dart` and `downloaded_embedded_cover_resolver.dart`.
   - This implies offline-first behavior for library browsing, recent access, and download history.

9. **Platform bridge and native concerns**
   - `platform_bridge.dart` is the boundary between Flutter and platform-specific capabilities.
   - Native Android code includes `MainActivity.kt` and `DownloadService.kt`; iOS has `AppDelegate.swift` plus the Flutter runner project.
   - Android resource files for file paths, locale config, and network security config suggest real device integration concerns like file sharing, locale support, and network policy.

10. **Library import and scanning**
    - The app is not only a downloader; it also manages a local music library.
    - `local_library_scan_prefs.dart`, `library_scan.go`, `csv_import_service.dart`, and the various library screens show support for scanning folders, importing collections, and organizing tracks/albums/playlists locally.
    - These features connect downloaded content back into the app’s browsing and playback surfaces.

11. **Playback, notifications, and sharing**
    - `playback_provider.dart` coordinates in-app playback state, while `notification_service.dart` and `share_intent_service.dart` handle mobile OS interactions.
    - `shell_navigation_service.dart` suggests cross-screen navigation is also abstracted for use outside direct widget context.
    - These services are infrastructure-like and keep platform behavior out of presentation code.

12. **Settings, onboarding, and operational controls**
    - The settings area is unusually broad: appearance, download behavior, provider priorities, lyrics/metadata priorities, extension settings, cache management, logs, and about/donate pages.
    - `setup_screen.dart` and `tutorial_screen.dart` indicate first-run onboarding, likely for repository URL entry and initial configuration.
    - This section acts as the control plane for how the engine behaves.

13. **Internationalization and theming**
    - The app is localized through `lib/l10n` with many generated language files and ARB sources.
    - Theme handling is separated into `theme/` plus dynamic color support, so UI appearance is a first-class subsystem rather than ad hoc styling.

14. **Build, release, and distribution**
    - GitHub Actions handle release tagging and GitHub Pages documentation deployment.
    - `site/` contains hosted docs/download pages, and `scripts/build_ios.sh` plus the iOS/Android native projects show this repo produces real mobile binaries rather than just a Dart package.
    - `apps.json` suggests the project also integrates with third-party app stores such as AltStore/SideStore.

15. **High-level data flow**
    - User actions start in Flutter screens, move through providers, then into the Go backend and platform bridge.
    - Results return as tracks, metadata, download progress, errors, and cached library updates, which then feed the UI and local databases.
    - The main architectural boundary is therefore: presentation/state in Flutter, execution/metadata/provider logic in Go, and device capabilities in native Android/iOS layers.

Main entry points: [`lib/providers`](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/providers) (Providers), [`go_backend`](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/go_backend) (Go engine), [`.github/workflows`](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/.github/workflows) (Release assets), [`lib/services/platform_bridge.dart`](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/services/platform_bridge.dart) (Platform bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flutter["Flutter app"]
  node_main_entry["App entry<br/>Flutter entrypoint<br/>[main.dart]"]
  node_app_boot["App boot<br/>Flutter app root<br/>[app.dart]"]
  node_main_shell["Main shell<br/>Navigation shell<br/>[main_shell.dart]"]
  node_primary_screens["Core screens<br/>UI flows"]
  node_settings_area["Settings area<br/>Settings UI"]
  node_widgets["UI widgets<br/>Reusable widgets"]
  node_providers["Providers<br/>State orchestration"]
  node_models[("Domain models<br/>Data models")]
  node_databases[("Local stores<br/>Persistence services")]
  node_platform_bridge["Platform bridge<br/>Device bridge"]
  node_download_payload["Download payload<br/>Transfer contract"]
  node_cover_cache[("Cover cache<br/>Cache layer")]
  node_theme_l10n["Theme & locale<br/>UI infrastructure"]
end

subgraph group_backend["Go backend"]
  node_go_core["Go engine<br/>Backend core"]
  node_extensions["Extensions<br/>Plugin runtime"]
  node_providers_backend["Music providers<br/>Source adapters<br/>[deezer.go]"]
  node_metadata_pipeline["Metadata pipeline<br/>Audio processing<br/>[metadata.go]"]
  node_library_scan["Library scan<br/>Import pipeline<br/>[library_scan.go]"]
end

subgraph group_native["Native hosts"]
  node_android_host["Android host<br/>Native Android"]
  node_ios_host["iOS host<br/>Native iOS"]
end

subgraph group_distribution["Build & release"]
  node_release_assets["Release assets<br/>Build & docs<br/>[workflows]"]
end

node_main_entry -->|"starts"| node_app_boot
node_app_boot -->|"hosts"| node_main_shell
node_main_shell -->|"navigates"| node_primary_screens
node_main_shell -->|"opens"| node_settings_area
node_primary_screens -->|"reads/writes"| node_providers
node_settings_area -->|"configures"| node_providers
node_providers -->|"uses"| node_models
node_providers -->|"persists"| node_databases
node_providers -->|"builds"| node_download_payload
node_providers -->|"invokes"| node_platform_bridge
node_providers -->|"calls"| node_go_core
node_go_core -->|"loads"| node_extensions
node_go_core -->|"queries"| node_providers_backend
node_go_core -->|"processes"| node_metadata_pipeline
node_go_core -->|"scans"| node_library_scan
node_go_core -->|"bridges"| node_platform_bridge
node_providers -->|"uses"| node_cover_cache
node_providers -->|"renders with"| node_theme_l10n
node_android_host -->|"implements"| node_platform_bridge
node_ios_host -->|"implements"| node_platform_bridge
node_release_assets -->|"packages"| node_android_host
node_release_assets -->|"packages"| node_ios_host
node_release_assets -->|"builds"| node_go_core
node_release_assets -->|"publishes"| node_theme_l10n

click node_main_entry "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/main.dart"
click node_app_boot "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/app.dart"
click node_main_shell "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/screens/main_shell.dart"
click node_primary_screens "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/screens"
click node_settings_area "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/screens/settings"
click node_widgets "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/widgets"
click node_providers "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/providers"
click node_models "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/models"
click node_databases "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/services"
click node_platform_bridge "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/services/platform_bridge.dart"
click node_download_payload "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/services/download_request_payload.dart"
click node_cover_cache "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/services/cover_cache_manager.dart"
click node_theme_l10n "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/theme"
click node_go_core "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/go_backend"
click node_extensions "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/extension_manager.go"
click node_providers_backend "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/deezer.go"
click node_metadata_pipeline "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/metadata.go"
click node_library_scan "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/library_scan.go"
click node_android_host "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/android/app/src/main"
click node_ios_host "https://github.com/spotiflacapp/spotiflac-mobile/tree/main/ios/Runner"
click node_release_assets "https://github.com/spotiflacapp/spotiflac-mobile/blob/main/.github/workflows"

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_main_entry,node_app_boot,node_main_shell,node_primary_screens,node_settings_area,node_widgets,node_providers,node_models,node_databases,node_platform_bridge,node_download_payload,node_cover_cache,node_theme_l10n toneBlue
class node_go_core,node_extensions,node_providers_backend,node_metadata_pipeline,node_library_scan toneAmber
class node_android_host,node_ios_host toneMint
class node_release_assets toneRose
```

## Components

### Flutter app

Cross-platform UI, state, persistence, and user flows.

- [App entry](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/main.dart): Flutter entrypoint · Bootstraps the mobile app and app shell. · `lib/main.dart`
- [App boot](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/app.dart): Flutter app root · Initial app wiring, dependencies, and top-level configuration. · `lib/app.dart`
- [Main shell](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/screens/main_shell.dart): Navigation shell · Primary navigation container for the app. · `lib/screens/main_shell.dart`
- [Core screens](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/screens): UI flows · Home, search, queue, repo/store, library, and media detail screens. · `lib/screens`
- [Settings area](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/screens/settings): Settings UI · Appearance, downloads, provider priorities, cache, logs, and onboarding-related settings screens. · `lib/screens/settings`
- [UI widgets](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/widgets): Reusable widgets · Shared UI building blocks for covers, dialogs, pickers, progress, and settings scaffolding. · `lib/widgets`
- [Providers](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/providers): State orchestration · Reactive coordination layer for downloads, playback, search, extensions, library, settings, and theme. · `lib/providers`
- [Domain models](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/models): Data models · Persisted and runtime entities such as tracks, downloads, settings, and theme state. · `lib/models`
- [Local stores](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/services): Persistence services · On-device databases and history/state storage used by the Flutter layer. · `lib/services`
- [Platform bridge](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/services/platform_bridge.dart): Device bridge · Flutter boundary for native capabilities like notifications, sharing, file access, and navigation helpers. · `lib/services/platform_bridge.dart`
- [Download payload](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/services/download_request_payload.dart): Transfer contract · Structured request data passed into the download pipeline. · `lib/services/download_request_payload.dart`
- [Cover cache](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/lib/services/cover_cache_manager.dart): Cache layer · Artwork caching and embedded cover resolution for offline media browsing. · `lib/services/cover_cache_manager.dart`
- [Theme & locale](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/lib/theme): UI infrastructure · Dynamic theming and localized string resources. · `lib/theme`

### Go backend

Download, metadata, provider, and extension engine.

- [Go engine](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/go_backend): Backend core · Main execution layer for downloads, metadata, provider access, and extension runtime. · `go_backend`
- [Extensions](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/extension_manager.go): Plugin runtime · Extension manager, manifests, runtime helpers, store integration, and provider prioritization. · `go_backend/extension_manager.go`
- [Music providers](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/deezer.go): Source adapters · Built-in and external service adapters for Deezer, Qobuz, Tidal, lyrics, and Song.link. · `go_backend/deezer.go`
- [Metadata pipeline](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/metadata.go): Audio processing · Metadata extraction, filename generation, duplicate checks, cover handling, CUE parsing, and progress reporting. · `go_backend/metadata.go`
- [Library scan](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/go_backend/library_scan.go): Import pipeline · Local library scanning and collection import logic. · `go_backend/library_scan.go`

### Native hosts

Android and iOS platform integration layers.

- [Android host](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/android/app/src/main): Native Android · Android activity, download service, and resource/configuration layer. · `android/app/src/main`
- [iOS host](https://github.com/spotiflacapp/spotiflac-mobile/tree/main/ios/Runner): Native iOS · iOS app delegate, runner project, and platform integration layer. · `ios/Runner`

### Build & release

Packaging, release, and hosted site assets.

- [Release assets](https://github.com/spotiflacapp/spotiflac-mobile/blob/main/.github/workflows): Build & docs · GitHub workflows, site pages, scripts, and alternate distribution metadata. · `.github/workflows`

## Connections

- App entry → App boot: starts · Entry point initializes the application root.
- App boot → Main shell: hosts · App root mounts the main navigation shell.
- Main shell → Core screens: navigates · Shell routes users into core app flows.
- Main shell → Settings area: opens · Shell exposes the settings/control plane.
- Core screens → Providers: reads/writes · Screens consume provider state and dispatch actions.
- Settings area → Providers: configures · Settings pages mutate provider-managed preferences and priorities.
- Providers → Domain models: uses · Providers exchange typed app state through shared models.
- Providers → Local stores: persists · State changes are written to local stores and history databases.
- Providers → Download payload: builds · Download actions are packaged into request payloads.
- Providers → Platform bridge: invokes · Provider actions reach platform-specific capabilities through the bridge.
- Providers → Go engine: calls · Heavy download and metadata work is delegated to the backend engine.
- Go engine → Extensions: loads · The backend hosts and coordinates extension execution.
- Go engine → Music providers: queries · Backend resolves external music and lyrics sources through adapters.
- Go engine → Metadata pipeline: processes · Audio files and metadata are normalized through the processing pipeline.
- Go engine → Library scan: scans · Backend imports and indexes local music libraries.
- Go engine → Platform bridge: bridges · Backend work depends on device/file capabilities exposed by Flutter host layers.
- Providers → Cover cache: uses · UI state and downloads consult cached cover/artwork assets.
- Providers → Theme & locale: renders with · UI presentation is controlled by theming and localization.
- Android host → Platform bridge: implements · Android exposes native services used by the Flutter layer.
- iOS host → Platform bridge: implements · iOS exposes native services used by the Flutter layer.
- Release assets → Android host: packages · Release tooling builds Android binaries and distribution artifacts.
- Release assets → iOS host: packages · Release tooling builds iOS binaries and distribution artifacts.
- Release assets → Go engine: builds · Release workflows include the Go backend in app builds.
- Release assets → Theme & locale: publishes · Docs and release assets support shipped app variants and localized content.
