:core:database
July 20, 2026 · View on GitHub
Purpose
Owns the main Room database, entities, DAOs, type converters, and migrations for podcasts, queue items, listening history, downloads, and RSS episodes. It does not own repositories, ranking's separate Room database, playback services, download workers, or feature UI.
Public API
BoxLoreDatabaseand itsgetDatabasefactory.- Entities:
PodcastEntity,ListeningHistoryEntity,ListeningSessionEntity,ListeningRollupEntity,DownloadedEpisodeEntity,RssEpisodeEntity, andentities.QueueItem. - DAOs:
PodcastDao,ListeningHistoryDao,ListeningSessionDao,ListeningRollupDao,DownloadedEpisodeDao,RssEpisodeDao, anddao.QueueDao. ListeningInsightsMaintenancefor rolling session/rollup maintenance (viaBoxLoreDatabase.listeningInsightsMaintenance()).ListeningRollupMergefor pure session→rollup merge logic.Convertersfor Room type conversion.
Internal structure
src/main/java/cx/aswin/boxlore/core/database/
BoxLoreDatabase.kt
Converters.kt
DownloadedEpisodeDao.kt
DownloadedEpisodeEntity.kt
ListeningHistoryDao.kt
ListeningHistoryEntity.kt
ListeningInsightsMaintenance.kt
ListeningRollupDao.kt
ListeningRollupMerge.kt
ListeningSessionDao.kt
PodcastDao.kt
PodcastEntity.kt
RssEpisodeDao.kt
RssEpisodeEntity.kt
dao/
QueueDao.kt
entities/
QueueItem.kt
Dependencies
- Project dependencies:
:core:model,:core:network. - Libraries: Room runtime, Room KTX, Room compiler through KSP, and Gson.
- Reverse-edge rule: database must not depend on catalog, playback, downloads, designsystem, or feature modules.
Threading / lifecycle
BoxLoreDatabase.getDatabaseis a process singleton created from application wiring.- DAO operations expose suspend functions and flows; callers should keep large database work off the main thread.
- Feature modules should depend on ports or repositories rather than injecting
BoxLoreDatabasedirectly.
Persistence & identity
- Room filename
boxlore_databasestores user data and must remain stable. - Legacy database rename behavior preserves installs that used
boxcast_database. - Entity/table schemas and migrations are release-critical persisted contracts.
- Package root is
cx.aswin.boxlore.core.database. - Ranking persistence is owned by
:core:rankinginadaptive_ranking_database.
Testing notes
- Unit tests live under
core/database/src/test. PodcastDaoInMemoryTestverifies the in-memory Room DAO path when Android resources are available to JVM tests.ListeningRollupMergeTestcovers session→rollup merge, including the empty-sessions guard.- Prefer repository or port fakes for feature tests instead of depending on Room directly.
./gradlew :core:database:testDebugUnitTest
CI relevance
unit-tests.ymlruns database JVM tests with the project suite.- Compile and KSP failures in this module block app and repository tests that depend on entities or DAOs.