Design every step so it is safe to kill and resume.
if retries < 5 { backoff(attempt) }
Foundations reels
Foundations1 / 3
1 / 5
Deal you never signed
Phones run on small batteries and limited memory, so Android and iOS both treat apps that are off screen as candidates for removal. Your process is a guest. The OS decides how long it stays, and it rarely asks first.
2 / 5
Android
When the user leaves your app, Android keeps the process cached for a while, then kills it without warning when memory runs short. Doze, App Standby Buckets and OEM battery managers on phones like Xiaomi or Oppo add further limits on when background work may run.
3 / 5
iOS
iOS suspends your app a few seconds after it leaves the screen. Suspended means frozen: no timers, no network callbacks, no code at all. Later the system may terminate it to free memory. Your code runs again only when the user opens the app or iOS grants background time.
4 / 5
What this means for design
Any work that matters must survive a kill at any line of code. That rules out long-running loops, in-memory queues and retry-in-a-minute timers. The question stops being how to stay alive and becomes how to resume.
In practiceInterview line: “I don’t keep the app alive. I make every step resumable.”
Interview answer
Say it in the interview
Mobile operating systems suspend and kill background apps to protect battery and memory, so I never design around staying alive. The app persists every unit of work before it starts, so work resumes after a kill at any line. The question I design for is how the app resumes, not how it survives.
1 / 5
Deal you never signed
Phones run on small batteries and limited memory, so Android and iOS both treat apps that are off screen as candidates for removal. Your process is a guest. The OS decides how long it stays, and it rarely asks first.
2 / 5
Android
When the user leaves your app, Android keeps the process cached for a while, then kills it without warning when memory runs short. Doze, App Standby Buckets and OEM battery managers on phones like Xiaomi or Oppo add further limits on when background work may run.
3 / 5
iOS
iOS suspends your app a few seconds after it leaves the screen. Suspended means frozen: no timers, no network callbacks, no code at all. Later the system may terminate it to free memory. Your code runs again only when the user opens the app or iOS grants background time.
4 / 5
What this means for design
Any work that matters must survive a kill at any line of code. That rules out long-running loops, in-memory queues and retry-in-a-minute timers. The question stops being how to stay alive and becomes how to resume.
In practiceInterview line: “I don’t keep the app alive. I make every step resumable.”
Interview answer
Say it in the interview
Mobile operating systems suspend and kill background apps to protect battery and memory, so I never design around staying alive. The app persists every unit of work before it starts, so work resumes after a kill at any line. The question I design for is how the app resumes, not how it survives.
What the OS actually does to your app
#lifecycle
❚❚
Foundations2 / 3
1 / 5
Two ways to build an app
A network-first app asks the server for data each time a screen opens and shows a spinner until it answers. An offline-first app reads a local database instantly and treats the network as something that happens later. The second feels faster and keeps working in a lift, a basement or on a plane.
2 / 5
One source of truth
In offline-first design the UI never reads from the network. It observes the local database. New server data goes into the database, and the screen updates because the query it watches changed. The screen gets data from exactly one place.
3 / 5
Writes are local too
When the user creates or edits something, the app writes it locally and returns at once. The screen updates in milliseconds. Sending that change to the server is a separate job that may run seconds or hours later.
4 / 5
Price you pay
You now own a sync problem: pending changes, conflicts, deletes and schema versions across devices that may stay offline for weeks. Every other course in this feed is about paying that price well.
In practiceA technician fills a 20-field form underground. It saves instantly and reaches the server when she walks back outside.
Interview answer
Say it in the interview
Our UI reads only from a local SQLite database, which is the single source of truth. Writes land locally first and sync later, so the app is instant and works with no signal. The trade-off is owning a sync protocol, which I treat as a core part of the product rather than plumbing.
1 / 5
Two ways to build an app
A network-first app asks the server for data each time a screen opens and shows a spinner until it answers. An offline-first app reads a local database instantly and treats the network as something that happens later. The second feels faster and keeps working in a lift, a basement or on a plane.
2 / 5
One source of truth
In offline-first design the UI never reads from the network. It observes the local database. New server data goes into the database, and the screen updates because the query it watches changed. The screen gets data from exactly one place.
3 / 5
Writes are local too
When the user creates or edits something, the app writes it locally and returns at once. The screen updates in milliseconds. Sending that change to the server is a separate job that may run seconds or hours later.
4 / 5
Price you pay
You now own a sync problem: pending changes, conflicts, deletes and schema versions across devices that may stay offline for weeks. Every other course in this feed is about paying that price well.
In practiceA technician fills a 20-field form underground. It saves instantly and reaches the server when she walks back outside.
Interview answer
Say it in the interview
Our UI reads only from a local SQLite database, which is the single source of truth. Writes land locally first and sync later, so the app is instant and works with no signal. The trade-off is owning a sync protocol, which I treat as a core part of the product rather than plumbing.
Offline-first, explained properly
#architecture
❚❚
Foundations3 / 3
1 / 6
Disk before network
The UI reads only the local database, and every pending action becomes a row on disk before any request starts. If the app dies a millisecond later, the intent is still there for the next run to find.
2 / 6
Idempotent and resumable
Every change carries a client-generated ID, so sending it twice is harmless. Cut work into small units, and commit progress after each one. Failure stops being an edge case and becomes a path the code walks every day.
3 / 6
Let the OS schedule
You declare what the work needs, such as a network, charging or free storage, and the OS picks the moment. No wake locks, no polling loops, and no services you hope will survive.
4 / 6
Records and bytes are different
Small structured records sync through your API. Large files go straight to object storage. They fail in different ways, so they get separate pipelines, retry rules and progress tracking.
5 / 6
Server orders, the client observes
The server decides the order of changes and applies the conflict policy; clients never trust their own clocks. And every sync run emits metrics, because a broken sync system fails silently: data just goes stale.
Interview answer
Say it in the interview
My rules are disk before network, idempotent and resumable work, OS-scheduled execution, separate pipelines for records and bytes, and server-assigned ordering. Together they make failure a normal path. Each exists because a phone can lose power, signal or its process at any moment.
1 / 6
Disk before network
The UI reads only the local database, and every pending action becomes a row on disk before any request starts. If the app dies a millisecond later, the intent is still there for the next run to find.
2 / 6
Idempotent and resumable
Every change carries a client-generated ID, so sending it twice is harmless. Cut work into small units, and commit progress after each one. Failure stops being an edge case and becomes a path the code walks every day.
3 / 6
Let the OS schedule
You declare what the work needs, such as a network, charging or free storage, and the OS picks the moment. No wake locks, no polling loops, and no services you hope will survive.
4 / 6
Records and bytes are different
Small structured records sync through your API. Large files go straight to object storage. They fail in different ways, so they get separate pipelines, retry rules and progress tracking.
5 / 6
Server orders, the client observes
The server decides the order of changes and applies the conflict policy; clients never trust their own clocks. And every sync run emits metrics, because a broken sync system fails silently: data just goes stale.
Interview answer
Say it in the interview
My rules are disk before network, idempotent and resumable work, OS-scheduled execution, separate pipelines for records and bytes, and server-assigned ordering. Together they make failure a normal path. Each exists because a phone can lose power, signal or its process at any moment.