How ahmedzayan7920/music-vibe works
Project Type & Purpose
• Music Vibe is a cross-platform (iOS, Android, Web, macOS, Windows, Linux) mobile/desktop music player built with Flutter.
• It uses the BLoC (Cubit) pattern for state management, a layered architecture for UI, business logic, data access, and platform-specific plugins to query and play audio files stored locally on the device.
File Structure Analysis
• Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web”: Host shells generated by Flutter, containing native code, assets, build scripts, and platform channels.
• “lib/”: The entire Flutter application code:
– core/: Dependency injection (DI), theming, failure handling, BLoC observer, extensions, song handler.
– logic/: Cubits (app, albums, artists, songs, favorites, playlists, folders, bottom navigation) and their states.
– repositories/: QueryRepository that wraps plugin calls.
– views/: UI screens and widgets, organized by feature (home, player, search, playlists, common UI elements).
– main.dart: Application entry point.
• local_plugins/on_audio_query_android/: A custom Flutter plugin for Android, exposing platform channels to query audio metadata (albums, artists, songs, genres, playlists, artwork).
README Insights
• Highlights key features: background playback, custom media-button actions, last-played-song memory, dynamic UI, and local storage access.
1. Flutter Application
• UI Layer: Widgets and Screens (lib/views/…)
• State Management: Cubits (lib/logic/…)
• Core Services: DI Container, Theming, Handlers (lib/core/…)
• Repositories: QueryRepository (lib/repositories/)
2. Platform Plugin
• on_audio_query (local_plugins/…): Android Kotlin code + iOS Swift counterpart (auto-generated on iOS/macOS)
3. Native Hosts
• Android (android/app), iOS (ios/Runner), Linux/MacOS/Windows runners
4. Device OS & File System
• Audio storage (filesystem)
• Audio playback service (media session, notification controls)
• UI → Cubits: User interactions (play, pause, search, navigate)
• Cubits → Repositories: State events trigger data access requests
• Repositories → Plugin: Query audio metadata via platform channel methods
• Plugin → Native Host → OS: Execute platform API calls to read file system, fetch metadata, control audio playback
• OS → Plugin → Repositories → Cubits → UI: Streaming audio file data, metadata responses, playback status updates
c. Architectural Patterns & Principles
• Layered Architecture: UI / State (presentation) → Business Logic (Cubits) → Data Access (Repositories) → Platform
• Dependency Injection: decoupling service creation via lib/core/di
• Single-Source-of-Truth: Cubit states represent UI state
• Platform-Channel Abstraction: QueryRepository hides native plugin implementation
d. Key Technologies & Frameworks
• Flutter & Dart
• flutter_bloc (Cubit)
• get_it or similar DI (lib/core/di/dependency_injection.dart)
• on_audio_query custom plugin (Kotlin for Android; Swift for iOS/macOS)
• Native platform channels for audio metadata & playback
Detail & Coverage
• DI container feeding Cubits & Repositories.
• Media button handler (lib/core/handlers/song_handler.dart) as part of core services interacting with native media button events.