Beyond CLEAN and MVP: Architecting an Offline-first Reactive Data Layer in Android
Reactive Data Layer Architecture (RDLA) is a mobile-optimized pattern for Android that addresses shortcomings of MVP and Clean Architecture in reactive, offline-first apps. It enforces a strict split between public API contracts and private implementation modules, uses Kotlin Flow cold streams so the UI subscribes to data rather than polling, and treats the local Room database as the single source of truth. The article walks through a heart rate tracking example covering the API module, repository coordinator, Room data source, ViewModel with StateFlow/SharedFlow, asynchronous mutation queues merged on-the-fly, WorkManager-backed background sync, conflict resolution with rollbacks, and a TestExtensions pattern for Robolectric-based unit tests without SQLite mocking.