How dante098t/music-app works
1. Overall shape
- This is an iOS music streaming app built in Swift/SwiftUI using an MVVM + Service layering style.
- The repo is organized around clear boundaries: Views for presentation, ViewModels for UI state/orchestration, Services for backend/audio/persistence operations, and Models for data structures.
2. App bootstrap and routing
- The entry point is doan_nhom6App.swift, with ContentView.swift acting as the top shell.
- Views/RootView.swift is the main route switchboard: it decides whether the user sees authentication, home, premium, artist, or admin areas based on session/app state.
- Managers/AppState.swift holds shared reactive state such as login/session and player-related global state.
3. Presentation layer by role
- The UI is split into role-driven surfaces:
- Auth: LoginView, ResigterView
- Standard user/home: HomeView, SideMenuView, ProfileView
- Player: PlayerView, QueueView, AlbumDetailView, RecentlyPlayedView, FavoriteSongsView
- Premium: PremiumHomeView, PremiumView, PremiumPlayerView, SearchResultView
- Artist: ArtistDashboardView
- Admin: AdminView
- This suggests the app is not just a consumer player; it has separate operational surfaces for users, creators, and platform staff.
4. Reusable UI components
- The Components folder contains small reusable UI pieces such as AlbumCard, SongCard, PremiumBanner, and AnimatedBackgroundView.
- These are visual building blocks used across multiple screens to keep the larger views thin and consistent.
5. ViewModels as the orchestration layer
- The ViewModels folder contains the stateful bridge between SwiftUI and services:
- AuthViewModel for sign-in/sign-up flows
- HomeViewModel for feed/discovery content
- PlayerViewModel for playback state and queue control
- SongViewModel for track-level data shaping
- SideMenuViewModel for navigation/menu state
- In diagram terms, these are the main consumer of services and the main source of data binding into the UI.
6. Service layer and domain operations
- The Services folder is the business/integration layer. Key services include:
- AuthService / AuthManager for authentication and session handling
- SupabaseService as the backend client gateway
- SongService, ArtistService, PlaylistService for catalog/content retrieval
- AudioPlayerService for actual playback
- StorageService for media asset storage access
- AnalyticsService for reports/metrics
- FavoriteAlbumService, RecentlyPlayedService, and related managers for user interaction history
- This layer is where most cross-cutting logic lives, keeping the views and view models relatively clean.
7. Playback pipeline
- Audio playback is handled through AVFoundation via AudioPlayerService.
- The data path is typically: UI interaction → PlayerViewModel → AudioPlayerService → remote audio asset fetched through storage/backend.
- QueueView, PlayerListView, and PremiumPlayerView indicate the app supports structured playback control, not just single-track streaming.
8. Local persistence and offline-friendly data
- The app includes Core Data via Persistence.swift and the doan_nhom6.xcdatamodeld model.
- This is used for locally retaining user-centric data such as favorites and recently played items, through managers like FavoriteManager and RecentlyPlayedManager.
- The local store acts as an offline-resilient cache for interaction history and preferences, separate from the cloud catalog.
9. Cloud backend and storage
- The backend is Supabase with PostgreSQL, accessed through SupabaseService.
- The app appears to use Supabase for:
- Authentication/session management
- Catalog and relational data queries
- Role-based access control for standard users, premium users, artists, and admins
- Storage-backed media assets through StorageService
- This is the main external system boundary in the architecture.
10. Domain model layer
- The Models folder contains the app’s core entities: Song, Album, Artist, Playlist, Profile, Subscription, Report, Analytics, FavoriteAlbum, RecentlyPlayed, User.
- These models mirror both backend records and local app state, giving the app a shared vocabulary across UI, services, and persistence.
- They are important for any architecture diagram because they sit between cloud data, Core Data, and view models.
11. Admin, artist, and premium business sub-systems
- The presence of AdminView / AdminViewModel, ArtistDashboardView, and premium-specific views indicates separate business flows:
- Admin: moderation, catalog governance, reporting, analytics
- Artist: dashboard-style content/insight access
- Premium: subscription-gated playback and discovery
- These are not separate apps, but separate feature boundaries inside the same client.
12. Key architectural flow to draw
- A good diagram would show:
- SwiftUI views at the top
- ViewModels in the middle
- Services below them
- Supabase/PostgreSQL + Storage on one side as remote infrastructure
- Core Data on the other side as local persistence
- AVFoundation as the playback engine behind AudioPlayerService
- The most important data movement is: user action → View → ViewModel → Service → backend/local store/audio engine → updated state back to UI.
Main entry points: RootView.swift Root view · PlayerViewModel.swift Player VM · SupabaseService.swift Supabase · Song.swift Domain models
Components 29
Presentation
SwiftUI screens and reusable UI components
- Root view · Top-level route switchboard for auth, home, premium, artist, and admin areas
doan_nhom6/Views/RootView.swift - Content view · Primary app container view
doan_nhom6/ContentView.swift - Admin VM · Supports admin dashboard workflows
doan_nhom6/Views/Admin/AdminViewModel.swift - Login · Sign-in screen
doan_nhom6/Views/Auth /LoginView.swift - Register · Account creation screen
doan_nhom6/Views/Auth /ResigterView.swift - Home · Primary user home screen
doan_nhom6/Views/Home/HomeView.swift - Side menu · App navigation drawer and shortcuts
doan_nhom6/Views/Home/SideMenuView.swift - Player · Now-playing controls and track playback UI
doan_nhom6/Views/Player/PlayerView.swift - Queue · Playback queue and upcoming tracks
doan_nhom6/Views/Player/QueueView.swift - Premium home · Premium user landing and subscription-facing UI
doan_nhom6/Views/User Premium/PremiumHomeView.swift - Admin · Administrative operations and moderation surface
doan_nhom6/Views/Admin/AdminView.swift - Artist dash · Creator dashboard surface
doan_nhom6/Views/Artist /ArtistDashboardView.swift
Orchestration
App state and view models that coordinate UI flow
- App entry · Bootstraps the application and initial environment
doan_nhom6/doan_nhom6App.swift - App state · Global reactive app and player state
doan_nhom6/Managers/AppState.swift - Auth VM · Coordinates sign-in and registration flows
doan_nhom6/ViewModels/AuthViewModel.swift - Home VM · Drives home feed and discovery state
doan_nhom6/ViewModels/HomeViewModel.swift - Player VM · Controls playback state and queue orchestration
doan_nhom6/ViewModels/PlayerViewModel.swift - Menu VM · Handles side menu and navigation state
doan_nhom6/ViewModels/SideMenuViewModel.swift - Song VM · Shapes track-level song data for the UI
doan_nhom6/ViewModels/SongViewModel.swift
Services
Backend, playback, and persistence integrations
- Auth service · Authentication and session management
doan_nhom6/Services/AuthService.swift - Supabase · Client gateway to cloud data and auth
doan_nhom6/Services/SupabaseService.swift - Audio engine · AVFoundation-backed audio playback
doan_nhom6/Services/AudioPlayerService.swift - Catalog services · Song, artist, and playlist retrieval
doan_nhom6/Services/SongService.swift - Storage · Remote media asset access
doan_nhom6/Services/StorageService.swift - Analytics · Metrics and reporting operations
doan_nhom6/Services/AnalyticsService.swift - Favorites · Favorite album and song interaction logic
doan_nhom6/Services/FavoriteManager.swift - Recents · Recently played tracking and retrieval
doan_nhom6/Services/RecentlyPlayedManager.swift
Data
Domain models and local persistence
- Core Data · Local persistence layer and data model container
doan_nhom6/Persistence.swift - Domain models · Songs, albums, artists, playlists, profiles, subscriptions, reports, and history models
doan_nhom6/Models/Song.swift
Connections 32
- App entry → Content view: launches · App bootstraps the main content shell
- Content view → Root view: hosts · Content view embeds the route switchboard
- Root view → Login: routes to · Shows auth flow when session is missing
- Root view → Home: routes to · Shows standard user home area
- Root view → Premium home: routes to · Shows premium experience
- Root view → Artist dash: routes to · Shows artist dashboard surface
- Root view → Admin: routes to · Shows admin surface
- Root view → App state: reads state · Uses global session and player state for routing
- Login → Auth VM: binds to · Login UI is driven by auth view model
- Register → Auth VM: binds to · Registration UI is driven by auth view model
- Home → Home VM: binds to · Home screen consumes discovery and feed state
- Home → Menu VM: uses · Home screen integrates navigation menu state
- Player → Player VM: binds to · Player UI is controlled by playback view model
- Queue → Player VM: binds to · Queue UI shares playback state
- Premium home → Player VM: uses · Premium playback views reuse the player orchestration
- Admin → Admin VM: binds to · Admin UI is backed by admin-specific orchestration
- Artist dash → Analytics: uses · Artist surface consumes reporting and insight data
- Auth VM → Auth service: calls · Authentication flow delegates to auth service
- Auth service → Supabase: uses · Auth operations go through the cloud gateway
- Home VM → Catalog services: calls · Home content comes from catalog services
- Song VM → Catalog services: calls · Song shaping depends on catalog data
- Player VM → Audio engine: controls · Playback state drives the audio engine
- Audio engine → Storage: streams from · Audio engine fetches media assets from storage
- Catalog services → Supabase: queries · Catalog data is sourced from backend records
- Analytics → Supabase: reports to · Analytics data is stored or fetched through the backend
- Favorites → Core Data: stores · Favorites are retained locally
- Recents → Core Data: stores · Recently played history is retained locally
- Core Data → Domain models: persists · Core Data stores domain entities
- Supabase → Domain models: serves · Backend data maps to shared domain entities
- App state → Player VM: shares state · Global player state feeds playback orchestration
- Home VM → Domain models: uses · Home state is shaped from domain models
- Player VM → Domain models: uses · Playback state references song and queue models