Podbelly is an ad-free, privacy-focused podcast player for Android. It is built entirely with Kotlin and Jetpack Compose, targets API 26+ (Android 8.0), and follows modern Android architecture conventions: multi-module Gradle project, MVVM with unidirectional data flow, Hilt dependency injection, and Media3 for playback.
The project is organized into three module layers: app, core, and feature.
| Module | Purpose |
|---|---|
app |
Application entry point, Hilt setup, Compose theme, navigation host, WorkManager workers |
core:database |
Room database, entities (PodcastEntity, EpisodeEntity, QueueItemEntity), DAOs |
core:network |
Retrofit iTunes Search API client, OkHttp-based RSS feed fetcher, RSS XML parser, OPML import/export |
core:playback |
Media3 MediaSessionService, PlaybackController singleton, PlaybackState data class, sleep timer |
core:common |
Shared utilities, user preferences (DataStore), date/duration formatting helpers |
feature:home |
Home screen showing recent and in-progress episodes |
feature:discover |
Podcast search and discovery powered by the iTunes Search API |
feature:podcast |
Subscribed podcast library grid, podcast detail screen with episode list |
feature:player |
Full-screen now-playing UI with seek bar, speed controls, skip-silence, and volume boost |
feature:queue |
Queue management screen with drag-to-reorder support |
feature:settings |
App settings, OPML import/export, download storage management |
app
/ | \ \
/ | \ \-----------\
v v v v
feature:* ... feature:* core:playback
| |
+------ core:database ------+
| |
+------ core:network -------+
|
+------ core:common --------+
Key rules:
appdepends on everyfeature:*andcore:*module.feature:*modules depend oncore:database,core:network,core:common, and occasionallycore:playback(e.g.,feature:player). Feature modules never depend on each other.core:*modules depend only oncore:common(and on each other where necessary, e.g.,core:playbackdepends oncore:databaseforQueueDao).
Each feature screen has a corresponding @HiltViewModel ViewModel that holds UI state
as a StateFlow and exposes action methods. Compose screens collect the state flow via
collectAsState() and call ViewModel methods in response to user interaction.
Room DAOs return Flow<List<T>> for observable queries. ViewModels transform and combine
these flows (using map, combine, flatMapLatest) and expose a single StateFlow of
screen-level UI state.
Hilt is the sole DI framework. Modules provide singletons for the Room database, Retrofit service, OkHttpClient, RssParser, and PlaybackController. ViewModels receive repositories and DAOs through constructor injection.
PodcastSearchRepository in core:network abstracts iTunes API calls and RSS feed
fetching behind a clean suspend-function API. Database DAOs serve as the repository layer
for local data, queried directly by ViewModels.
The Room database stores podcasts, episodes, and queue items. PodcastEntity and
EpisodeEntity are linked by a foreign key (podcastId) with cascade delete. Episodes
track playback position, download path, and played state to support resume and offline
playback.
A periodic Worker (scheduled via WorkManager) refreshes subscribed podcast feeds in the
background, fetching new episodes and inserting them into the Room database. This runs
even when the app is not in the foreground.
| Library | Purpose |
|---|---|
| Jetpack Compose + Material 3 | Declarative UI with Material You theming |
| Navigation Compose | Type-safe single-Activity navigation with bottom nav |
| Hilt | Compile-time dependency injection |
| Room | SQLite persistence with Flow-based reactive queries |
| Media3 (ExoPlayer) | Audio playback engine with MediaSessionService |
| Media3 Session | MediaController/MediaSession for system media integration |
| Retrofit + OkHttp | HTTP client for iTunes Search API |
| Coil | Async image loading for podcast artwork |
| Kotlin Coroutines + Flow | Asynchronous programming and reactive streams |
| WorkManager | Reliable background feed refresh scheduling |
| KSP | Annotation processing for Hilt and Room |
Data flows through the app in a single direction:
Network (iTunes API / RSS)
|
v
Repository / RssParser
|
v
Room Database (single source of truth)
|
v
DAO (returns Flow<T>)
|
v
ViewModel (transforms into UI StateFlow)
|
v
Compose UI (collectAsState, renders)
|
v
User Action --> ViewModel method --> Repository / DAO / PlaybackController
-
Discover flow: User searches ->
ItunesSearchApireturns results -> user subscribes ->PodcastSearchRepository.fetchFeed()fetches and parses the RSS XML -> podcast and episodes are inserted into Room. -
Refresh flow: WorkManager triggers periodic refresh -> for each subscribed podcast,
fetchFeed()is called -> new episodes are inserted, existing ones are updated. -
Playback flow: User taps an episode -> ViewModel calls
PlaybackController.play()-> controller builds aMediaItemwith metadata and sends it to theMediaController->PlaybackServicereceives it via theMediaSessionand starts ExoPlayer ->Player.Listenercallbacks updatePlaybackState-> Compose UI reacts to the new state.
Podbelly uses a single-Activity architecture with Jetpack Navigation Compose.
All routes are defined as a sealed class in Screen.kt:
| Route | Description |
|---|---|
home |
Home screen (start destination) |
discover |
Search and discover podcasts |
library |
Subscribed podcast grid |
queue |
Playback queue |
settings |
App settings |
podcast/{podcastId} |
Podcast detail (parameterized) |
player |
Full-screen now-playing |
Five tabs are shown in a NavigationBar: Home, Discover, Library, Queue, and Settings.
The bottom bar uses saveState and restoreState so each tab remembers its scroll
position and back stack independently. The bar is hidden on the full-screen player route.
When an episode is loaded (i.e., playbackState.episodeId != 0), an animated mini player
appears above the bottom navigation bar. It displays episode artwork, title, podcast name,
a progress indicator, and a play/pause toggle. Tapping the mini player navigates to the
full-screen player route.
Playback is built on three cooperating components:
Compose UI (NowPlayingScreen, MiniPlayer)
| observes StateFlow<PlaybackState>
v
PlaybackController (@Singleton)
| sends commands via MediaController
v
PlaybackService (MediaSessionService)
| owns ExoPlayer, MediaSession
v
Android system (notification, lock screen, Bluetooth, audio focus)
A MediaSessionService that runs in the foreground with a persistent notification.
It creates an ExoPlayer configured for speech audio (AUDIO_CONTENT_TYPE_SPEECH),
automatic audio focus management, and handling of audio-becoming-noisy events (e.g.,
headphone disconnect). It exposes two custom session commands:
SET_SKIP_SILENCE-- enables ExoPlayer's silence-skipping mode.SET_VOLUME_BOOST-- increases player volume to 1.5x for quiet podcasts.
A Hilt @Singleton that bridges the UI layer and the service. It:
- Connects to
PlaybackServicevia aMediaController(built from aSessionToken). - Exposes a
StateFlow<PlaybackState>that the UI observes. This state includes episode metadata, play/pause status, position, duration, speed, and queue flags. - Provides control methods:
play(),pause(),resume(),seekTo(),skipForward(),skipBack(),setPlaybackSpeed(),setSkipSilence(),setVolumeBoost(), andstop(). - Runs a coroutine-based position-update loop (every 250ms) while playback is active.
- Manages queue advancement: when an episode ends (
Player.STATE_ENDED), it removes the finished episode from the queue viaQueueDaoand starts the next one automatically.
An immutable data class that fully describes the current playback status. ViewModels and
Compose screens never talk to the MediaController directly -- they read PlaybackState
and call methods on PlaybackController.
MainActivity.onCreate() calls playbackController.connectToService(this), which
asynchronously builds the MediaController. Because PlaybackController is a singleton
and the service runs independently, playback continues across configuration changes and
even after the Activity is destroyed (e.g., when the user swipes the app away, the service
stops only if nothing is playing).