"Design a chat app like WhatsApp" comes in two versions. One asks you to design the servers. The other puts the phone in the frame and asks for the client, and that second version is the one this guide covers. The server question has well-rehearsed answers. The client question is about a process that dies without warning and a network that disappears mid-sentence.
It is a real interview question, not a study-guide invention. A TikTok/ByteDance Android report from March 2025 describes two design rounds on client-side messaging. A Meta London loop for an iOS role in 2020 asked for a messenger app. Two reports are not frequency data, but they show the question gets asked on both platforms.
The client version is hard because the phone is a hostile place to run a chat app. The network drops mid-send. The OS kills your process mid-write. A user comes back after three days to thousands of missed messages. A push arrives for a message your WebSocket never saw. This is an interview design for a WhatsApp-like product, not a description of WhatsApp's private implementation.
What Mobile System Design Rounds Actually Test
A mobile round is not a backend round on a smaller whiteboard. The subject is the app on the phone: its lifecycle, its storage, its network, and its battery. The Mobile Design Rounds chat case study and Recomposed chat lesson are useful preparation examples. Combined with Android's architecture guidance, they suggest five areas to cover, not a universal interview rubric:
| Theme | The question it asks you |
|---|---|
| App lifecycle and state survival | The OS can kill your process when you are backgrounded. What survives, and how does the app come back? |
| UI architecture and performance | Who owns screen state, and how does a long, live list stay smooth on the main thread? |
| Networking and real-time transport | REST for what, socket for what, and who manages the connection? |
| Offline-first data and sync | What works with no network, what is the source of truth, and how does the client catch up? |
| Background work, push, and battery | What may still run when the app is backgrounded, and at what cost? |
Security cuts across all five. Set the privacy boundary during scoping, then go deeper if asked. This guide walks through the major blocks rather than implementing a database or protocol. For the framework this question slots into, see the Complete Android System Design Interview Framework. The backend chat system design guide covers server routing, message storage, and group fan-out; this guide stays on the phone.
One boundary to name before the interviewer does. "No message lost" is two promises, not one:
- Local durability: a committed message survives process death, crashes, reboots, and network loss. Uninstalling or clearing app data removes local history. Device or storage loss is outside this guarantee.
- Delivery: the client keeps retrying a committed message, but it cannot promise delivery after a permanent server rejection. That message stays on the device as
FAILED, visible to the user.
Step 1: Clarify the Scope
Interviewer: Design the Android client for a chat app like WhatsApp.
Candidate: A few questions before I start. Can I assume the backend exists: a WebSocket gateway, REST send and history APIs, and FCM for push? Are we covering 1:1 chats, groups, or both? Do we need delivery and read receipts? Text only, or media too? And how strong is the offline requirement?
Interviewer: Backend exists. 1:1 and groups. Sent, delivered, and read receipts. Text only. The app must be usable offline: reading history and composing always work.
Candidate: Got it. Then the interesting depth is on the phone itself: what the UI renders, how a send survives the process, and how the client proves its history is complete. Let me start with requirements and rough numbers, then walk through the architecture block by block.
Requirements
Functional
- Conversation list with last message, unread count, and tick status
- Conversation screen with paginated local history
- Send while offline, deliver on reconnect
- Receive live updates over WebSocket; use FCM for background alerts and sync hints
- Delivery and read receipts, sent and rendered
- Recover ordered history within the server's retention and access rules
Non-Functional
- No loss of committed messages - a committed row survives process death, crashes, reboots, and network loss, and stays visible as
FAILEDif the server permanently rejects it - No duplicates in the UI - retries and catch-up may deliver the same logical message more than once
- Server-defined ordering - never arrival order, never the device clock
- Smooth scrolling through 100,000 local messages
- Battery-aware - one shared connection in the foreground, push when backgrounded
Back-of-the-Envelope Estimates
Interviewer: What numbers are we designing around?
Candidate: I would use explicit sizing assumptions, not claim these are WhatsApp measurements. Suppose a small text message averages 200 bytes before database, protocol, and encryption overhead. Update frequency and catch-up volume matter more than that exact number.
| Quantity | Estimate |
|---|---|
| Message size (text plus metadata) | about 200 bytes |
| Receipts per 1:1 message | 2 inbound events (delivered, read) |
| Naive receipts for a sender in a 100-member group | up to 198 receipt updates: delivered and read from 99 recipients |
| 3 days offline, 40 chats at 30 messages a day | about 3,600 messages, 720 KB, 36 pages of 100 |
| Local storage for 100,000 messages | about 20 MB plus indexes |
These are payload estimates, not a storage benchmark. Receipt amplification is the useful takeaway: a naive per-message design creates avoidable traffic. Batch read positions, and let the server aggregate group receipts.
High-Level Client Architecture
Interviewer: Walk me through the overall architecture before we go deep.
Candidate: MVVM on top with unidirectional data flow, a repository as the one door to local data, and a small set of application-scoped engine components underneath. User intent flows down: a send tap goes from the screen to the ViewModel to the repository. State flows up: the engine components write through the repository into Room, and every screen observes that state back up through the ViewModel. The UI is a projection of local state, so reconnects, retries, and process restarts change what the database holds, not how a screen behaves.
The engine box groups the sender, connection owner, and sync engine. Commands flow toward the data layer; observed state flows back to the screen. These engines are application-scoped while the process is alive. Scheduled Workers reconstruct the dependencies they need. The network client handles REST and auth inside this boundary; the connection owner manages the WebSocket. The table separates these responsibilities:
| Block | What it owns |
|---|---|
| UI layer (Compose) | Renders screen state, sends user intent down. Holds no conversation logic. |
| ViewModels | Project repository state into screen state and route user intent back down. Scoped to a ViewModelStoreOwner. |
| ChatRepository | The data boundary. Every read and write of message state goes through it. |
| Room | The local source of truth: messages, outbox, sync cursors. On disk, so it survives process death. |
| MessageSender | Drains pending rows, reconciles ACKs, manages retries. |
| ConnectionManager | Owns the one WebSocket: connect, backoff, reconnect handshake. |
| SyncEngine | Keeps local history complete: detects gaps and repairs them. |
| Network layer | REST calls and auth for everything that is not the socket. |
| WorkManager | Send retries that outlive the process. |
| FCM receiver | Handles sync hints and schedules bounded work. Visible notifications have a separate display path. |
The major blocks earn a walkthrough each: the UI and its state flow, the lifecycle, local data and the send path, the connection layer, and staying complete. That is the rest of this guide.
Block 1: The UI Layer and State Flow
Interviewer: Start at the top. What does the UI look like?
Candidate: Two screens, both Jetpack Compose, and neither one touches the network. The conversation list is one Room query: last message, unread badge, tick status per chat. The conversation screen pages over local history. Both observe Room through a ViewModel, so a reconnect or a retry changes what the database holds, never how a screen behaves.
Three decisions carry the screen:
- Paging, not loading. Paging with Compose loads history in chunks. Configure page size and cache limits rather than keeping 100,000 messages in memory. Scrolling up fetches older pages from disk, and it works in airplane mode for the history already cached on this device. The Android Reddit app guide shows the related Room and Paging 3 pattern for an offline feed.
- A reversed
LazyColumn. With newest-first data, index 0 is at the bottom. Open at the latest message initially, preserve the scroll anchor while paging, and do not force-scroll someone who is reading older history. - A stable key per message. Give every local row an immutable ID. For an outgoing message, its client-generated ID can serve that role. Reconcile the ACK into the same row so the pending bubble does not disappear and reappear.
Interviewer: Where do the day dividers, sender grouping, and the "Unread messages" banner come from?
Candidate: The presentation layer builds those from paged data and screen state. The ViewModel owns screen-level decisions; small display-only formatting can stay near the composable. Neither place sends messages directly.
Interviewer: What keeps the main thread responsive?
Candidate: No blocking database or network work on it, and no rebuilding the entire history for one receipt update. Collect screen state with lifecycle-aware APIs such as
collectAsStateWithLifecycle, keep list keys stable, and measure scrolling and frame timing on a lower-end device. Libraries are a starting point, not proof of smooth scrolling.
Interviewer: And when I tap send - what calls what?
Candidate: The tap is user intent, and it travels down: the composable tells the ViewModel, the ViewModel calls the repository, and the repository writes a
PENDINGrow to Room. The bubble appears because Room emits the change back up the same path, not because send code touched the UI. That separation is what lets every block below fail and retry without a single screen knowing about it.
Block 2: Living with the Android Lifecycle
Interviewer: You keep saying process death. Why is that a headline block and not an edge case?
Candidate: Because on Android, process death is an expected lifecycle event. The OS ranks every process in an importance hierarchy, and a backgrounded app can slide down to the cached tier, which the system can reclaim whenever it needs memory. The Android process lifecycle documentation is blunt about it: a cached process can be killed at any time, and the app should assume no work continues there. So I design as if the process is temporary and the disk is what persists.
Three rules follow:
- Screen scope vs app scope. A ViewModel is scoped to a
ViewModelStoreOwner, such as a navigation destination, navigation graph, or activity. It survives configuration recreation and is cleared when that owner is permanently removed. Anything that must outlive a screen - the socket, the sync engine, the sender - is application-scoped. Application scope outlives any screen but not the process; after a kill those components are reconstructed, cheaply, because all state that matters is already in Room. - Everything that matters is on disk. Messages, the outbox, sync cursors, a composed-but-unsent draft: Room. Saved state is only for small, transient UI state such as scroll position, and the system may restore it when it brings a killed process back - it is not a durability guarantee. Anything else is recomputed on restart.
- Cold start reads disk first. Render the last known conversation list and history without waiting for network sync. Reconstruct the engines alongside it: recover interrupted sends, connect, and catch up. A first install still needs an initial fetch; cached screens can show a small catching-up indicator.
Interviewer: And when the app is just sitting in the background?
Candidate: Then the platform's rules apply instead of mine. I cannot rely on an ordinary background process to keep the socket alive or run indefinitely. For this chat design, I use FCM to signal incoming activity and WorkManager for deferrable retries. A network constraint makes a retry eligible when connectivity returns; the OS still decides when it runs. A Worker reconstructs its dependencies in the current process and reads pending work from Room, rather than expecting the old application-scoped objects to survive. Foreground services have separate rules and are not a permanent chat-socket loophole.
Block 3: Local Data and the Send Path
Interviewer: Why is a database at the center of the diagram instead of the network layer?
Candidate: Because on Android, process death is normal, and anything that only lives in memory is already lost. Room is where state survives. The socket writes to it, the outbox is a query over it, the UI observes it, and after a kill the app reconstructs durable state. Transient UI state is restored separately when available.
Interviewer: What does a message row look like?
Candidate: I separate identity, ordering, and status. An outgoing message gets a
clientMessageIdbefore the server sees it. The server returns a stableserverMessageIdplus a per-conversation ordering position,serverSeq. Transport state (PENDING,SENT, orFAILED) is separate from recipient delivery/read state. These are contracts for this design, not fields Android supplies.
Three choices here are worth defending.
- Two statuses, not one. Transport state (
PENDINGtoSENT, orFAILED) and receipt state (NONEtoREAD) move independently, and one enum cannot order both. Keeping them apart also makes the "receipts only move forward" rule a one-line guard. serverSeqstays null until server confirmation. Local send order is not conversation order. If I send A offline and you send B online, the server may order B first. Both clients have to agree, so position is only known after the server assigns it.- A sync cursor per conversation.
lastSyncedSeqmeans coverage since an established baseline, not that a new phone has downloaded the entire conversation. Keep historical paging separate from forward catch-up. The server must define ordering, retention, deletions, and a way to reset an expired cursor.
The send path, step by step
Interviewer: I type "running late" and hit send inside a tunnel. Walk me through it.
Candidate:
1. Insert row: status = PENDING, serverSeq = null (durable now)
2. Room emits, the bubble renders with a clock icon (no network involved)
3. A drain tries the WebSocket
4. Tunnel: the send fails, the row goes back to PENDING
5. Reconnect: the drain resumes, the server ACKs
6. Row updated: status = SENT, serverSeq = 4103 (one tick)Step 1 is the local durability boundary. After the transaction commits, an ordinary process kill does not remove the row. A tap before the commit is not yet a durable send, and disk errors must be surfaced rather than shown as success.
Retries are safe because of the client ID
Interviewer: Say the server saved my message but the ACK never reached me. Now what?
Candidate: I resend with the same
clientMessageId. Within the authenticated sender's scope, the server maps that key to the same message and returns the original result. Its dedupe retention must cover the retry window. If a socket echo or history page arrives before the ACK, the client merges by that client ID instead of making a second bubble. Server IDs dedupe already-accepted messages; the client ID connects them to a pending local send.
One attempt at a time
Interviewer: What if two drains run at once, or the process dies mid-send?
Candidate: Foreground and Worker drains share one claim-and-recovery policy. A claimed attempt can expire after a crash; late failure callbacks cannot overwrite a confirmed send. Overlapping network attempts can still happen, so server idempotency is the final safety net. The important mobile decision is that recovery starts from durable pending work, not a queue that disappeared with the process.
Retries that outlive the process
Interviewer: The app goes to the background with messages still pending.
Candidate: Enqueue persistent work with a network constraint. WorkManager can reconstruct the sender after a process restart. A bounded Worker uses a request/response send endpoint with the same idempotency contract; it does not need to keep a background socket alive.
Unique work avoids redundant scheduling, but does not replace row claims. Recheck pending work at startup and handle the race where a new row appears as a Worker finishes. Room and WorkManager do not share one atomic transaction.
For a short user-initiated send, expedited work may help, subject to quotas and fallback. Ordinary work can be delayed by constraints and OS policy. Neither path promises instant delivery. After a settings-level force stop, background work cannot be relied on until user action takes the app out of the stopped state.
The boundary from the intro applies here. If the server permanently rejects a message, the row ends as FAILED, visible, with retry left to the user's tap.
Block 4: The Connection Layer
Interviewer: Who owns the WebSocket, and when is it open?
Candidate: One
ConnectionManager, and one socket for the whole app. Not one per conversation: multiplexing avoids one set of connection and heartbeat overhead per chat. Battery cost still grows with traffic, reconnects, and radio wake-ups.
The lifecycle, in four rules:
- Foreground means try to connect. With an authenticated session and usable network, open one socket for the visible app. A reconnecting state is normal, not a fatal screen error.
- Failures back off. Reconnect with exponential backoff and jitter, so a flapping network does not produce a reconnect storm. A connectivity callback is a useful retry signal, not proof the server is reachable. Requests can still fail behind a captive portal or during a network handoff.
- Background means push. For this design, close the socket when the app leaves the foreground and use FCM for alerts and sync hints. Android recommends WebSockets in the foreground and FCM in the background; this is a design policy, not a claim that every background socket is forbidden.
- Every connect starts with a handshake. The client reports its
lastSyncedSeqper conversation, and the server replies with the current head. That handshake is how the sync engine learns it is behind, and it runs on every reconnect, not just at launch.
Durable socket results go through the repository into Room: messages, ACKs, and receipts. Ephemeral typing and connection indicators can remain in memory. Neither path calls a composable directly.
Interviewer: And if the socket and a push deliver the same message?
Candidate: Socket and history responses upsert the same server message, and outgoing echoes reconcile with the original client ID. A push hint can cause an extra fetch, but not an extra message row. Use stable notification IDs as well, so repeated alerts update rather than multiply. Presence-based push suppression can reduce noise, but a stale presence signal must not be the only fallback.
Block 5: Staying Complete - Sync and Push
Interviewer: I've been offline since Tuesday. I open the app on Friday.
Candidate: The reconnect handshake tells me how far behind I am, and the sync engine closes the gap:
1. Client reports (conversationId, lastSyncedSeq = 4102)
2. Server replies with head = 4180
3. Client fetches pages: GET /messages?afterSeq=4102&limit=100
4. Each response includes coveredThrough, the server's coverage marker
5. One Room transaction per page: insert messages AND advance
lastSyncedSeq to coveredThroughFour rules keep this correct:
- Fetch by sequence window, never by time. Timestamp sync ("everything since Friday") breaks under clock skew and late-arriving messages.
- Freeze the target. Catch up to the head seen at sync start. Newer messages arrive over the live socket or a later catch-up, so the loop ends. A detected gap or periodic foreground head check schedules another pass; do not rely on another message arriving to reveal a missing tail.
- Advance only with explicit coverage.
coveredThroughis a proposed server contract, not an Android API. It covers live messages, deletions, and any permitted skipped positions. An empty page can advance the cursor if its coverage marker proves the range complete; emptiness by itself proves nothing. - Write messages and cursor in one transaction. After a process kill, the two can never disagree.
Catch-up is idempotent against the live socket, because both paths insert with the same dedupe constraint. Which one delivers a message first does not matter.
Interviewer: What if the gap is 40,000 messages? Or this is a new phone?
Candidate: Two cases, two directions.
| Case | Strategy |
|---|---|
| Existing device, long gap | Forward catch-up from lastSyncedSeq, ascending, in the background. The live socket keeps new messages flowing. |
| Fresh install or new device | No baseline exists. Fetch the newest page (about 50) per conversation, and page backward as the user scrolls up. |
On a fresh install, the server returns a recent snapshot with a forward-sync baseline and a separate token for older history. That lets live sync continue without pretending every earlier message is local. If an old cursor expires or access changes, refresh the snapshot. Edits and deletions also need change events or a change cursor; a new-message-only feed will miss them.
Push: visible alerts and history sync are different jobs
Interviewer: The app is in the background and a message arrives. What happens?
Candidate: I separate alert latency from history correctness. A user-visible notification should not wait for a full history fetch. A sync hint tells the app to reconcile durable state; it is not proof that history is complete.
- The backend sends an appropriate FCM alert or sync hint for the device.
- For an alert, display allowed notification content promptly. A privacy-sensitive app can use a generic "New message" alert, or decrypt a permitted preview locally. Do not put plaintext private messages into push payloads by accident.
- For sync, schedule bounded work that fetches changes and commits them through the repository. Do not start an unscoped coroutine in a short-lived receive callback and assume it will finish.
- On open or reconnect, run the same catch-up protocol regardless of which pushes arrived.
Firebase's priority guidance warns against calling the server before posting a notification. Its receive guide also explains why work that outlives a callback needs a valid background execution path. Exact callbacks depend on the FCM API and SDK in use; the architecture does not depend on one callback name.
Interviewer: So a pointer-only push is wrong?
Candidate: No. It is a reasonable sync hint or privacy choice. It is wrong to promise an immediate message preview while requiring an unreliable round trip first. Choose the alert content and privacy policy explicitly, then sync history separately.
Pushes can be delayed or lost. Urgent priority is for time-sensitive, user-visible content, not a bypass for arbitrary background sync. Notification permission and channel settings also matter: on Android 13 and later, non-exempt notifications need runtime permission.
On cold start, render cached history, show that it may be catching up, and reconcile without blocking the entire screen. For more on notification routing, see the Android notification system design guide.
Block 6: Delivery and Read Receipts
Interviewer: Define sent, delivered, and read.
Candidate: I would state the product semantics, rather than assume every messenger uses the same ticks:
| State | Confirmed by | Meaning |
|---|---|---|
| Sent (one tick) | Server | Server persisted the message. The sender can stop retrying. |
| Delivered (two ticks) | Recipient's device | The app committed the message locally and acknowledged it through the server. FCM acceptance alone is not delivery. |
| Read (blue ticks) | Recipient's client | The client reported a read position under the product's read-through rule below. |
Receipts only move forward, and the update is guarded so a late DELIVERED can never overwrite a READ. Receipt events travel over the same at-least-once channel as messages, so reordering has to be harmless.
Sending read receipts without a storm
Interviewer: I scroll through a busy group and read 40 messages. What leaves my phone?
Candidate: A batched read position, not 40 separate events. For this product, "read through sequence N" means the conversation was open and the user reached N; earlier messages are considered read. That is a product rule, not proof the user looked at every bubble.
Debounce updates, for example around 500 ms, and flush on a screen transition when practical. Store the latest pending watermark durably, merge it monotonically, and retry later if offline.
If the product instead requires each message to have been individually visible, one read-through watermark is insufficient for arbitrary skipped ranges. Say that trade-off out loud rather than quietly changing what "read" means.
Group receipts and the unread badge
In groups, the server can aggregate member watermarks into "Read by 12," with member detail fetched when requested. The phone does not need an eagerly updated receipt object for every member of every historical message.
The badge has one subtlety: while local coverage is partial, say a fresh-install window or an unrepaired gap, the client cannot count unread locally with confidence. Have the server return a count tied to a sync version, then apply only later deltas. Refresh it after gaps or read-position changes. Counting only cached rows and presenting that number as exact is the bug to avoid.
Block 7: Clock Skew and Failure Modes
Interviewer: Why not just order by timestamp?
Candidate: Because phones disagree about time by minutes. A user who sets their clock forward pins their messages to the bottom forever. A phone that drifts back buries new messages in old history. A conversation needs one ordering authority, and the server is the only party every message passes through. So
serverSeqis the sort key, and device time is only a display label. Pending messages use a local insertion order until the server confirms their position; keep their UI identity stable when they move.
Interviewer: Summarize the failures you designed for.
Candidate:
| Failure | What absorbs it |
|---|---|
| Send in airplane mode | PENDING row, drain on network return |
| Process killed mid-send | Interrupted attempt recycled, then idempotent resend |
| Stale failure callback after ACK | Attempt guard, stale update ignored |
| ACK lost after server persisted | Same clientMessageId, server dedupes |
| Duplicate WebSocket delivery | Dedupe constraint on serverMessageId |
| Out-of-order delivery | Render by serverSeq |
| Offline for days | Forward catch-up, cursor on coveredThrough |
| Newest messages deleted | Advance only with explicit server coverage, including deletions |
| Fresh install | Newest page first, backward paging |
| Push delayed or dropped | Alert path is separate; sync handshake repairs durable history |
| Receipt events reordered | Forward-only receipt guard |
| Read-receipt storm in groups | Batched read-through position with explicit product semantics |
| Wrong device clock | Server orders; the clock never touches ordering or identity |
Common Interview Follow-ups
"Why not just use Firebase or Firestore?"
A managed backend can be a good choice, including beyond a prototype. This interview assumes an existing backend, so I am explaining its client contracts. Managed services reduce work, but do not remove product decisions about ordering, retries, receipts, privacy, or history recovery.
"How does multi-device work?"
Every device runs the same client with its own lastSyncedSeq. Your own sent messages reach your other devices as ordinary incoming messages through the same insert path, already SENT.
"What about end-to-end encryption?"
End-to-end encryption adds a client crypto boundary: encrypt before sending, decrypt locally for display, and keep key management out of composables. The server can still route opaque IDs and order messages without reading their bodies. Device linking, key rotation, encrypted backups, and new-device history recovery need separate protocols. A generic alert can avoid exposing preview text to the push service. Do not present encryption as one line between Room and the ViewModel.
"How do media messages change the design?"
Add an attachment reference and an upload stage before the message enters the outbox. The message is not SENT until the upload finishes and the server ACKs the message send. The Android photo app guide covers a WorkManager upload pipeline, retry handling, and pre-signed URLs.
"What happens on sign-out?"
Scope storage and work per account. Cancel jobs, close the socket, clear credentials, and apply the product's local-data policy. Reject late callbacks from the previous account session; cancellation alone does not stop a response already in flight. Use authenticated TLS connections and platform-backed key protection where appropriate. Never log tokens or message bodies.
"How do you test all of this?"
Test across boundaries, not only Room. Kill the process after commit but before send; lose an ACK; deliver an echo before the ACK; switch accounts during a request; deny notification permission; go through Doze and a network handoff. Verify history recovery, no duplicate bubbles, no cross-account writes, and responsive scrolling while catch-up runs. Record send latency, oldest pending age, sync failures, and notification outcomes without logging private content.
Quick Interview Checklist
- Clarify offline behavior, delivery/read semantics, and the privacy boundary.
- Draw UI, ViewModel, repository, local store, send/sync components, and background work.
- Explain what survives rotation, navigation, process death, and sign-out.
- Keep scrolling responsive while history and receipt updates arrive.
- Persist before send; reconcile retries, echoes, and ACKs into one message.
- Use one foreground connection, bounded background work, and a separate alert path.
- Define catch-up coverage and the new-device baseline with the backend.
- Test process kills, missing ACKs, network changes, notification denial, and account switching.
Conclusion
The mobile half of the chat question tests whether you design for a process that dies without warning and a network that comes and goes. Strong candidates do not list libraries. They explain why intent flows down and state flows up, why process death shapes every block, why the insert comes before the network call, why one component owns the one connection, and why only the server gets to order a conversation.
For another client-focused prompt, use the Android system design practice questions.
Technical References
- Android: build an offline-first app - local reads, repositories, and queued writes.
- Android: ViewModel and saving UI state - configuration changes, process death, and persistence boundaries.
- Android: Compose lists - paging and stable item keys.
- Android: define work requests - constraints, retries, and expedited-work limits.
- Android: receive messages reliably - foreground transport and background push.
- Firebase: message priority and receiving messages - prompt alerts, callback limits, and background processing.
Technical sources checked November 17, 2026. Sequence cursors, idempotency, and read semantics above are proposed product/backend contracts, not Android or Firebase guarantees.
Frequently Asked Questions
What does the Android client architecture for a chat app look like?
Compose renders state from ViewModels. A repository exposes Room-backed data and accepts user actions. Send, connection, and sync components reconcile network results into local state. WorkManager handles bounded persistent work; FCM supports background alerts and sync hints. No composable owns a socket or sends a message directly.
How do you avoid losing a chat message when the app is killed?
Commit the outgoing message locally before sending. After a restart, recover pending work and retry with the same client-generated idempotency key. Reconcile echoes and ACKs into the original row. Uninstalling or clearing storage removes local data; permanent server rejection leaves a visible failed message rather than a delivery promise.
Should a chat app use WebSocket or push notifications?
Both. This design uses one WebSocket while the app is in the foreground and FCM for background alerts and sync hints. A prompt notification should not wait for full history sync. On open or reconnect, catch up from the server even if no push arrived.
How do you detect missing messages in a chat?
Keep a server-defined cursor per conversation and advance it only with proven coverage. The server must account for deletions, access changes, and expired cursors. On a new phone, establish a recent snapshot and a forward-sync baseline; load older history separately.
How do you send read receipts without flooding the server?
Batch a forward-only read position per conversation instead of emitting one event per message. Define whether reaching a message marks all earlier messages read. If each message must be individually visible, a single watermark cannot represent arbitrary skipped ranges.
Which companies have asked mobile chat design questions?
A TikTok/ByteDance Android candidate report describes client-focused messaging rounds in March 2025. A Facebook London iOS report describes a messenger-design round in 2020. These are self-reported examples, not frequency data or proof of current hiring questions.
Practise explaining the lost ACK, the process restart, and the three-day gap out loud. Then use Mockingly.ai to practise the interview conversation.
