How would you design the mobile client for a chat app like WhatsApp?
What the interviewer wants to hear
- Local database for messages, UI observes it
- Real-time connection (WebSocket) while in foreground, push when in background
- Message states: sending, sent, delivered, read; client-generated IDs
- Outgoing queue with retries and ordering
- Paging of history, media upload/download handling
- Battery, data usage and end-to-end encryption concerns
Model answer
The core is a local database of conversations and messages, and the UI only observes it. When the app is in the foreground, I keep a WebSocket connection for real-time messages, typing and receipts, with reconnect and backoff. In the background the OS limits sockets, so new messages arrive through push notifications, which can wake the app to fetch. When the user sends a message, I create it locally with a client-generated ID and status "sending", show it immediately, and put it in an outgoing queue. The server acknowledges with the same ID so retries never duplicate. Message history loads with paging. Media is uploaded separately with resumable uploads and thumbnails. I would also consider end-to-end encryption with keys in secure storage, and limit battery and data use.
Can you answer it under time pressure?
Take a timed hard round and get scored on every answer.
More hard Mobile App Developer questions
- Your app has grown to 40 developers and one huge module. Builds are slow and teams block each other. How would you restructure it?
- A delivery app must track the rider location all day. How do you balance accuracy with battery life and OS limits?
- In a Flutter or React Native app, you need a feature that only exists in native SDKs, such as a payment terminal SDK. How would you integrate it well?
- How would you measure and improve app performance for real users in production, not just on your test phone?
- Users keep running old versions of your app for months. How do you evolve the API and decide when to force an update?
- Your crash reports show rising out-of-memory crashes after a release. How do you find and fix the problem?
- How would you implement secure login with an OAuth or OpenID Connect provider in a mobile app?
- How would you migrate a large UIKit or Android View app to SwiftUI or Jetpack Compose without stopping feature work?
- Millions of users have data in your app local database. How do you change the schema safely?