How smrutiranjan-patra/wavetune works
1. What this repo is
- WaveTune is an Expo/React Native Android music player built for local device media. The README makes it clear the project is optimized for Expo Dev Client on Android, so native modules and Android permissions matter to the architecture.
2. App shell and navigation
- The app/ directory uses file-based routing with a tab layout at app/(tabs)/_layout.tsx.
- Primary surfaces are home, search, playlist, and settings, plus a nested library section with separate views for songs, albums, artists, folders, and genres.
- app/player.tsx is a distinct full-screen playback route, while components/MiniPlayer.tsx suggests a persistent lightweight player UI across the tab experience.
3. UI layer
- Reusable presentational components live in components/:
- Header, Button, SongCard, MiniPlayer
- These components are likely thin wrappers around store state and navigation actions; they should not own business logic.
- global.css, tailwind.config.js, and nativewind typings indicate the UI is styled with Tailwind/Nativ eWind rather than platform-specific styling code.
4. Global app composition
- app/_layout.tsx and providers/AppProvider.tsx are the main composition boundaries.
- The provider layer likely wires together app-wide stores, permissions, player initialization, and any startup side effects before screens render.
5. State management boundary
- store/ holds the app’s client state:
- app.store.ts
- library.store.ts
- player.store.ts
- settings.store.ts
- store/handlers/ suggests a separation between raw state and state-transition logic.
- In architecture terms, screens read from stores, while services and handlers update them.
6. Device media ingestion pipeline
- hooks/useMediaPermission.ts and services/library/permission.service.ts / services/scanner/permissions.ts handle Android media access.
- The flow is: permission check → scan local media → extract metadata → normalize → persist/update state.
- This is the key boundary between the Android device and the app’s internal library model.
7. Library scanning and normalization
- services/library/scanner.service.ts, services/scanner/scanner.service.ts, and services/media.service.ts indicate a scanning subsystem that reads device media and builds the app’s internal catalog.
- services/library/library.service.ts likely orchestrates the full library refresh process.
- helpers/library/* contains domain-specific helper transformations for songs, albums, artists, folders, and genres.
8. Metadata processing
- services/metadata/metadata.service.ts and services/metadata/parsers.ts are responsible for interpreting track metadata.
- services/library/metadata.service.ts connects metadata extraction to the library domain model.
- This subsystem is important because it turns raw device files into searchable, browsable entities like tracks, albums, and artists.
9. Persistence layer
- services/database/ is a repository-style persistence boundary with:
- database.service.ts
- songs.repository.ts
- albums.repository.ts
- artists.repository.ts
- This implies the app keeps a local indexed store for library entities rather than re-scanning on every screen render.
- The repositories are the only layer that should know the storage format; services and UI consume higher-level models.
10. Playback subsystem
- services/player/ is a dedicated playback domain:
- player.service.ts
- playback.service.ts
- queue.service.ts
- setup.service.ts
- mapper.ts
- player.types.ts
- index.ts
- The architecture suggests a split between:
- queue management,
- playback control,
- player initialization,
- and data mapping from library entities into playable items.
- store/player.store.ts likely mirrors the current track, queue, and playback status for the UI.
11. Search and browse flows
- services/search/search.service.ts likely queries the persisted library rather than scanning files directly.
- The library screens and search screen together form the main read path over the catalog:
- browse by entity type in library/*
- search by indexed metadata in search.tsx
- This is a clear separation: search/browse are consumers of the persisted library, not of raw device media.
12. Important runtime/infrastructure constraints
- The README shows this is meant to run in an Android Dev Client with Metro and ADB workflows.
- Because the app depends on device media access and likely native playback/permission behavior, native changes require expo prebuild --clean and expo run:android.
- That means the architecture has both a React Native UI/runtime layer and a device-integrated native boundary that affects deployment and iteration.
13. How data likely moves through the system
- On startup, the provider/layout bootstraps app state and player setup.
- After permissions are granted, the scanner reads device media, metadata is parsed, and entities are stored through database repositories.
- Stores are updated with the library snapshot, which feeds the tab screens, search, and player UI.
- When a song is selected, the player subsystem converts library items into queue entries and drives playback, while the mini-player and player screen reflect current playback state.
14. Architecture summary for diagramming
- You can model the app as four main layers:
- UI/navigation in app/ and components/
- state orchestration in store/ and providers/
- domain services for library, metadata, search, and playback
- device/native integration for permissions, scanning, and playback
- The most important boundary is between Android device media access and the normalized local music library that powers browsing, search, and playback.
Main entry points: player.service.ts Player service · library.store.ts Library store · AppProvider.tsx App provider · database.service.ts Database
Components 30
UI shell
File-based routes and reusable screens/components.
- Root layout · Bootstraps the app and composes global providers.
app/_layout.tsx - Tabs layout · Defines the main tab-based navigation surface.
app/(tabs)/_layout.tsx - Home · Primary landing screen for the music app.
app/(tabs)/home.tsx - Library layout · Nested library browsing routes.
app/(tabs)/library/_layout.tsx - Player · Full-screen playback route.
app/player.tsx - Mini player · Persistent compact playback UI.
components/MiniPlayer.tsx
State
App-wide stores and state transition logic.
- App provider · Wires startup state, permissions, and player setup.
providers/AppProvider.tsx - App store · Global app state container.
store/app.store.ts - Library store · Catalog state for songs, albums, artists, and browse views.
store/library.store.ts - Player store · Current track, queue, and playback status.
store/player.store.ts - Library handlers · State transition logic for library updates.
store/handlers/library.handlers.ts
Ingestion
Permission, scan, and metadata pipeline from Android media.
- Media permission · Requests or checks Android media access.
hooks/useMediaPermission.ts - Scanner permissions · Permission helpers used by the scanning pipeline.
services/scanner/permissions.ts - Scanner · Reads local device media into app-friendly records.
services/scanner/scanner.service.ts - Media source · Low-level access to device media content.
services/media.service.ts - Metadata · Extracts and parses track metadata.
services/metadata/metadata.service.ts
Library
Normalized catalog orchestration and helpers.
- Library service · Coordinates permission, scan, metadata, and persistence for refreshes.
services/library/library.service.ts - Library scanner · Library-domain scanning entrypoint.
services/library/scanner.service.ts - Library metadata · Maps extracted metadata into library entities.
services/library/metadata.service.ts - Song helpers · Transforms raw track data into library models.
helpers/library/songs.ts - Search · Queries the persisted library index.
services/search/search.service.ts
Persistence
Local database repositories and storage boundary.
- Database · Persistence boundary for the indexed library.
services/database/database.service.ts - Songs repo · Song persistence and retrieval.
services/database/songs.repository.ts - Albums repo · Album persistence and retrieval.
services/database/albums.repository.ts - Artists repo · Artist persistence and retrieval.
services/database/artists.repository.ts
Playback
Player initialization, queueing, and transport control.
- Player service · Coordinates playback behavior and player state.
services/player/player.service.ts - Queue · Builds and advances the play queue.
services/player/queue.service.ts - Playback control · Handles play, pause, skip, and other transport actions.
services/player/playback.service.ts - Player setup · Initializes native playback runtime.
services/player/setup.service.ts - Player mapper · Converts library entities to playable items.
services/player/mapper.ts
Connections 33
- Root layout → App provider: composes · Root composition wires global app services.
- Root layout → Tabs layout: hosts · Root layout renders the main navigation surface.
- Tabs layout → Home: routes to · Primary tab landing screen.
- Tabs layout → Library layout: routes to · Nested library navigation.
- Root layout → Player: routes to · Full-screen player route is mounted separately.
- Home → Mini player: uses · Home screen participates in persistent playback UI.
- Player → Player store: reads · Playback screen reflects current player state.
- Mini player → Player store: reads · Compact player reflects current playback state.
- App provider → App store: initializes · Global app state is prepared at startup.
- App provider → Media permission: requests · Provider coordinates media permission flow.
- App provider → Player setup: initializes · Provider prepares player runtime.
- Media permission → Scanner permissions: delegates to · Hook uses Android permission helpers.
- Scanner permissions → Scanner: unlocks · Permission checks gate scanning.
- Scanner → Media source: reads from · Scanner pulls local device media.
- Scanner → Metadata: parses with · Scanner enriches tracks with metadata.
- Metadata → Library metadata: feeds · Parsed metadata is adapted to library entities.
- Library service → Library scanner: orchestrates · Library refresh is coordinated through the library domain.
- Library scanner → Scanner: uses · Library scanner triggers the device scan.
- Library service → Database: persists to · Normalized catalog is written to local storage.
- Library metadata → Song helpers: normalizes · Library domain helpers shape song entities.
- Song helpers → Library store: updates · Normalized entities flow into library state.
- Database → Songs repo: exposes · Database boundary includes song repository.
- Database → Albums repo: exposes · Database boundary includes album repository.
- Database → Artists repo: exposes · Database boundary includes artist repository.
- Library store → Search: feeds · Search queries the persisted catalog state.
- Library store → Library handlers: mutates via · Library state changes are centralized in handlers.
- Player service → Queue: coordinates · Player core manages queue behavior.
- Player service → Playback control: drives · Core player delegates transport actions.
- Player service → Player mapper: maps through · Library items are converted to playable entries.
- Player service → Player store: updates · Playback state is mirrored into the store.
- Player service → Player setup: depends on · Player core relies on initialization.
- Search → Library store: queries · Search reads the indexed library model.
- Library layout → Library store: reads · Library browsing screens consume catalog state.