In a mobile design round for a food-delivery app, what belongs in the data-model and API sketch, and how deep should it go?
answer
- the nouns the screens show
- stable ids over field lists
- kept, displayed, or ephemeral
- one call per screen need
- names and fields, not wire format
basics
~20 sList the few entities the screens need with their ids, mark which the device keeps, then the handful of calls and messages per screen need. Stop at names and key fields; protocol, paging and retries are deep dives.
solid answer
~40 sFor the data model I'd write the nouns: `Restaurant`, `MenuItem`, `CartLine`, `Order` with its status, a courier position and `Address`, each with a stable id. Then I mark what the device keeps: the cart, saved addresses, the active and recent orders. Prices are displayed but owned by the server, confirmed by a quote before checkout, and courier positions are ephemeral. For the API, one line per screen need: search restaurants near a location, get a menu, quote the cart, place the order, get an order, a live channel for status and position, a status push, and push-token registration. That is the sketch: names, direction and key fields. Protocol, paging and retry rules are deep dives I'd offer later.
code
pseudocode · 17 linesentities
restaurant { id, name, open_now, eta }
menu_item { id, restaurant_id, name, price, options }
cart_line { menu_item_id, quantity, chosen_options } -- kept on device until checkout
order { id, status, lines, total, placed_at } -- active and recent kept
courier_position { order_id, location, at } -- latest only
address { id, label, location } -- kept on device
calls and messages
search_restaurants(location, page) -> restaurants
get_menu(restaurant_id) -> menu_items
quote_cart(lines, address_id) -> prices, fees, eta -- server decides the price
place_order(quote, payment) -> order
get_order(order_id) -> order
order_updates(order_id) [live] -> status, courier_position
push: order_status_changed -> { order_id, status }
register_push_token(token)go deeper
Recall the sketch's two halves: the nouns the screens show with their ids, and one call or message per screen need, written as names and key fields.
Explain which entities the device keeps and why, and which stay owned by the server even when shown on screen, such as prices confirmed by a quote at checkout.
Show you can stop at sketch depth: name protocol, paging and retry decisions as deep dives to offer, and spend the minutes on the entities that drive the design.
Use the sketch to expose ownership: one source of truth per entity and stable ids make the later sync, caching and contract trade-offs straightforward to argue.
## Why sketch the data and the API at all The client block diagram shows boxes and arrows, but not what travels along them. A short **data-model sketch** and **API sketch** fill that in: the nouns the screens show, and the calls and messages that move them. In a mobile design round they usually take a few minutes, right after the diagram, and they do two jobs. They prove the screens are covered, and they expose **ownership**: which data the device keeps, which it only displays, and which the server always decides. The trap is depth. The sketch is names, identifiers and key fields. It is not a schema, not a protocol and not an error catalogue. ## The entities For a food-delivery customer app (browse restaurants and menus, a cart and checkout, live order tracking with a courier on a map, a push on each status change) the nouns fall out of the screens: | Entity | Key fields | Identifier | Kept on the device? | |---|---|---|---| | `Restaurant` | name, open now, ETA | server id | Recently viewed only | | `MenuItem` | name, price, options | server id + restaurant id | Last menus browsed | | `CartLine` | menu item, quantity, chosen options | menu item id | Yes, until checkout | | `Order` | status, lines, total, placed at | server id | Active and recent orders | | `CourierPosition` | order, location, timestamp | order id | Latest only | | `Address` | label, location | server id | Yes | Identifiers matter more than fields. Stable ids are what let a screen, the store and an incoming update agree that they are talking about the same order. ## What the device keeps, and what it never owns The "kept on the device" column is the most useful part of the sketch, because it drives the storage and sync deep dives later. - **Kept:** the cart, saved addresses, the active order with its last-known status, and recent orders. These are what a reopened app must show without waiting for the network. - **Displayed but not owned:** prices, fees and promotions. The device may show cached menu prices while browsing, but the total the user is charged is the server's decision, confirmed by a quote before checkout. Each kind of data has one **source of truth**, and for a price that source is the server. - **Ephemeral:** courier positions. The tracking screen needs the latest one; the sketch says so and moves on. - **Never persisted as plain data:** payment card details. Name it as a security concern for later and do not design it here. ## The API sketch One line per screen need, written as a name, a direction and what it carries: 1. Search restaurants near a location, a page at a time. 2. Get a restaurant's menu. 3. Quote the cart: send the lines and the address, get prices, fees and an ETA. 4. Place the order against that quote. 5. Get an order by id, for a relaunch or a refresh. 6. A live channel from the server for one order's status and courier position. 7. A push message when the order's status changes. 8. Register the device's push token. That is the whole sketch. It shows the network client's workload and the two ways the server reaches the device: a live channel while the tracking screen is open, and push when it is not. ## How deep is deep enough Stop at names and key fields. Each of these is real work, but each is a **deep dive** to offer, not a sketch detail: - the protocol and payload format of each call; - how the restaurant list pages, and how duplicates are merged; - how placing the order survives a retry without charging twice; - which transport carries the live channel, and how it reconnects; - status codes and error shapes; - how old app versions keep working when a field changes. When the interviewer asks about one of them during the sketch, answer in a sentence and offer it as a deep dive. Settling it now spends the minutes meant for the whole design on one arrow. ## Common mistakes - **Writing a database schema.** Column types and indexes say nothing about the client's design. - **Mirroring the server.** Copying every server entity to the device costs disk and goes stale; the device keeps what it needs on relaunch. - **Computing prices on the device.** A client-computed total can disagree with the charge; the quote is the answer. - **Skipping the API entirely.** Without the calls the boxes carry nothing, and the interviewer cannot see how the screens are fed. A good sketch fits on a corner of the whiteboard and makes every later trade-off easier to point at.
- Should the cart live on the device or on the server?In the sketch I'd keep cart lines on the device, so the cart survives a restart and edits are instant, and treat prices as the server's: a quote re-prices the cart and checkout uses the quoted total. If the requirements say the cart follows the user across devices, the server owns it and the device caches it, which is a requirement to ask about, not guess.
- During the sketch the interviewer asks which protocol the live channel uses. Do you settle it now?Briefly, no. I'd say it is a server-to-device stream for one order's status and position, name the candidates, and offer it as a deep dive, because the choice turns on battery, reconnects and background limits. Settling it in the sketch spends the minutes meant for the whole design on one arrow.
- The data model should list every database column with its type.
- The device can compute the order total itself from the cached menu prices.
- Every entity the server stores should also be stored on the device.
- The API sketch needs final URLs, status codes and the protocol decided.
- The API can be skipped because the diagram already shows a network client.