How watermelon-music/watermelon-exe works
Purpose and Entry Point
Watermelon Music Desktop is a Kotlin/Compose for Desktop Windows music client. It searches a remote music catalog, resolves YouTube audio streams for native playback, presents library/radio/profile/premium experiences, and syncs account data with Supabase. Application startup and window composition begin at src/main/kotlin/com/watermelon/music/Main.kt; Gradle packages the native desktop distribution via build.gradle.kts.
UI, Navigation, and State
Compose screens are organized by product area, with ViewModels mediating user actions and UI state. Navigation is centralized in src/main/kotlin/com/watermelon/music/navigation/NavController.kt. Primary user surfaces include discovery/home (ui/home/HomeScreen.kt), search (ui/search/SearchScreen.kt), library (ui/library/LibraryScreen.kt), and radio (ui/radio/RadioScreen.kt). Authentication has an independent screen and state flow rooted in ui/auth/AuthViewModel.kt.
Catalog Discovery and Remote APIs
src/main/kotlin/com/watermelon/music/data/repository/MusicCatalogRepository.kt is the catalog boundary used to retrieve search metadata, stream-related information, and lyrics/subtitles. It integrates the Watermelon/Render-facing API contract in data/remote/WatermelonApi.kt, radio discovery through data/remote/RadioBrowserApi.kt, and Retrofit client construction in data/remote/RetrofitModule.kt. Remote DTOs are isolated in data/remote/WatermelonModels.kt before presentation/domain use.
Stream Resolution and Playback
Playback is separated from catalog lookup. src/main/kotlin/com/watermelon/music/data/remote/youtube/LocalAudioExtractor.kt and YouTubeDownloader.kt resolve YouTube or YouTube Music content into playable audio stream URLs. src/main/kotlin/com/watermelon/music/player/AudioPlayer.kt owns native/system audio output and background-capable playback. Player UI and shared playback state are represented by ui/player/PlayerViewModel.kt, with compact and immersive views in ui/player/MiniPlayer.kt and ui/player/FullScreenPlayerScreen.kt.
Account, Sync, and User Entitlements
Supabase is the account and synchronized-data boundary. src/main/kotlin/com/watermelon/music/data/SupabaseModule.kt initializes the client, while AuthRepository.kt handles authentication, profiles/display-picture storage, and user-associated synchronization. Library behavior is concentrated in LibraryEngine.kt; engagement and premium rules are isolated in GamificationEngine.kt and PremiumManager.kt. This keeps backend-account concerns outside Compose screens.
Domain and Cross-Layer Data Flow
Core app models are in src/main/kotlin/com/watermelon/music/domain/model/Song.kt, Category.kt, and Country.kt. Typical control flow is: Compose screen → ViewModel → repository/engine → remote API or Supabase → state update → screen recomposition. For playback: search/catalog selection → YouTube stream extraction → AudioPlayer → player UI state; lyrics fetched through the catalog are rendered in the full-screen player.
Runtime and External Dependencies
The material runtime is JVM/Kotlin with Compose for Desktop, packaged for the current OS through Gradle. External services are the Watermelon/Render metadata and lyrics endpoints, YouTube-derived stream sources, Radio Browser, and Supabase Auth/PostgreSQL/Storage. Release automation is defined at .github/workflows/release.yml.
Main entry points: MusicCatalogRepository.kt Music catalog repository · NavController.kt Navigation controller · LocalAudioExtractor.kt YouTube stream extractor · Main.kt Application entry
Components 21
Desktop app
- Gradle distribution · Packages the native desktop distribution.
build.gradle.kts - Application entry · Starts the Compose desktop window.
src/main/kotlin/com/watermelon/music/Main.kt
Compose UI
- Navigation controller
src/main/kotlin/com/watermelon/music/navigation/NavController.kt - Product screens · Home, search, library, and radio surfaces.
- Auth ViewModel · Owns authentication screen state.
Data and services
- Music catalog repository · Catalog, stream metadata, and lyrics boundary.
src/main/kotlin/com/watermelon/music/data/repository/MusicCatalogRepository.kt - Watermelon API · Metadata and lyrics contract for the Watermelon/Render service.
- Radio Browser API · Radio discovery source.
- Retrofit module
- Auth repository · Authentication, profiles, storage, and account sync boundary.
- Supabase module
src/main/kotlin/com/watermelon/music/data/SupabaseModule.kt - Library engine · Concentrates library behavior.
- Premium and engagement · Gamification and premium entitlement rules.
Playback
- Player ViewModel · Shares playback state with player views.
- Player views · Mini player and full-screen player render playback and lyrics.
- YouTube stream extractor · Resolves YouTube content into playable audio URLs.
src/main/kotlin/com/watermelon/music/data/remote/youtube/LocalAudioExtractor.kt - Audio player · Owns native audio output and background playback.
src/main/kotlin/com/watermelon/music/player/AudioPlayer.kt
External systems
- Watermelon / Render · Remote catalog metadata and lyrics endpoints.
- YouTube sources · Derived audio stream source.
- Radio Browser
- Supabase · Auth, PostgreSQL, and Storage.
Connections 23
- Gradle distribution → Application entry: packages
- Application entry → Navigation controller: composes
- Navigation controller → Product screens: routes
- Navigation controller → Auth ViewModel: auth flow
- Product screens → Music catalog repository: catalog actions
- Product screens → Library engine: library actions
- Product screens → Premium and engagement: premium state
- Auth ViewModel → Auth repository: sign-in actions
- Music catalog repository → Watermelon API: metadata and lyrics
- Music catalog repository → Radio Browser API: radio discovery
- Retrofit module → Watermelon API: client
- Retrofit module → Radio Browser API: client
- Watermelon API → Watermelon / Render: requests
- Radio Browser API → Radio Browser: requests
- Auth repository → Supabase module: uses
- Supabase module → Supabase: connects
- Library engine → Auth repository: syncs user library
- Music catalog repository → YouTube stream extractor: selected content
- YouTube stream extractor → YouTube sources: resolves streams
- YouTube stream extractor → Audio player: playable URL
- Audio player → Player ViewModel: playback state
- Player ViewModel → Player views: renders state
- Music catalog repository → Player views: lyrics