Read this story as text
Ten minutes to the door: the story, written out
Nami orders a Diet Coke and the AWS architecture behind a 10-minute delivery builds up on screen: the home feed, search, checkout, rider dispatch and live tracking. An interactive, voiced story. Free, no signup.
- I order a Diet Coke from Zepto. Within ten minutes, I have it.
- Like me, around 9.5 million people get their order within 11 minutes.
- I'm Nami. Let's build the engineering behind those minutes on AWS, starting from the first tap.
The home screen
- Tap the icon. I open the Zepto app, and I see something loading. Hmm...
- A skeleton loader. A skeleton loader! The app has sent a request to the server.
- Who is knocking? The server's front door is API Gateway, and it first checks who I am. Servers are completely unbiased: show them a stolen token and they will happily serve a hacker as me. So use MFA, strong passwords, and rotate them when you can.
- Three searches at once. Then the home service searches in parallel: what do I usually buy? Anything festive? And what deliverable stock is near me?
- What I usually buy. My habits live in a DynamoDB table. Diet Coke every four days. Milk every second day. No judgement, just arithmetic. And here is the twist: this list was made last night, not now.
- Diwali, for everyone. Festive picks are the same for everyone nearby: diyas, rangoli colours, mithai. So we keep one copy in memory, in ElastiCache. A million people, one cache.
- Is it on the shelf? Then the question that ruins evenings: is it in stock? Only my nearest store, the one that can deliver in ten minutes, counts. Out of stock? Quietly removed. You will never know.
- Put the right things first. A small ranking model on SageMaker puts my usuals first and mixes in festive picks. It is a tiny model, not a giant one, so it answers in a few milliseconds.
- The page appears. And there it is, in under two hundred milliseconds. Diet Coke, milk, tomatoes, a box of mithai. Ah, there is my Diet Coke.
- Same app, same time. Meanwhile, my friend Falak opens the same app. She sees protein bars, maggi, and a diya. Same app, same time, a completely different set of products.
- Millions of us. And around 2.5 million people order on Zepto every day. We do not think harder, we think earlier. The clever work happened before. Now it is only lookups.
- How did it know? Every tap I ever made travelled into a Kinesis stream. At night, a model learned my habits and wrote my page in advance. By morning, my Diet Coke was already waiting.
- Add to cart. I add Diet Coke, milk, and tomatoes. Each tap is a tiny write into my cart, plus a quick recheck of stock and price.
Search
- Open search. Now I want yogurt. I tap the search bar, and before I type a single letter, it shows my recent searches. That is just a small lookup of my own history in DynamoDB.
- Typing. I start typing: y, o, g. Every letter sends a tiny request, and the answer comes from memory, not from a search. A cache of the most common words that start with these letters. It has to feel instant, or typing feels broken.
- The list is mine. The list is ordered for me. I bought yogurt before, so yogurt comes first. Someone who never eats it would see yoga mat on top.
- Search for yogurt. I tap yogurt. Now the real search starts. The search service asks an OpenSearch index which products match. It finds every yogurt in the catalogue, in a few milliseconds.
- Only what I can get. But the catalogue has hundreds of yogurts, and my store has only a few. So each match is checked against live stock at my nearest store. Available ones go first, the rest go into a separate section.
- The results. And here they are. Available yogurts first, with brands and prices. Below them, the ones my store does not have, each with a Notify me button.
- Notify me. I tap Notify me on the blueberry one. That saves a single row: me, and this yogurt. When the warehouse scans new stock in, an event finds everyone waiting and sends a push. I do not have to keep checking.
- Add the yogurt. Now I add the Greek yogurt to my cart. The same tiny write as before, and a recheck of stock and price.
Checkout
- The cart. Now I open my cart: four items, my address, a coupon, and a Pay button. Every plus and minus is a tiny write to the server, and the discount is worked out there too, not on my phone.
- One tap, one order. I tap Pay. The order service saves my order as pending, with a unique key. If my phone retries, or I tap twice in panic, the key says: same order.
- A workflow, not a function. An order is not one action. Hold the stock, charge the card, confirm. If one function does all of it and crashes halfway, you get a mess. So a Step Functions workflow keeps the list and remembers where each order is.
- Hold the milk. First step: hold the stock. One conditional update: take one only if one is free. If two people tap for the last milk at the same moment, the database picks a single winner.
- Charge the card. Now the payment. A Lambda calls the payment provider, with the order key on the request. If my connection drops and it retries, the card is still charged only once.
- The bank takes its time. Banks are slow. The provider answers later, by calling a webhook on API Gateway. Until then the workflow just waits, and waiting costs nothing. When the webhook arrives, it wakes up.
- If the card fails. What if the card is declined? Every step has an undo. The workflow cancels the order and releases the milk. No half-finished orders, no manual clean-up.
- Order placed. Paid. One event goes on the bus: order placed. The warehouse, notifications and analytics each listen on their own, and my phone gets a push. Ten minutes, the clock starts now.
Dispatch
- Order packed. My order is placed. In the store, a picker is already packing it. When the bag is sealed, they scan it, and the system announces one thing: order packed.
- Who is nearby? That starts a dispatch workflow. It needs riders near this store. Asking four hundred riders where they are would be slow, so a live map in memory already knows. Riders within three kilometres is one quick lookup.
- Nearest by road. Nearest on the map is not nearest by road. A rider across a river is a bad pick. So the closest twenty get scored on real road time, with Amazon Location, and on how many orders they already carry.
- One offer at a time. The best rider gets the offer as a push notification, with a thirty second timer. Just one rider at a time. Offering to ten would leave nine of them staring at a sorry, gone message.
- Accepted, once. Asha taps accept. One conditional write: this rider is free, make her busy. If Ravi tapped at the same moment, only one of them wins. Mine is Asha, and my phone shows her name.
- If nobody answers. What if she never answers? Her phone is in a pocket, her gloves are on. After thirty seconds the workflow moves on to the next rider. And if nobody is free, it widens the circle from three kilometres to five.
- Picked up. Asha reaches the store, scans my bag, and rides off. The clock is still running. Next, I watch her ride on my map.
Live tracking
- The dot. Asha has my bag, and my map shows her as a moving dot. Her rider app sends her location every few seconds, to the same front door as everything else.
- A flood of pings. Thousands of riders send a location every few seconds. Writing each one straight into a database would melt it. So every ping first drops into a Kinesis stream, a buffer that soaks up the burst.
- Only the latest spot. A Lambda reads the stream and keeps only the newest ping per rider, in one DynamoDB row that gets overwritten. Where she was a minute ago is not interesting. Where she is now is.
- My screen stays connected. My phone opens a WebSocket to API Gateway, a connection that stays open. The server saves my connection id next to my order, so it knows who is watching Asha.
- Push, not poll. When her row changes, a stream wakes a function. It looks up who is watching and pushes her new position down my connection. My phone never asks where she is. The server tells me, and the dot moves.
- An ad on the same screen. Now look at the bottom of the screen: a credit card ad. People watch this screen for ten minutes, so it earns money. But the ad must never slow the map. It is a separate call with its own short deadline. If it is late, the map goes first and the ad just does not show.
- Which ad? Which ad? An ad service picks from campaigns held in memory: this city, this kind of customer, a limit of three views a day, and a budget that has to last the whole month. It decides in a few milliseconds, because everything it needs is already in memory.
- Counting views and taps. Every view and every tap on the ad is an event, with a unique id so it is never counted twice. They flow through a Kinesis stream into counters. Advertisers are billed from those counters, so the counters have to be right.
- Delivered. Asha reaches my door. One last push, the doorbell, and it is done, in nine minutes and forty seconds. Diet Coke, milk, tomatoes, and the Greek yogurt.
More stories on Real-world systems