# yisuspineapple/nexo architecture

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

- Interactive diagram: https://gitdiagram.com/yisuspineapple/nexo
- Repository: https://github.com/yisuspineapple/nexo

## Overview

#### Purpose and runtime
Nexo is a Flutter-based, offline local-music player targeting Android, Linux, and Windows, with low-memory operation as a primary constraint. Flutter starts at `lib/main.dart`; native platform launchers host it through `android/app/src/main/kotlin/io/github/yisus/nexo/MainActivity.kt`, `linux/runner/main.cc`, and `windows/runner/main.cpp`.

#### Presentation and application composition
The UI is organized around Flutter screens and provider-based state/dependency wiring. `lib/presentation/screens/home_shell.dart` is the application shell; major flows include library, search, queue, now-playing, settings, onboarding, and recommendations. Providers bridge UI state to repositories and use cases, notably `lib/presentation/providers/repository_providers.dart`, `lib/presentation/providers/playback_providers.dart`, and `lib/presentation/providers/library_providers.dart`.

#### Domain boundary
Business rules are isolated behind domain entities, repository contracts, value IDs, and use cases. The UI should invoke use cases rather than persistence or audio implementations directly. Core flows include directory indexing, playback/queue control, session recovery, library search, backups, and metrics:
`lib/domain/usecases/index_directories_usecase.dart`,
`lib/domain/usecases/play_queue_usecase.dart`,
`lib/domain/usecases/restore_session_usecase.dart`.
Repository interfaces in `lib/domain/repositories/` separate these flows from local implementations.

#### Local library ingestion
The library pipeline discovers user-selected folders, excludes configured paths, scans audio files, reads metadata, then persists normalized songs and library state. Source adapters are `lib/data/sources/audio_file_scanner.dart` and `lib/data/sources/song_metadata_reader.dart`; orchestration is centered on `lib/domain/usecases/refresh_library_usecase.dart` and `lib/data/repositories/song_repository_impl.dart`. There is no indicated remote catalog or cloud dependency.

#### Persistence and data mapping
A local generated database is the durable system of record for songs, folders, playlists, history, queues, settings, preferences, and active sessions. Its schema/database boundary is in `lib/data/local/app_database.dart`, generated support in `lib/data/local/app_database.g.dart`, and tables such as `lib/data/local/tables/songs_table.dart` and `lib/data/local/tables/active_session_table.dart`. Mappers and converters translate database representations to domain entities, preventing storage types from leaking upward.

#### Playback subsystem
Playback is split between a domain-facing audio-player contract and concrete audio/background-handler implementation. `lib/data/audio/audio_player_repository_impl.dart` adapts playback operations, while `lib/data/audio/nexo_audio_handler.dart` is the likely media-session/background integration boundary. Queue and playback state persist through `lib/data/repositories/playback_repository_impl.dart`; domain use cases manage play, reorder, shuffle, settings updates, errors, and restoration.

#### User-derived features and content
Lyrics are read and parsed locally through `lib/data/repositories/lyrics_repository_impl.dart` and `lib/data/sources/lyrics_parser.dart`. Offline listening data feeds “For You” and statistics via `lib/data/repositories/user_metrics_repository_impl.dart`, `lib/domain/usecases/user_metrics_usecases.dart`, and `lib/presentation/providers/for_you_provider.dart`. Backup/restore is encapsulated separately in `lib/data/repositories/backup_repository_impl.dart` and `lib/domain/usecases/backup_usecases.dart`.

#### Infrastructure
Build targets are Android Gradle (`android/build.gradle.kts`) and native Flutter desktop runners (`linux/CMakeLists.txt`, `windows/CMakeLists.txt`). CI is defined in `.github/workflows/build.yml`. The application is designed around device-local files, local database storage, and OS audio/media services rather than external network services.

Main entry points: [`lib/presentation/screens/home_shell.dart`](https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/screens/home_shell.dart) (Home shell), [`lib/data/repositories/song_repository_impl.dart`](https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/song_repository_impl.dart) (Song repository), [`lib/main.dart`](https://github.com/yisuspineapple/nexo/blob/main/lib/main.dart) (Flutter entry), [`lib/data/local/app_database.dart`](https://github.com/yisuspineapple/nexo/blob/main/lib/data/local/app_database.dart) (Local database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime hosts"]
  node_flutter_entry["Flutter entry<br/>Flutter bootstrap<br/>[main.dart]"]
  node_android_host["Android host<br/>native launcher<br/>[MainActivity.kt]"]
  node_linux_host["Linux host<br/>native launcher<br/>[main.cc]"]
  node_windows_host["Windows host<br/>native launcher<br/>[main.cpp]"]
end

subgraph group_presentation["Flutter presentation"]
  node_app_shell["Home shell<br/>screen shell<br/>[home_shell.dart]"]
  node_providers["Provider wiring<br/>state and DI"]
  node_playback_providers["Playback providers<br/>UI state"]
  node_library_providers["Library providers<br/>UI state"]
  node_for_you_provider["For You provider<br/>recommendation state"]
end

subgraph group_domain["Domain"]
  node_repository_contracts{{"Repository contracts<br/>domain ports"}}
  node_library_usecases["Library indexing<br/>use cases"]
  node_playback_usecases["Queue and playback<br/>use cases"]
  node_session_restore["Session recovery<br/>use case"]
end

subgraph group_data["Local data and playback"]
  node_song_repository["Song repository<br/>local repository"]
  node_audio_scanner["Audio file scanner<br/>file source"]
  node_metadata_reader["Metadata reader<br/>file source"]
  node_app_database[("Local database<br/>generated database<br/>[app_database.dart]")]
  node_playback_repository["Playback repository<br/>local repository"]
  node_audio_player["Audio player adapter<br/>audio repository"]
  node_audio_handler["Media session handler<br/>background audio"]
  node_lyrics_repository["Lyrics repository<br/>local repository"]
  node_lyrics_parser["Lyrics parser<br/>local parser<br/>[lyrics_parser.dart]"]
  node_metrics_repository["User metrics<br/>local repository"]
  node_backup_repository["Backup and restore<br/>local repository"]
end

subgraph group_platform["Device and platform"]
  node_music_folders["User music folders<br/>device files"]
  node_os_media["OS media services<br/>platform service"]
end

node_android_host -->|"hosts"| node_flutter_entry
node_linux_host -->|"hosts"| node_flutter_entry
node_windows_host -->|"hosts"| node_flutter_entry
node_flutter_entry -->|"starts"| node_app_shell
node_app_shell -->|"uses"| node_providers
node_app_shell -->|"uses"| node_playback_providers
node_app_shell -->|"uses"| node_library_providers
node_app_shell -->|"uses"| node_for_you_provider
node_providers -->|"binds"| node_repository_contracts
node_library_providers -->|"invokes"| node_library_usecases
node_playback_providers -->|"invokes"| node_playback_usecases
node_playback_providers -->|"restores"| node_session_restore
node_for_you_provider -->|"reads"| node_metrics_repository
node_library_usecases -->|"depends on"| node_repository_contracts
node_playback_usecases -->|"depends on"| node_repository_contracts
node_session_restore -->|"depends on"| node_repository_contracts
node_repository_contracts -.->|"implemented by"| node_song_repository
node_repository_contracts -.->|"implemented by"| node_playback_repository
node_repository_contracts -.->|"implemented by"| node_audio_player
node_song_repository -->|"scans with"| node_audio_scanner
node_song_repository -->|"reads metadata with"| node_metadata_reader
node_audio_scanner -->|"discovers files"| node_music_folders
node_metadata_reader -->|"reads tags"| node_music_folders
node_song_repository -->|"persists library"| node_app_database
node_playback_repository -->|"persists state"| node_app_database
node_metrics_repository -->|"derives from history"| node_app_database
node_backup_repository -->|"exports and restores"| node_app_database
node_lyrics_repository -->|"parses with"| node_lyrics_parser
node_audio_player -->|"delegates media session"| node_audio_handler
node_audio_handler -->|"integrates with"| node_os_media

click node_flutter_entry "https://github.com/yisuspineapple/nexo/blob/main/lib/main.dart"
click node_android_host "https://github.com/yisuspineapple/nexo/blob/main/android/app/src/main/kotlin/io/github/yisus/nexo/MainActivity.kt"
click node_linux_host "https://github.com/yisuspineapple/nexo/blob/main/linux/runner/main.cc"
click node_windows_host "https://github.com/yisuspineapple/nexo/blob/main/windows/runner/main.cpp"
click node_app_shell "https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/screens/home_shell.dart"
click node_providers "https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/repository_providers.dart"
click node_playback_providers "https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/playback_providers.dart"
click node_library_providers "https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/library_providers.dart"
click node_for_you_provider "https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/for_you_provider.dart"
click node_library_usecases "https://github.com/yisuspineapple/nexo/blob/main/lib/domain/usecases/refresh_library_usecase.dart"
click node_playback_usecases "https://github.com/yisuspineapple/nexo/blob/main/lib/domain/usecases/play_queue_usecase.dart"
click node_session_restore "https://github.com/yisuspineapple/nexo/blob/main/lib/domain/usecases/restore_session_usecase.dart"
click node_song_repository "https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/song_repository_impl.dart"
click node_audio_scanner "https://github.com/yisuspineapple/nexo/blob/main/lib/data/sources/audio_file_scanner.dart"
click node_metadata_reader "https://github.com/yisuspineapple/nexo/blob/main/lib/data/sources/song_metadata_reader.dart"
click node_app_database "https://github.com/yisuspineapple/nexo/blob/main/lib/data/local/app_database.dart"
click node_playback_repository "https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/playback_repository_impl.dart"
click node_audio_player "https://github.com/yisuspineapple/nexo/blob/main/lib/data/audio/audio_player_repository_impl.dart"
click node_audio_handler "https://github.com/yisuspineapple/nexo/blob/main/lib/data/audio/nexo_audio_handler.dart"
click node_lyrics_repository "https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/lyrics_repository_impl.dart"
click node_lyrics_parser "https://github.com/yisuspineapple/nexo/blob/main/lib/data/sources/lyrics_parser.dart"
click node_metrics_repository "https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/user_metrics_repository_impl.dart"
click node_backup_repository "https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/backup_repository_impl.dart"

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_flutter_entry,node_android_host,node_linux_host,node_windows_host toneBlue
class node_app_shell,node_providers,node_playback_providers,node_library_providers,node_for_you_provider toneAmber
class node_repository_contracts,node_library_usecases,node_playback_usecases,node_session_restore toneMint
class node_song_repository,node_audio_scanner,node_metadata_reader,node_app_database,node_playback_repository,node_audio_player,node_audio_handler,node_lyrics_repository,node_lyrics_parser,node_metrics_repository,node_backup_repository toneRose
class node_music_folders,node_os_media toneIndigo
```

## Components

### Runtime hosts

- [Flutter entry](https://github.com/yisuspineapple/nexo/blob/main/lib/main.dart): Flutter bootstrap · `lib/main.dart`
- [Android host](https://github.com/yisuspineapple/nexo/blob/main/android/app/src/main/kotlin/io/github/yisus/nexo/MainActivity.kt): native launcher · `android/app/src/main/kotlin/io/github/yisus/nexo/MainActivity.kt`
- [Linux host](https://github.com/yisuspineapple/nexo/blob/main/linux/runner/main.cc): native launcher · `linux/runner/main.cc`
- [Windows host](https://github.com/yisuspineapple/nexo/blob/main/windows/runner/main.cpp): native launcher · `windows/runner/main.cpp`

### Flutter presentation

- [Home shell](https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/screens/home_shell.dart): screen shell · Hosts library, search, queue, player, settings, onboarding, and recommendations flows. · `lib/presentation/screens/home_shell.dart`
- [Provider wiring](https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/repository_providers.dart): state and DI · `lib/presentation/providers/repository_providers.dart`
- [Playback providers](https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/playback_providers.dart): UI state · `lib/presentation/providers/playback_providers.dart`
- [Library providers](https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/library_providers.dart): UI state · `lib/presentation/providers/library_providers.dart`
- [For You provider](https://github.com/yisuspineapple/nexo/blob/main/lib/presentation/providers/for_you_provider.dart): recommendation state · `lib/presentation/providers/for_you_provider.dart`

### Domain

- **Repository contracts**: domain ports
- [Library indexing](https://github.com/yisuspineapple/nexo/blob/main/lib/domain/usecases/refresh_library_usecase.dart): use cases · Indexes directories and refreshes the local library. · `lib/domain/usecases/refresh_library_usecase.dart`
- [Queue and playback](https://github.com/yisuspineapple/nexo/blob/main/lib/domain/usecases/play_queue_usecase.dart): use cases · Controls queue playback and session recovery. · `lib/domain/usecases/play_queue_usecase.dart`
- [Session recovery](https://github.com/yisuspineapple/nexo/blob/main/lib/domain/usecases/restore_session_usecase.dart): use case · `lib/domain/usecases/restore_session_usecase.dart`

### Local data and playback

- [Song repository](https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/song_repository_impl.dart): local repository · Orchestrates scanning, metadata extraction, and normalized song storage. · `lib/data/repositories/song_repository_impl.dart`
- [Audio file scanner](https://github.com/yisuspineapple/nexo/blob/main/lib/data/sources/audio_file_scanner.dart): file source · `lib/data/sources/audio_file_scanner.dart`
- [Metadata reader](https://github.com/yisuspineapple/nexo/blob/main/lib/data/sources/song_metadata_reader.dart): file source · `lib/data/sources/song_metadata_reader.dart`
- [Local database](https://github.com/yisuspineapple/nexo/blob/main/lib/data/local/app_database.dart): generated database · System of record for library, queues, settings, history, and sessions. · `lib/data/local/app_database.dart`
- [Playback repository](https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/playback_repository_impl.dart): local repository · Persists queue and playback state. · `lib/data/repositories/playback_repository_impl.dart`
- [Audio player adapter](https://github.com/yisuspineapple/nexo/blob/main/lib/data/audio/audio_player_repository_impl.dart): audio repository · `lib/data/audio/audio_player_repository_impl.dart`
- [Media session handler](https://github.com/yisuspineapple/nexo/blob/main/lib/data/audio/nexo_audio_handler.dart): background audio · `lib/data/audio/nexo_audio_handler.dart`
- [Lyrics repository](https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/lyrics_repository_impl.dart): local repository · `lib/data/repositories/lyrics_repository_impl.dart`
- [Lyrics parser](https://github.com/yisuspineapple/nexo/blob/main/lib/data/sources/lyrics_parser.dart): local parser · `lib/data/sources/lyrics_parser.dart`
- [User metrics](https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/user_metrics_repository_impl.dart): local repository · Derives listening metrics for offline recommendations. · `lib/data/repositories/user_metrics_repository_impl.dart`
- [Backup and restore](https://github.com/yisuspineapple/nexo/blob/main/lib/data/repositories/backup_repository_impl.dart): local repository · `lib/data/repositories/backup_repository_impl.dart`

### Device and platform

- **User music folders**: device files
- **OS media services**: platform service

## Connections

- Android host → Flutter entry: hosts
- Linux host → Flutter entry: hosts
- Windows host → Flutter entry: hosts
- Flutter entry → Home shell: starts
- Home shell → Provider wiring: uses
- Home shell → Playback providers: uses
- Home shell → Library providers: uses
- Home shell → For You provider: uses
- Provider wiring → Repository contracts: binds
- Library providers → Library indexing: invokes
- Playback providers → Queue and playback: invokes
- Playback providers → Session recovery: restores
- For You provider → User metrics: reads
- Library indexing → Repository contracts: depends on
- Queue and playback → Repository contracts: depends on
- Session recovery → Repository contracts: depends on
- Repository contracts → Song repository: implemented by
- Repository contracts → Playback repository: implemented by
- Repository contracts → Audio player adapter: implemented by
- Song repository → Audio file scanner: scans with
- Song repository → Metadata reader: reads metadata with
- Audio file scanner → User music folders: discovers files
- Metadata reader → User music folders: reads tags
- Song repository → Local database: persists library
- Playback repository → Local database: persists state
- User metrics → Local database: derives from history
- Backup and restore → Local database: exports and restores
- Lyrics repository → Lyrics parser: parses with
- Audio player adapter → Media session handler: delegates media session
- Media session handler → OS media services: integrates with
