In a mobile system-design round for a food-delivery app, which boxes go on the client block diagram and how does data flow between them?
answer
- seven boxes, one job each
- screens read state, never the network
- the store is what screens observe
- network, sync and push write in
- arrows matter as much as boxes
basics
~20 sDraw UI, state holders, repository, local store, network client, sync engine and push handler. Screens render what state holders expose, state holders read the repository, and network, sync and push all write into the local store the repository serves.
solid answer
~40 sI'd draw seven boxes. The **UI** renders state and sends user events; a **state holder** per screen (a view model or presenter) handles those events and exposes screen state. The **repository** is the single door to each kind of data (restaurants, menus, cart, orders) and serves it from the **local store**, which the screens observe. The **network client** talks to the backend, the **sync engine** keeps the store in step with the server without a screen involved, and the **push handler** receives order-status pushes from the OS. The arrows matter as much as the boxes: reads flow store, repository, state holder, UI, and every change from the network, sync or push lands in the store first, so a screen updates the same way whatever caused the change.
go deeper
Recall the seven boxes from screen to server and give one job for each. Draw the arrows: reads flow up to the UI, and changes from the network, sync and push land in the store.
Explain why the store sits between the network and the screen: one owner per kind of data, the same update path whatever caused a change, and an app that still shows something after a restart.
Treat the diagram as a convention to argue, not recite: say which box this app could merge, and name the boxes you will open later instead of explaining them while drawing.
Use the diagram as the shared map for the whole round: every later trade-off should point at a box and an arrow, which keeps the discussion on the client rather than drifting to server design.
## What the client block diagram is for In a mobile system-design round the interviewer asks you to design one installed app end to end. After the requirements are pinned down, the next step is a **client block diagram**: a handful of boxes that show how the app is put together and how data moves through it. It is the map the rest of the round is argued on. The seven-box shape below is a **convention of the mobile design round, not a standard**. It is the common starting point because almost every data-driven app needs these jobs done somewhere. You present it as that common shape, then argue each box for the app in front of you. For a food-delivery customer app (browse restaurants and menus, build a cart, check out, track the order with a courier on a map, get a push on every status change) it fits closely. ## The seven boxes and what each owns | Box | What it owns | In the food-delivery app | |---|---|---| | **UI** | Rendering state and capturing user input | Restaurant list, menu, cart, checkout, order-tracking map | | **State holder** | One screen's state and its event handling; lives as long as the screen | The cart screen's view model or presenter | | **Repository** | The single door to one kind of data, combining local and remote sources | Restaurants, menus, cart, orders, addresses | | **Local store** | Data on disk that outlives the process; what screens observe | The active order, the cart, saved addresses | | **Network client** | Every call to the backend, with shared concerns such as auth | Search, menu, quote, place order, live order updates | | **Sync engine** | Keeping the store in step with the server with no screen involved | Refreshing the active order; applying incoming updates | | **Push handler** | What happens when a push arrives from the OS's push service | An order-status push, written into the store | A useful test for each row: **what does this box own that no other box owns?** If you cannot answer, the box is decoration. ## The arrows: one direction for data, the other for events The arrows say more than the boxes. A clean diagram has two paths. 1. **The read path.** The local store holds the data; the repository exposes it; the state holder turns it into screen state; the UI renders that state. Data flows one way, toward the screen. 2. **The event path.** The user taps "place order"; the UI sends the event to the state holder; the state holder calls the repository; the repository calls the network client, and the result is written into the store. The new state then reaches the screen along the read path. 3. **The outside-world path.** The sync engine and the push handler write into the store too, through the repository. Neither of them talks to a screen. This is the **unidirectional data flow** idea applied to the whole client: state flows down to the UI, events flow up to whoever owns the data, and each kind of data has a **single source of truth**. ## Why every write lands in the store first Routing every change through the store gives three properties an interviewer looks for: - **One update path.** Whether the order status changed through a refresh, the sync engine or a push, the tracking screen sees it the same way. - **Survival.** On both native platforms the operating system may end a backgrounded app's process to free resources. Data that lives only in a state holder or in a screen disappears with it; data in the store is there on relaunch. - **No second owner.** If the tracking screen fetched the order itself, there would be two copies of the order, and the push handler would have no way to reach the screen's copy. Not every kind of data must be persisted. A repository's source of truth can be the network for data the device must never treat as its own, such as a price the server will charge. The diagram only needs to make that ownership visible. ## What the diagram deliberately leaves out The diagram names boxes; it does not explain them. Each of these is a deep dive owned by its own part of the round, named in one clause and parked: - where the decision to show cached or fresh data lives (layering); - which transport keeps the courier position live, and how it reconnects (real-time); - how an order placement survives a retry on a bad network (the request pipeline); - what goes on disk, how long, and how the store's schema migrates (storage); - how menu images load and cache (media). ## How to draw it in the interview 1. Draw the UI at the top and the network client at the bottom, with the store in the middle, so the read path is visibly vertical. 2. Add the state holders and the repository between them, then the sync engine and push handler at the side, both pointing into the store. 3. Label each box with the food-delivery data it owns, not just its generic name. 4. Say one sentence per box about why this app needs it, and offer the boxes you will open later.
- Why not let the order-tracking screen call the network client directly?Because the screen would then own a second copy of the order with its own fetch logic. The push handler and sync engine could not reach that copy, the order would vanish when the OS ends the process in the background, and two screens showing the same order could disagree. Going through the repository keeps one owner for order data; the screen only observes it.
- Where does the live courier position fit on this diagram?It enters through the network client, over whichever live channel the real-time deep dive picks, and reaches the repository like any other server data, so the tracking screen observes it instead of owning a connection. Whether only the latest position is kept is a storage detail to name and park, not something to draw.
- Each screen fetches its own data straight from the network client.
- The push handler updates whichever screen happens to be visible.
- A state holder alone keeps the cart and orders safe across a process restart.
- The seven-box diagram is a standard that must be drawn exactly as given.
- Boxes are what count; the arrows between them can be left vague.