Skip to content
All guides

Design a chat app: the mobile side of the system design round

By Mike Salari. Staff mobile engineer · 500+ technical interviews from the hiring side.

"Design a chat app" is one of the most common mobile system design prompts, and most answers stop at a server, a socket and a push arrow. This guide is for senior and staff iOS, Android, Flutter and React Native engineers. You get the ten client-side decisions an interviewer probes, what each one scores, the follow-ups that change the conditions, and three short code samples you can say out loud.

Who this is for

Engineers with a mobile system design round coming up, and leads who run that round and want a sharper scoring sheet. This page is about the decisions between the boxes.

The one idea to carry in

Every message in a chat app has two lives. Before the server acknowledges it, it is a local operation the user owns. After the acknowledgement, it is shared history the server orders. Most chat bugs come from mixing those two lives up: a retry that cannot tell whether a send landed, a cursor that moved past messages that never reached the disk, a delete that flickers back.

An answer weakens when the diagram grows but the promise to the user stays vague. A modest design with clear authority and recovery scores higher than a big one with neither.

The questions

1. "Before you draw anything, what do you need to know?"

What is scored: whether you shape the problem and rank what matters before you solve it.

A strong answer covers:

  • Context: one-to-one or groups, media, edits and deletes, read receipts, how many devices per account, and whether end-to-end encryption is required.
  • Decision: rank the characteristics out loud. For chat, durability of sent messages and cross-device consistency usually beat raw latency.
  • Alternative: treating every characteristic as equal. A chat app, a trading app and a photo editor give three different designs.
  • Failure mode: designing the happy path and letting the interviewer find offline, process death and old app versions for you.
  • Evidence: you pick one journey to go deep on, for example "send a message and recover missed ones after offline", and say what you leave for later.

Follow-ups:

  • The product now allows three devices per account. Which of your assumptions break first?
  • You have 25 minutes left. What do you drop?

Weak answer: "WebSockets and a database." It names tools before a single requirement.

2. "Walk me through one message from the composer to the server."

What is scored: durability, idempotency, and an honest UI.

A strong answer covers:

  • The client creates a message ID before anything else.
  • The message goes into the local database and an outbox table in one transaction, so the bubble that says "sending" and the durable copy appear together. There is no window where the user sees it and a crash loses it.
  • The send carries the client ID. The server treats it as an idempotency key, so a retry after a lost response becomes a lookup, never a second message.
  • An unacknowledged message is a local draft the user may still edit or cancel. Once acknowledged, an edit becomes a new revision operation and the original stays.
  • Failure mode: one row with a "sent" flag flipped optimistically. After process death you cannot tell a message that landed from one that only looked like it did.

Follow-ups:

  • The request timed out, but the server saved it. Walk me through the next minute.
  • The user edits the message while it is still in the outbox. What goes over the wire?

Weak answer: "If it fails, I retry with backoff." Backoff controls load. It does nothing about duplicates.

3. "How does the client know it has every message?"

What is scored: cursor discipline, the rule that separates a passing answer from a strong one.

A strong answer covers:

  • The server assigns a sequence number per conversation. That number is both the order and the cursor.
  • The device stores its cursor and asks for everything after it on reconnect, in pages.
  • The load-bearing rule: the cursor moves only inside the same local transaction that writes the messages. After any interruption, the stored cursor is never ahead of the newest message on disk.
  • Alternative: a wall-clock timestamp as the cursor. A phone whose clock runs fast stamps its cursor into the future and skips every message the server accepts in that window.
  • Evidence: a test that kills the process between fetch and write, then asserts nothing was skipped.
Kotlin
suspend fun applyPage(db: ChatDatabase, page: SyncPage) {
    db.withWriteTransaction {
        db.messageDao().upsertAll(page.messages)        // idempotent on message ID
        db.cursorDao().upsert(
            ConversationCursor(page.conversationId, page.lastSequence)
        )
    }
}

Follow-ups:

  • The OS kills the app after the fetch returns and before the write commits. What does the next launch request?
  • A page arrives twice because the response was retried. What changes in the database?

Weak answer: "The socket reconnects and the messages come in." A dropped connection loses whatever was in flight, and nothing tells the client it is missing anything.

4. "Socket, push, or polling?"

What is scored: matching the transport to app lifecycle and to the direction data flows.

A strong answer covers:

  • In the foreground, a WebSocket, because chat is two-way: the client sends messages and typing state, and receives at the same time.
  • For one-way live data, such as a status feed, server-sent events are simpler to run. They are part of the WHATWG HTML standard and ride plain HTTP. Ask first which way the data flows.
  • In the background, nothing your app owns stays connected. APNs and FCM wake the app. Push is a doorbell. The fetch behind it carries the data.
  • Apple says background notifications are low priority, not guaranteed, may be throttled, and advises no more than two or three per hour. FCM says a message ID means accepted, not delivered, and an offline device stores at most 100 non-collapsible messages before all of them are discarded.
  • So both paths feed one apply function and one cursor. Push says "come look". The cursor fetch decides what is true.

Follow-ups:

  • The user taps a notification for a message the database does not have yet. What does the screen show?
  • Three pushes coalesce into one. What did the user lose?

Weak answer: "Push delivers the message when the app is closed." Both Apple and Firebase document cases where it does not.

5. "A whole office reconnects at once after a Wi-Fi blip. What happens to your backend?"

What is scored: thinking about the whole fleet of devices at once.

A strong answer covers:

  • Context: if reconnect means a full state download, thousands of clients returning in the same minute become a denial of service you caused yourself.
  • Decision: reconnect with exponential backoff and random jitter, so devices that dropped together do not return together.
  • Reconnect cheaply: fetch by cursor, load reference data such as user profiles lazily, and subscribe only to what is on screen.
  • Detecting a dead socket: a TCP connection can go silent without closing, so the client and server use heartbeats with a timeout. Shorter intervals find death faster and cost battery.
Swift
import Foundation

func reconnectDelay(attempt: Int, base: Double = 1, cap: Double = 60) -> Duration {
    let ceiling = min(cap, base * pow(2, Double(attempt)))
    return .seconds(Double.random(in: 0...ceiling))   // full jitter
}

// try await Task.sleep(for: reconnectDelay(attempt: failures))

Follow-ups:

  • Your heartbeat is every 10 seconds. Product says battery complaints went up. What do you change?
  • The server restarts during peak hours. What does the first 60 seconds look like from the client?

Weak answer: "Reconnect immediately so the user sees messages fast." It optimises one device and knocks the recovering server back down.

6. "How do edits and deletes reach a phone that was asleep for a month?"

What is scored: treating deletes as data and keeping one write path.

A strong answer covers:

  • A delete is a tombstone operation with its own ID and sequence, delivered like any message, so a sleeping device learns the message existed and then that it was removed.
  • A tombstone lives longer than your longest realistic offline window. Pick that number from your own fleet data, even when storage would prefer a shorter one.
  • Every inbound event goes through one apply function: idempotent on message ID and monotonic on version.
  • Failure mode: the socket writes straight to the database while sync also writes. The same message lands twice, or a deleted message comes back on screen. That second case is a privacy failure.

Follow-ups:

  • An edit arrives before the original message. What do you store?
  • Legal asks for "delete for everyone" within a day. What breaks in your tombstone lifetime?

Weak answer: "We remove the row when the server says so." A device that was offline never hears it, and a later page can resurrect the message.

7. "The user has a phone and a tablet. What does 'read' mean now?"

What is scored: defining a multi-device rule instead of a single boolean.

A strong answer covers:

  • Read-your-writes across devices: the sending phone shows the message at once, and every other device of that user shows it within a bounded time or shows an honest pending state.
  • Each device reports the highest sequence it has displayed.
  • "Seen somewhere" is the maximum across devices. "Delivered to all" is the minimum. Write down which one each checkmark means.
  • Alternative: one global read flag per message. It flips on the first device and lies about the others.
Kotlin
data class DeviceReadState(val deviceId: String, val highestDisplayedSeq: Long)

fun seenSomewhere(states: List<DeviceReadState>): Long =
    states.maxOfOrNull { it.highestDisplayedSeq } ?: 0L

fun deliveredToAll(states: List<DeviceReadState>): Long =
    states.minOfOrNull { it.highestDisplayedSeq } ?: 0L

Follow-ups:

  • A read receipt arrives before the delivered one. What does the sender see?
  • In a group of 200, what does "read" mean, and what does it cost the server?

Weak answer: isRead: Boolean. It cannot express what three devices know.

8. "A device was offline longer than the server keeps history. Now what?"

What is scored: a recovery path that does not lose the user's own work.

A strong answer covers:

  • The device cannot catch up incrementally past the server's compaction horizon. It must rebootstrap from a snapshot.
  • Order matters: drain the outbox first so unsent messages survive, then reset read state, then pull the snapshot.
  • Rebootstrap is a counted event in telemetry. A spike means your horizon is shorter than some real cohort's offline time.
  • Alternative: silently wipe and refetch. It hides the signal and can drop drafts.

Follow-ups:

  • The outbox holds a message that fails validation on the new server version. What does the user see?
  • The user is on a metered connection abroad. Do you still pull the full snapshot?

Weak answer: "Clear the cache and reload." It loses unsent messages and teaches you nothing.

9. "End-to-end encryption is now required. What changes?"

What is scored: seeing encryption as a key-lifecycle and enrolment problem.

A strong answer covers:

  • The transport becomes key-blind. The server still assigns sequences and delivers ciphertext, so the cursor and tombstone rules from earlier questions do not change.
  • A new device and old history is a policy choice with an owner: grant full history and a stolen device opens years of messages; grant none and users think the app erased their past.
  • Old app versions cannot encrypt. You need capability negotiation and a rule for mixed conversations.
  • Server-side search, moderation and backup all get harder. Say which ones the product gives up.
  • Only name a protocol you can explain one level deeper.

Follow-ups:

  • The user loses their only phone. What can they recover?
  • One member of a group is on an app version that cannot encrypt. What happens to that conversation?

Weak answer: "It is end-to-end encrypted," with nothing on keys, devices or old clients.

10. "Your optimisation shipped and some devices now skip messages. How do you recover?"

What is scored: containment and reversal under partial information.

A strong answer covers:

  • Context: a release moved the cursor before persistence finished, to save scroll time. Affected devices report success and miss a range.
  • Contain by cohort: switch off the change behind a flag for the affected version. A global rollback strands users and repairs nothing.
  • Repair with a safe low-water mark: reset the cursor to the newest message proven on disk, so the skipped range refetches. Full rebootstrap only where that mark cannot be trusted.
  • Telemetry records the skipped sequence range, never message text.
  • Evidence: a cursor-skew assertion with zero tolerance that pages on-call.

Follow-ups:

  • Half the affected users are on metered connections. Does your repair change?
  • The postmortem proposes "be more careful with cursor code". What do you put there instead?

Weak answer: "Force everyone to reinstall or log out." It burns data, drops outboxes and hits a backend that is already under stress.

Senior vs staff on this prompt

Mobile System Design Blueprint scores two answers to the multi-device question. The senior one names the right parts: client IDs, server sequence, one idempotent apply function, tombstones. It would pass many rounds. It misses the cursor rule, so it still has the skip bug.

The staff answer has the same parts plus the rule, a test that proves it, a plan for old clients that still poll, a convergence budget, an owner, and the number that would prove the offline model wrong. What closes the gap is the invariant, the fleet, the budget, the owner and the way back.

For the wider architecture round, see mobile app architecture interview questions. For staff-level loops in general, see staff mobile engineer interview questions.

What changed in 2024 to 2026

  • Android's offline-first guide, updated 14 October 2026, still names the local data source as "the canonical source of truth for the app" and the exclusive source higher layers read. Android Developers
  • Android 15 (2024) caps dataSync foreground services at 6 hours in 24, shared across the app, then calls onTimeout. Long media sync or history download can no longer assume an unlimited service. Android Developers
  • Room's current docs show @Upsert for insert-or-update by primary key and withWriteTransaction for grouping DAO calls in one write transaction, the two pieces the cursor rule needs. Android Developers
  • Apple's current guidance: background notifications are low priority, not guaranteed, may be throttled, and the system holds only the newest one and drops it if the app is force quit. Apple Developer
  • Firebase Cloud Messaging: acceptance is not delivery, and past 100 stored non-collapsible messages all are discarded and the app should do a full sync. Firebase

How the rounds run

Formats vary by company and level. Some companies run a mobile-specific design round. Others give a general system design prompt and expect you to bring the mobile view. StaffEng notes that most companies struggle with their Staff-plus loops and that it is always reasonable to ask the recruiter and hiring manager what each format evaluates. No official company page found names "design a chat app" as its question, so treat it as practice.

A pace that works in 45 minutes: requirements and ranking, one journey end to end, state and authority, then failures (lost response, old client, offline for days, missed push), then trade-offs and how the design grows from first version to scale.

Sources