Design: Offline-First Feed
ADVANCED › System Design
Designing an offline-first feed with Room as source of truth, RemoteMediator paging, and WorkManager sync.
This is a staple Android system-design round: build a news/social feed that works offline, stays fast, and reconciles with the server. Interviewers probe whether you make the local DB the single source of truth, wire a network-bound resource so the UI is reactive, page from disk with RemoteMediator, sync in the background with WorkManager, and reason clearly about conflict resolution, caching, and error/empty states. Strong answers also name what you would test.
What this covers
- Why Room is the single source of truth and how observable Flow reads keep the UI live across connection states
- The network-bound resource flow: show cache, fetch network, write to DB, re-observe (DB re-emits)
- Paging 3 with RemoteMediator and a RemoteKeys table for DB-backed pagination
- Background sync with WorkManager: NetworkType.CONNECTED constraint, unique work, Result.retry() exponential backoff
- Conflict resolution (last-write-wins, server-authoritative) and the three write strategies (online-only, queued, local-first)
- Distinguishing loading vs empty vs error vs retry via Paging LoadState, plus what you would test
Study this topic
- Design: Offline-First Feed explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Design: Offline-First Feed interview questions and answers