Build a Food Delivery Platform
A food delivery platform keeps taking orders and charging cards while its kitchen tablets are unreachable, and 212 customers pay for food that no kitchen ever saw. You will build the replacement, from menus and card holds through the kitchen, couriers, refunds and payouts, and prove it survives a simulated dinner peak with failures injected.
The brief
The client
I run operations at a food delivery platform in one mid-sized city. We list about 120 independent restaurants, take about 1,000 orders a day and have up to 120 couriers on shift at dinner, all on one application that handles the cart, the card charge, the kitchen tablets and the courier app.
During one Friday dinner peak the connection to our kitchen tablets dropped for 2 hours 40 minutes. The customer side stayed up, so it kept taking orders and charging cards. 212 customers paid for food no kitchen ever saw, waited 50 minutes or more and cancelled, and my team refunded them by hand over the weekend.
Our accountant then found that courier tips were counted toward the base pay we promise for each delivery. A courier kept none of the tip the customer meant for them, and nobody had decided that. I need a platform where a card hold, a kitchen and a courier always end in the same outcome, and where I can show a restaurant, a courier or a bank exactly where each cent went.
The problem
Today nothing can answer whether the money, the kitchen and the courier agree about an order. When the kitchen side fails, the customer side keeps selling, because taking payment never waits for a restaurant to say yes. Nobody has decided what customers, restaurants and couriers can still do when one capability is down, so a fault in one place is a fault everywhere.
Every refund is a manual edit of an order total. A missing item refunded after the card was charged and one refunded before it end with different amounts, and nobody can say which is right. The card provider keeps its fee on a charge that is refunded later, and nobody has booked that cost anywhere. Commission, courier pay, tips, refunds and payouts are recomputed from order totals at the end of the week, which is how tips were absorbed into base pay.
Couriers' positions are kept forever next to their orders. A bank dispute is answered with screenshots, because nobody recorded who delivered the order or when. Restaurants ask for a weekly statement that matches their own till, and ours does not.
The client's name and figures are invented for this brief; the rules and the failures are ones that real businesses of this kind work with.
The spec
Requirements
- Let a restaurant be onboarded with a recorded consent, then publish a menu with modifiers, tax rates, allergen tags and opening hours, and mark items sold out.
- Let a customer filter a menu by allergen, build a basket and see a total with tax, delivery fee, service fee and tip that equals what is charged.
- Create one order and one card hold however often, and however simultaneously, the same order is submitted.
- Hold the card before the kitchen is asked, handle a bank challenge, and take money only for an order the kitchen accepted and only for the lines that were delivered.
- Deliver each order to the restaurant's tablet in a form the restaurant can check, take its answer within 5 minutes, and release the hold when the order is rejected, unanswered or cancelled.
- Offer each accepted order to one courier at a time, give it to exactly one, offer it again if the courier declines or never arrives, and show the customer a live tracking view with the order's status and an ETA.
- Show where every cent of a completed order went, including the card provider's fee, keep tips apart from courier base pay, and pay restaurants and couriers weekly with a statement each can check.
- Let support refund a customer fully or partly, attribute the cost to the restaurant, the courier or the platform, and answer a bank dispute with order evidence.
- Keep customers, restaurants and couriers working as stated while menu publishing, card payments, the kitchen connection, courier dispatch, tracking, refunds or payouts is stopped, change one visible rule while orders keep arriving, and give an operator what is needed to trace an order, retry what could not be processed, and pause a restaurant or a zone.
Deliverables
- Your repository starts the whole platform with one command, plus a way to play the customers, the restaurant tablets, the couriers and the payment provider's messages, with a clock you control so a day runs faster than real time.
- A fake payment provider you built, able to decline a card, ask for a bank challenge, answer late, answer twice, answer out of order, time out, expire a hold, open a dispute, keep its fee on a charge that is refunded later and fail on demand.
- A README that takes a reviewer from a fresh clone to an order placed, accepted, delivered, paid and shown on the restaurant's statement in 15 minutes, and lists the command that runs each test.
- A worked example of one order's money, by hand, that the platform reproduces to the cent.
- Documentation for a restaurant's tablet integration: the requests the platform sends, how to verify their signature, and the answers it accepts.
- A test suite covering every failure test the Phases pose, plus the results of the simulated dinner peak from the final Phase committed to your repository.
- An operations note stating how an operator traces an order, retries what the platform could not process, pauses a zone or a restaurant, reverses a payout, and stops and restarts each of the seven capabilities named in the requirements.
Out of scope
- Real maps, geocoding or route optimisation. Zones and a fixed travel-time table are enough to teach dispatch, and routing is a research field of its own.
- Customer and courier mobile apps. An HTTP interface and the simulator stand in for them.
- A real payment provider or real card data. A fake provider that mimics holds, partial captures, expiry and disputes keeps the build on one machine and keeps card data out of your repository.
- Integrating with real restaurant point-of-sale vendors. A simulated tablet is enough, because each vendor integration is a separate project of mapping item codes and failed-order states.
- Batching or stacking, one courier carrying two orders. It turns offers into a matching problem and doubles the dispatch rules, so one order per courier keeps the offer rule checkable.
- Promotions, vouchers and loyalty. Each one adds a pricing rule, and the brief wants the pricing rules fixed and few.
- Ratings and reviews. They add moderation and aggregation and say nothing about the coordination between a payment, a kitchen and a courier.
- Courier employment classification. The brief states no rules on employee versus contractor status.
- Real bank transfers for payouts. A payout ends at a statement and the amounts behind it, and moving the money is the client's bank.
- Push, SMS or email notifications. The tracking view is how the customer learns an order changed.
- Machine-learned prep times or ETAs. The platform records the waiting time such a model would need, and nothing learns from it here.
- Payment methods that cannot be held. They need a different flow, pay first and refund on rejection, and would double the rules for ending an order.
- Kubernetes or cloud deployment. Everything runs on one machine.
- Payment methods other than cards, such as iDEAL. The platform takes cards only, because the card is held before the kitchen accepts and charged after, and iDEAL takes the money at once.
Architectural constraints
- Amounts are in euros and exact to the cent. No amount is ever rounded in a way that makes a total differ from the sum of its parts.
- No card number is ever stored.
- Money is never taken for an order the kitchen has not accepted.
- Every order ends in exactly one outcome, and no card hold stays open past its deadline.
- Whatever fails, no order is lost, no order is doubled and no deadline fires twice.
- A stopped capability delays only the work that needs it. Everything else keeps working.
- Tips and courier base pay are never counted against each other.
- The customer's name, phone and delivery address are seen by a courier only while that delivery is active.
- A courier's position is kept only while the courier is on shift, and each position is deleted 30 days after its delivery.
- Personal fields are erased on request, while financial, tax and order-evidence records stay for 7 years, identified by ID only.
- The platform never deactivates a courier on its own. It raises a flag that an operator decides on.
Prerequisites
You have finished an intermediate project or have equivalent experience, on any stack. You do not need prior experience with payments or with products that keep working while part of them fails, and you do not need to know how a food delivery platform works; the first Phase explains the business and the words the brief uses. The brief has you build the fake payment provider yourself, so no account with a payment company is needed. Having once chased a refund that came out different depending on when it was issued will make most of this brief feel familiar.
Free to start. An account is what keeps track of the checkpoints you finish.
Map the platform
Produces the written map of one order (who takes part, what each party sees and does, every deadline), one order's money worked by hand to the cent, and a way to start the platform with one command and move a clock you control. Runs no customer order yet.
Acceptance criteria
Your repository holds a document that records one order from placement to payout. It names every party (the customer, the restaurant, the courier, the bank and the operator), says what each one sees and does at each step, and says which of them can see the customer's name, phone and delivery address and the courier's name and phone.
The same document lists every deadline with its number and says what the customer, the restaurant or the courier experiences when it passes: the bank challenge (10 minutes from the hold request), the restaurant's answer (5 minutes from the order reaching the tablet), the courier offer (45 seconds), the courier's arrival (10 minutes past the promised time), the longest wait for a courier (15 minutes after the food is ready), the card hold (7 days), the report window (30 minutes after delivery), the start of preparation for a scheduled order (30 minutes before the requested delivery time), the evidence window for a bank dispute (7 days) and the weekly payout.
For each part of the day the client names (browsing menus, paying by card, reaching the kitchens, finding couriers, tracking an order, refunds, payouts), the document says what the other parts of the day keep doing while it is unavailable. No answer says that the order fails or that money is lost.
Architectural guidance
Each party to an order will invent its own deadline unless one document says what the number is and what follows when it passes. A deadline nobody wrote down is the Friday outage: nothing noticed the wait was over, and 212 customers paid for food that no kitchen was cooking. The answers about unavailable parts matter most, since a platform that stops selling everywhere when one part fails has rebuilt the single application the client is replacing.
Acceptance criteria
A worked example exists in your repository that a reader can check with a calculator. Food prices include tax. The basket has two lines of 1,500 and 1,300 cents and a tip of 200 cents. The document shows the food tax taken out of each line (9 percent of the tax-included price, which is the price times 9 divided by 109, rounded half up per line: 124 and 107, so 231), the delivery fee of 249 cents and its tax (21 percent taken out of the fee: 43), the service fee of 5 percent of the 2,800 cent subtotal (140 cents, tax 24), the total fee tax of 67, and the customer's total of 3,389 cents. The tip is not taxed.
It then shows who is owed what. The commission is 20 percent of the food subtotal without tax (2,800 minus 231 is 2,569, so 514). The restaurant is owed 2,055 cents plus 231 cents of food tax. The platform keeps 514 cents of commission and 322 cents of fees net of tax, and owes 67 cents of tax. The courier is owed 350 cents of base pay and the 200 cent tip. The shares add up to the customer's total, and the document shows the sum. The courier's base pay is paid by the platform out of its own share, so the platform keeps 486 cents before its own tax.
The card provider keeps a fee of 1.5 percent of the amount charged plus 25 cents, rounded half up: 76 cents on the 3,389 cents. The fee is the platform's own cost and comes out of its share, so the platform keeps 410 cents before its own tax. The restaurant and the courier are owed the same amounts whatever the provider charges.
Two variants are worked the same way. In the first, the second line is sold out after placement: food 1,500, food tax 124, service fee 75 (tax 13), delivery fee 249, tip 200, total 2,024, 1,365 cents of the original 3,389 no longer owed, commission 275, restaurant owed 1,101, provider fee 55. In the second, the customer cancels after the restaurant accepted: only the 2,800 cent food subtotal is charged, the restaurant is owed 2,055 plus 231 tax, the commission is 514, the provider fee is 67, and the delivery fee, service fee and tip are given back. The document states that the tip stays with the courier on any order that has a delivery, and is returned only when nothing was delivered.
Architectural guidance
A money rule that lives only in code gets changed by whoever fixes the last bug. A figure agreed in writing before anything is built is the number the finished product must reproduce, so a rounding difference shows up as a failed comparison with 3,389 and 2,055 and not as a restaurant's statement that is a cent off its till. Taking the tax out of each line before rounding matters because rounding the whole order once gives a different cent on some baskets, and the client's accountant finds those weeks later.
Acceptance criteria
A fresh clone starts the whole platform with one command from your repository root. The README names the command and the single IANA time zone you chose for the platform's weeks and reports. When the command settles, a reviewer can see that the platform is working and what time it believes it is. Running the command a second time on a machine that already has data changes nothing and loses no data. Stopping any one of the seven areas of the day named in the map of the order and starting it again brings it back without restarting the rest.
A simulator in your repository, given a seed, plays the client's cast: 120 restaurants, 300 couriers of whom 120 are on shift at the dinner peak, customers, and the 6 zones Z01 to Z06. It can play customers, restaurant tablets, couriers and the bank's messages. Running it twice with the same seed gives identical output, and a different seed gives different identifiers. The simulator reads the client's reference data, which you write down from this text. The city has 60 postcodes, 1001 to 1060, ten per zone, so 1001 to 1010 is Z01, 1011 to 1020 is Z02, and so on up to Z06. Travel time between zones in minutes, and 6 minutes inside a zone, is this table:
from_zone,Z01,Z02,Z03,Z04,Z05,Z06
Z01,6,11,14,18,22,17
Z02,11,6,9,15,19,21
Z03,14,9,6,10,16,20
Z04,18,15,10,6,8,13
Z05,22,19,16,8,6,10
Z06,17,21,20,13,10,6The simulator also controls a clock. With one command it moves the platform's time ahead by a number of hours you pass, without waiting. Afterwards the platform shows the new time everywhere it shows a time, within one second, and a deadline that falls inside the jump has passed. Without simulation the platform uses the real time. The README lists the command that runs each test the brief asks for, so a reviewer can find them.
Architectural guidance
A reviewer who cannot start the platform in a few minutes will not trust the dinner peak at the end, so the start command is part of the product. The clock exists because a 5 minute answer window and a 7 day card hold cannot be waited out. A product that reads the real time anywhere ignores a jump and fails every deadline test later, when it is expensive to find out.
Architectural walkthrough
How a food delivery platform gets a meal from a kitchen to a door
The platform lists about 120 independent restaurants in one city and takes about 1,000 orders a day, with up to 120 couriers on shift at dinner. A restaurant publishes a menu with modifiers, tax rates, allergen tags and opening hours, and marks items sold out. A customer filters the menu by allergen, builds a basket and sees one total made of the items, tax, delivery fee, service fee and tip.
The platform does not cook or deliver anything itself. When a customer orders, the platform holds the amount on the card and sends the order to the restaurant's kitchen tablet. The restaurant has 5 minutes to accept or reject it. After it accepts, the platform offers the order to one courier at a time until one takes it, and the customer watches the order's status and an estimated arrival time. Money is taken only for the lines that were delivered.
Each week the platform pays every restaurant and every courier and gives each a statement. Support handles refunds and answers disputes raised through a customer's bank.
The words this brief uses:
Modifier: a choice added to a menu item, such as a size or an extra.
Hold: an amount set aside on the customer's card without taking it. It is released if the order does not go ahead.
Capture: taking the money, which can be less than the hold.
Kitchen tablet: the device in the restaurant that receives orders and sends back the restaurant's answer.
Offer: the platform asking one courier to take an accepted order. The courier can decline.
Base pay: the amount the platform promises a courier for each delivery.
Tip: money the customer adds for the courier, kept apart from base pay.
Commission: the share of an order the platform keeps from the restaurant.
Statement: the weekly list of what the platform paid a restaurant or courier and why, which they check against their own records.
Dispute: a customer asking their bank to reverse a charge. The platform answers with order evidence.
Why the map comes first
No customer order runs in this Phase. It exists because of what a team learns on the first Friday it builds without it.
Everyone who touches an order holds a different idea of who is involved, what each person must do by when, and what the money comes to. When those ideas are written down after the platform is built, the first comparison happens in the weekly payout, where a courier's tip has already been counted toward the base pay the client promises. Nobody decided that, and nobody could see it.
The client's Friday was a deadline nobody owned. The connection to the kitchen tablets dropped for 2 hours 40 minutes, the customer side kept taking cards, and 212 customers paid for food no kitchen saw. Nobody's job was to notice that the 5 minutes a restaurant gets to answer had passed.
Money has the same problem. If the 3,389 cents of the worked basket is not agreed to the cent before anything is built, the first disagreement about a total has no right answer to check against. It surfaces on a restaurant's statement that does not match its till.
Deadlines of 5 minutes, 10 minutes and 7 days also cannot be tested by waiting. A product that can only be exercised in real time gets checked once, by hand, and then trusted.
Place an order
Produces menus customers always see in their newest form, an allergen filter, a basket total that equals the charge, and an order that is created once however often it is submitted. Leaves the card, the kitchen and the couriers for later Phases.
Acceptance criteria
A customer builds a basket of lines (a menu item, a quantity and chosen modifiers) with a tip and sees a total that is exactly what will be charged: food subtotal, food tax, delivery fee, service fee, fee tax, tip and total, all in whole cents. Modifier prices are added to the item's price before the tax is taken. Food tax is 9 percent, taken out of each tax-included line and rounded half up per line. The delivery fee is 249 cents. The service fee is 5 percent of the food subtotal, rounded half up. The tax on both fees is 21 percent, taken out of the fee. The tip is not taxed.
The basket from the worked example (lines of 1,500 and 1,300 cents, tip 200) shows a food subtotal of 2,800, food tax of 231, service fee of 140, fee tax of 67 and a total of 3,389. A quantity of zero, a negative tip, an item that is not on the menu the basket was built from and an amount that is not a whole number of cents are each refused and priced as nothing.
A test generates enough baskets to cover odd prices, large quantities and many modifiers. For each one the total equals the sum of its parts, every tax amount is between zero and the price it is taken from, and pricing the same basket twice gives the same total.
Architectural guidance
A total that is right for most baskets and one cent wrong for a few ends up on a restaurant's statement weeks after the order, when nobody remembers the basket. Taking the tax out of each line and rounding once per line is the client's rule, and rounding the whole order at once gives a different cent on some baskets. A basket priced against a menu that has since changed shows the customer a total the platform will not charge.
Acceptance criteria
A customer places an order with an Idempotency-Key header, a restaurant, lines, a tip, a name, a phone, a delivery address and, optionally, a requested delivery time up to 48 hours ahead. The key is a value the customer's app chooses for one placement and repeats on every retry, so the platform can recognise the retry. The first request returns the order and its amounts. The same key with the same request returns the same answer and no second order. The same key with a different request is refused.
However many times, and however simultaneously, a placement is sent, exactly one order exists. A test sends the same placement many times at once and counts one order. Keys are kept for 24 hours: a test that moves the clock forward by 24 hours and one second and sends the same key again gets a new order.
A request is refused and stores nothing when the header is missing, when the restaurant has no recorded consent, is paused, or is closed at that moment in its own time zone, when an item is unavailable, when the delivery postcode belongs to no zone, or when the requested delivery time is in the past or more than 48 hours ahead. Until a courier is assigned, no courier-facing view shows the customer's name, phone or address.
A test kills the process between storing the order and answering the customer. Afterwards the customer sends the same placement again and receives the one order. No run leaves a customer told the order was placed with nothing stored.
Architectural guidance
Customers double-tap, and phones retry on a bad connection because a client that times out cannot tell a lost request from a lost response. Without protection the client refunds duplicate orders by hand and some customers see two charges. An address in no zone is refused at the door, because an order no courier can ever serve would wait with the customer's money reserved and nobody responsible for it.
Architectural walkthrough
Phones retry, customers double-tap, and a menu changes while a basket is open. The client has paid for each of these. A placement sent twice becomes two orders, and the client refunds one of them by hand. A total on the screen that differs by a cent from the charge shows up weeks later on a restaurant's statement.
Menu updates reach customers late, twice or in the wrong order, and sometimes not at all because menu publishing is stopped. A customer who sees an old price and is charged a new one disputes the charge. A customer who cannot see any menu because one part of the platform is stopped is a lost order for every restaurant, so the last published menu has to stay usable.
An order placed at one price must keep that price. If a restaurant edits a dish at 19:40, the customer who saw the old price at 19:39 is owed the old price or told about the new one before paying, never charged a price they did not see.
A process that dies between storing an order and answering the customer leaves a customer who does not know whether they ordered. If they try again the platform must find the order that exists. If it told them the order was placed, the order must exist.
Hold the card
Produces a card hold taken before the kitchen is asked, a bank challenge the customer must complete in time, and provider messages that arrive twice or out of order, tested against a fake payment provider you build. Takes no money yet.
Acceptance criteria
You write up in your repository how a card hold behaves from the client's side. You define a hold as an amount reserved on a card without moving money, and give the hold window (7 days at the bank, shortened to minutes in tests). You describe taking the full amount, taking less than the hold with the rest released, releasing a whole hold, expiry of a hold nobody took money from, a bank challenge the customer must complete (10 minutes from the hold request), a refund after the money was taken, and a dispute with a 7 day evidence window.
You list, in a table, what each answer to a hold request means for the order next: granted, challenge needed, declined and bank unavailable. You list the behaviours your fake provider must be able to cause: a decline, a challenge, an answer that arrives late, a message sent twice, messages out of order, a hold that expires early, a refused charge, an answer that never comes, and a dispute. You do not describe the provider's interface. You state that no card number is stored by the platform and that the customer's card details are entered only at the fake provider.
Architectural guidance
The fake provider is only worth building if it is as awkward as a real bank, and that has to be written down before it is built. A provider that never expires a hold or never reorders a message hides exactly the bugs this Phase exists to find. Deciding now what the order does when the bank is unavailable stops that case being invented in the middle of a bug.
Acceptance criteria
Placing an order puts a hold on the customer's card for the order's total, never a charge, before the kitchen is asked. When the hold is granted the order goes on. When the card is declined, the order ends as "payment failed" and the bank shows no hold for it. When the bank is unavailable or does not answer within 30 seconds, the customer is told, the order ends as "payment failed", and no hold exists at the bank afterwards, even if the bank answers later. Placing the same order twice creates one hold.
A request that contains a card number is refused, and a search of everything the platform stores and logs finds no card number.
A test kills the process after the bank granted the hold and before the kitchen is asked. Afterwards exactly one hold exists and the order still shows as waiting for the restaurant. A test stops card payments entirely: customers can still browse menus, and the orders placed during the stop are held once when payments return, or end as "payment failed", and are never held twice.
Architectural guidance
A hold taken after the kitchen is asked lets a kitchen start cooking for a card that will be declined. A process that dies between the hold and the next step leaves a customer whose card is held for an order nobody knows about. A bank that is slow to answer is not the same as a bank that said no, and a hold that appears at the bank after the platform has given up belongs to nobody.
Acceptance criteria
When the bank asks for a challenge, the order shows as "waiting for payment" for up to 10 minutes from the hold request. When the simulated customer completes the challenge in time, the hold is granted and the order goes on once. When 10 minutes pass without the challenge, the order ends as "payment failed" and the bank shows no open hold for it. The kitchen never sees an order that ended this way.
A challenge completed at 10 minutes and one second changes nothing, and the hold it creates is released. A test stops the platform after the challenge is requested, moves the clock 10 minutes, starts it again, and finds the order ended once.
Architectural guidance
A bank challenge is a step where the bank asks the customer to confirm the payment, and the customer may never do it. An order waiting on it needs an end, otherwise it holds a basket and a reserved amount for up to 7 days. A challenge completed late must not bring back an order the customer was already told had ended.
Acceptance criteria
The bank's messages reach the platform from outside. A message that is unsigned or wrongly signed is refused and changes nothing. A message delivered twice changes each hold and each order once, and the customer sees each change once. The same messages delivered in a different order, such as a charge before the grant it follows, end with the hold in the same final condition; a hold never goes back to an earlier condition. A message about a hold the platform does not know is recorded for an operator and changes nothing.
A hold that reaches its expiry without money being taken is released once and the customer sees the order as ended. A test shortens the window to minutes, moves the clock past it, and finds one release. A message that arrives after the order ended changes nothing.
A test kills the process while a message is being taken. Afterwards the message has been applied once, or not at all and applied once when it is sent again.
Architectural guidance
A bank sends the same message more than once and does not promise to send them in order. If the platform applies messages as they arrive, a late "granted" undoes a charge and the customer is told the order is ready for payment again. Expiry is a message too: a hold that expires without anyone noticing keeps the money reserved for nothing, and the customer sees it on their statement.
Acceptance criteria
A set of named tests ends with this stated result: the fake provider shows exactly one charge for each charged hold, and no open hold past its expiry. The tests are: the same charge requested twice, enough charge requests at the same moment to race, a charge after the hold window has passed (refused, and no money moves), a charge after the hold was released (refused), a charge above the held amount (refused), and the same order placed twice, which creates one hold.
One test makes the bank answer a hold request after the platform has given up and the order has ended as "payment failed". The hold that appears late is released, and the bank shows no open hold for that order. One test kills the process between asking for a charge and receiving the answer: the customer is charged once, and the money neither disappears nor doubles.
Architectural guidance
Charging a customer twice and charging an expired hold are the two ways this Phase hurts a card. Both are races between a request and a clock, so they are proven with repeats and with the clock moved, not argued. The late-answer case is the quiet one: a bank that confirms after the platform gave up leaves a hold that nobody will ever release.
Architectural walkthrough
Banks challenge, time out, answer late, answer twice and answer in the wrong order. The client pays for each of these with money. A customer charged twice phones support. A customer charged for an order that already ended waits days for a refund. A hold left open for 7 days keeps a customer's money reserved for food that was never cooked.
Taking payment at checkout is how the client runs today, and it is the reason a rejected or unanswered order needs a refund. A hold takes nothing, so this Phase only reserves the amount. Whether the hold ends in a charge or a release is decided by what the kitchen does next.
A bank asking the customer to confirm the payment adds a wait the client does not control. An order sitting in that wait with a basket and a hold needs an end, and a challenge completed after that end must not bring a dead order back.
A process that dies after the bank granted the hold and before the kitchen was asked leaves a customer whose card is held for an order nobody is cooking. The customer finds out when they phone. The fake provider you build here is also what every later money Phase is tested against, so it has to be able to cause every awkward behaviour the bank can.
Reach the kitchen
Produces orders delivered to the restaurant's tablet in a form the restaurant can check, the restaurant's answers taken back, a restaurant that pauses when its tablet goes silent, and scheduled orders released when cooking should start. Leaves deciding what each answer means for the order to the next Phase.
Acceptance criteria
A document in your repository describes how a restaurant's kitchen receives and answers an order. It says what the tablet shows (the lines with name, quantity, modifiers and allergen tags, and the time the restaurant has to answer), how long a kitchen takes to answer, and what the kitchen can say: accept with a preparation time, reject with a reason (too busy, closed, item unavailable, other), report an item sold out, and say the food is ready.
It says what the platform does when the kitchen says nothing for 5 minutes, and what it does when the same answer arrives twice. It is written in the restaurant's terms and names no part of your platform.
Architectural guidance
The tablet is a device the platform does not control, so what a kitchen can do and say has to be written down before anything is built for it. Deciding now what silence means stops the platform from either waiting on an order forever or giving up on one that is still inside the restaurant's 5 minutes.
Acceptance criteria
Each placed order reaches the restaurant's tablet in a signed request. The signature is HMAC-SHA256 over the timestamp and the raw body of the request. The tablet rejects a request with an altered body, or a timestamp older than 5 minutes. A tablet integration document in your repository tells a restaurant's developer how to check a request, which requests the platform sends, which answers it accepts, and the heartbeat. The tablet sees the allergen tags of every line.
The platform waits 5 seconds for an answer and retries 3 times, 5 seconds apart, after the first attempt. The retries never extend the 5 minutes the restaurant has to answer. Every retry for one order is recognisable as the same order, so the tablet shows one ticket, not four. When the tablet never acknowledges, the failure is recorded and the order is not marked as delivered.
A test makes the tablet unreachable for part of the 5 minutes: the order reaches it once the tablet returns, never twice as two orders. A test kills the process after the order was saved and before it was sent: the tablet still receives it once.
Architectural guidance
A receiver that verifies a signature against its own copy of the body rejects some genuine messages, and the sender cannot tell which. The 5 second timeout and the three retries bound how long a sick tablet can tie up the platform, and retries that move the 5 minute limit would give the restaurant more time than the client promised the customer. A retry that creates a second ticket in the kitchen is a second dinner cooked for one customer.
Acceptance criteria
The restaurant answers from the tablet with signed requests under the same 5 minute rule as the requests it receives. An accept with a preparation time moves the order to accepted. A reject with a reason (too busy, closed, item unavailable, other) ends it. An item reported sold out is recorded for the order. A ready message for an order the restaurant has accepted marks it ready.
An accept with no preparation time, a reject with an unknown reason, and an unsigned or stale request are refused and store nothing. An answer for an order the platform never sent to that restaurant is refused. An action the order's current situation does not allow, such as ready before accept, is refused. An answer for an order that already ended changes nothing, and the tablet is told what happened to the order in words (for example, "the customer cancelled").
Architectural guidance
The tablet's messages are the only way the platform learns what a kitchen decided, so each one has to change the order or be refused with a reason the tablet can read. A tablet that is told the order's real state can stop retrying on its own, and a tablet that is only ignored keeps cooking for a customer who left. A preparation time is required because the courier's offer is timed from it.
Acceptance criteria
A restaurant whose tablet has had no contact for 3 minutes stops receiving new orders, and customers see it as unavailable. Contact is any acknowledgement, answer or heartbeat; the heartbeat interval is your choice, shorter than 3 minutes. When contact returns, the restaurant becomes available again by itself. A restaurant that an operator paused stays paused when its tablet comes back, and a restaurant paused by silence is not unpaused by an operator's resume of a different restaurant.
A test stops the platform at minute 2 of silence, starts it again, moves the clock, and finds the restaurant paused at minute 3. After the platform itself was stopped for 20 minutes and started again, no restaurant is paused because of that gap; a restaurant is paused only after 3 minutes without contact counted from the restart.
With one restaurant's tablet unreachable, customers can still order from every other restaurant.
Architectural guidance
A silent tablet is the Friday outage in small. The platform has to stop selling for that restaurant instead of collecting payment for orders nobody will read. Measuring silence badly has a cost of its own: if the platform counts silence from the last message it saw, its own outage makes every restaurant look dead at once. A pause an operator set must not be undone by a tablet that happens to reconnect.
Acceptance criteria
A scheduled order, placed up to 48 hours ahead, is held on the customer's card at placement like any order and does not reach the kitchen then. It reaches the kitchen 30 minutes before the requested delivery time, and the restaurant's 5 minutes to answer start at that moment. A delivery time less than 30 minutes ahead goes to the kitchen at once.
A test shortens the hold window so the first hold expires before the release. At release the platform asks the bank for a new hold. If it is granted, the order goes on. If it is declined, or needs a challenge that is not completed in time, the order ends as "payment failed" and the kitchen never sees it. The first hold expiring does not end the order.
A test stops the platform before the release moment and starts it after: the order is released once.
Architectural guidance
A kitchen that receives a dinner order at lunchtime ignores it or prepares it too early. A hold can run out before the release moment, so release is when the platform finds out whether the card still works, and it has to find out before the kitchen cooks. The restaurant's 5 minutes start at release because a restaurant cannot be late for an order it has not been shown.
Acceptance criteria
A named test sends the same accept twice and the order is accepted once, and the customer is told once. It sends an accept followed by a reject for the same order: the first answer stands, the second is answered with the order's state, and nothing changes. It sends a ready message before the accept: the order is not marked ready, and the tablet is told the state. It sends the platform's own delivery retries and ends with one ticket on the tablet. It kills the process while an answer is being taken, and the answer is taken once or can be sent again and taken once.
The result of the run is stated: for every order in the test, the customer was told each change at most once, the changes happened in an order that matches the kitchen's real sequence, and a stale or unsigned answer added none.
Architectural guidance
A tablet on a poor connection resends, and a restaurant's staff tap twice. The platform's job is to turn that noise into at most one change per order. Counting what the customer was told, and not only what the order looks like now, catches the duplicate that left the order correct and sent the customer two messages.
Architectural walkthrough
The tablet is a device the platform does not control. It goes offline, answers twice, answers late, and its owner may press accept and reject within a second of each other. The client has already paid for one such failure: the connection to the tablets dropped for 2 hours 40 minutes, and 212 customers paid for food no kitchen ever saw.
A restaurant needs to be able to check that an order came from the client. Without that, anyone who knows the address of a tablet can send it a forged order, and the kitchen cooks food that nobody ordered and nobody will collect.
A restaurant that stops answering has to stop receiving orders. Selling into a kitchen that nobody is reading collects payment for food nobody cooks. The opposite mistake is as costly: a platform that measures silence badly can pause every restaurant at once because the platform itself was down for a while.
A process that dies after saving an order and before sending it leaves a customer with a held card and a kitchen that never heard of the order, and nobody finds out until the customer phones. Scheduled orders add a second clock: a dinner order sent at lunchtime is ignored or cooked too early.
Settle each order
Produces an order that is accepted or ended within the kitchen's 5 minutes, a hold released when the order ends before acceptance, lines that run out after placement, the client's rule for late cancels, and orders that survive a restart. Leaves couriers and taking the money for later Phases.
Acceptance criteria
After the card is held and the kitchen is asked, an order is accepted or ended within 5 minutes of reaching the tablet. A customer sees the order in plain words at each stage: waiting for payment, waiting for the restaurant, accepted, ended. An order whose restaurant never answers ends as expired within the 5 minutes, and the customer sees that it ended. A rejected order shows the restaurant's reason.
An accepted order shows the preparation time and the time the food is promised to be ready (acceptance plus preparation time). Every order ends in exactly one final outcome. Nothing is charged for an order the kitchen has not accepted: the bank shows no charge for an order that is waiting for the restaurant, rejected or expired, and none for an accepted order before it is delivered.
With card payments stopped, an order that needs the bank waits and does not fail, and exactly one request reaches the bank when payments return.
Architectural guidance
When the kitchen side fails and the customer side keeps selling, the customer waits for food nobody is cooking and the client refunds them by hand. Three parties with three ideas of whether an order is alive is the Friday again. An order the kitchen never answers has to end, and the customer has to see that it ended before they give up and phone.
Acceptance criteria
When an order ends before acceptance, because the restaurant rejected it, never answered, or the customer cancelled, the whole hold is released, the customer pays nothing, and the bank shows no open hold for the order. A customer's cancel is accepted while the order is waiting for the restaurant, and the customer is told they pay nothing. A cancel before the card was held is refused with the order's real state.
A release asked for twice releases once. A test stops the bank for the moment the order ends: the order still ends, the customer sees it ended, and the release happens once when the bank returns. When the order ends, the restaurant's tablet is told, stops being retried for that order, and answers any later message with the order's state in words.
An accept that arrives after the order expired changes nothing: the order stays expired, the customer is not told it was accepted, the hold stays released, and the tablet is told the state.
Architectural guidance
An unreleased hold keeps the customer's money reserved for up to 7 days, and the customer sees it on their statement for an order they never received. The late accept is the dangerous message: it arrives after the customer was told the order is dead. If it revives the order, the restaurant cooks for a customer who has already moved on.
Acceptance criteria
When the kitchen reports an item sold out after placement, that line is removed, the customer is told, and the order goes on with a new total. Food subtotal, food tax and the service fee (5 percent of the new subtotal) are recomputed. The delivery fee and the tip are kept. The item can no longer be ordered from that restaurant until it is marked available again.
Removing the second line of the worked example gives food 1,500, food tax 124, service fee 75, delivery fee 249, tip 200 and a total of 2,024. The customer's hold was for 3,389, so 1,365 cents are no longer owed, and the amount taken at the end is 2,024.
A report repeated removes the line once. A report for an order that has ended or been picked up changes nothing and is answered with the order's state. When every line of an order is removed, the order ends like a rejection with the reason item unavailable, and the hold is released.
Architectural guidance
The client's rule is to refund the line and let the order continue, because cancelling a whole dinner for one missing side dish loses the order and the customer. Recomputing the service fee on the new subtotal and keeping the delivery fee and the tip is a rule you can check against the worked example. An order whose total is not updated now is charged the original amount at the end, and the customer disputes it.
Acceptance criteria
A customer who cancels after the restaurant accepted and before pickup owes the food subtotal only. The delivery fee, the service fee and the tip are given back, and the hold is reduced to match. Cooking counts as started at acceptance. For the worked example the customer owes 2,800 cents and 589 cents are released at once. Taking the 2,800 comes in Phase 8.
A cancel after pickup is refused, the customer is told the food is already on its way, and nothing changes. A cancel sent twice has the effect of one. A cancel before acceptance still costs the customer nothing.
Architectural guidance
The restaurant cannot get back food that is already cooking, so the client charges the food subtotal and returns everything the platform controls. If the platform charged nothing, the restaurant would pay for food nobody collected. Treating acceptance as the start of cooking gives the rule one moment that can be tested and told to the customer, and the refusal after pickup exists because a courier is already carrying the food.
Acceptance criteria
A named test places orders with each deadline pending: a bank challenge, a restaurant's answer, a scheduled release and a card hold about to expire. It kills the platform without warning, moves the clock past every deadline, and starts the platform again. Each deadline then takes effect once: one expired order per order that expired, one release per released hold, one message to the kitchen per scheduled order. A deadline that fell due while the platform was down takes effect after the restart, late and once.
A further run kills the platform between an order ending and the hold being released, and the release still happens exactly once afterwards. The platform is killed and restarted at every point in an order's life (waiting for payment, waiting for the restaurant, accepted, ended) and every order reaches the right outcome.
The result is stated: every customer was told each change once, every order is in its expected state, and the bank shows no open hold for an ended order.
Architectural guidance
A clock remembered twice tells the customer twice that their order was cancelled, or releases a hold that was already released. A process that dies between ending an order and giving the money back leaves the customer's card held for an order that no longer exists.
Acceptance criteria
A named test sends the restaurant's accept and the customer's cancel for the same order at the same moment, enough times to race. Every run ends in one outcome. Either the cancel won: the order is cancelled, the hold is fully released and the customer pays nothing. Or the accept won: the order is accepted and the cancel is treated as a cancel after acceptance, so the customer owes the food subtotal only. No run ends in both, in two final outcomes, or with an amount that does not match the path.
A second test races the accept against the 5 minute limit passing. The order ends accepted or expired and never both. In both tests the loser is answered with the order's real outcome and changes nothing. The result is stated: across all runs, the number of orders with more than one final outcome is zero, and every amount matches its path.
Architectural guidance
An accept and a cancel are two true facts about one order, and only one can come first. If the platform lets both succeed, the client charges a customer for an order the customer cancelled, or the restaurant cooks one the customer left. The loser is answered and not ignored, so the restaurant and the customer both learn what happened.
Architectural walkthrough
Every order must end in one outcome that the customer, the restaurant and the bank agree on. The failures here are the ones that leave them disagreeing. A clock forgotten when the platform restarts leaves an order waiting forever with a customer's card held. A clock remembered twice tells the customer twice that their order was cancelled.
A restaurant accepting and a customer cancelling at the same moment are two true facts about one order. If both succeed, the client charges a customer for an order the customer cancelled, or the restaurant cooks food nobody will collect. The platform has to pick one, and the other party has to be told the real outcome.
Items run out after an order is placed, and a customer cancels after cooking has started. The client has a rule for each, and a platform that cancels the whole dinner for one missing side dish loses the order and the customer. A platform that charges nothing for a cancel after cooking leaves the restaurant paying for the food.
A bank that is unreachable at the moment an order ends must not leave the customer's money reserved. The release has to happen later, once, and the customer has to see that it did.
Dispatch couriers
Produces couriers on shift in six zones, offers that reach one courier at a time and timed to the food, pickup and dropoff confirmed with a code, and a new offer when a courier drops out. Money and the customer's live view are left for later Phases.
Acceptance criteria
An operator can put a courier on shift in one of the six zones, Z01 to Z06, and take the courier off shift again. At any moment an operator can see who is on shift in each zone and whether each courier is free or carrying an order. With 120 of the 300 rostered couriers put on shift across the zones, the per-zone counts add up to 120.
A courier who has sent nothing for 2 minutes while on shift is taken off shift, and the operator sees why. If that courier held an open offer, the offer ends and the next courier is offered the order without waiting for the 45 seconds to run out. A courier who goes off shift is offered nothing until back on shift.
A courier's name and phone number are visible to operators and to no one else. A customer or a restaurant looking at their own order sees neither.
Architectural guidance
A courier whose phone died or who rode into a tunnel looks exactly like a courier waiting for work. Every offer sent to that person goes unanswered for 45 seconds, so a few missing couriers on the list add minutes to many orders at the dinner peak. The client also holds names and phone numbers for 300 people, and the fewer screens show them the smaller the damage when one screen leaks.
Acceptance criteria
A courier is offered each accepted order, one courier at a time. The courier sees the restaurant, the pay (350 cents base pay plus the order's tip) and a 45 second countdown. The courier does not see the customer's name, phone or address. An offer nobody answers within 45 seconds moves to the next courier, and a decline moves it on at once.
Candidates are the idle on-shift couriers in the restaurant's zone, chosen at the moment each offer is sent. The courier with the shortest travel time to the restaurant comes first, from the client's travel-time table, and the courier idle longest wins a tie. A courier holds one order at a time and is offered nothing else while carrying one.
The first offer goes out at the time the food is promised ready minus that courier's travel time to the restaurant, or at once if that moment has passed. An order accepted with the food promised 20 minutes ahead and a nearest courier 6 minutes away is offered 14 minutes after acceptance, not at acceptance.
With no idle courier in the zone, no offer is sent, and the order is offered as soon as a courier comes on shift or becomes free. If the customer cancels while an offer is open, the offer disappears from the courier's phone, and an accept sent afterwards is refused with the reason in plain words. Killing the platform between sending an offer and its 45 second end still ends with the next courier offered exactly once.
Architectural guidance
An offer sent when the kitchen accepts puts a courier at the counter for the whole prep time, paid for waiting and unavailable to anyone else. An offer sent too late leaves a finished dish cooling on the pass. An offer left open after the customer cancelled sends a courier across town for nothing, and a platform restart that forgets the 45 seconds either offers the order to nobody or to two couriers at once.
Acceptance criteria
Every delivery has a 4-digit pickup code and a 4-digit dropoff code. The courier tells the restaurant the pickup code and enters it to confirm pickup. The customer sees the dropoff code in the tracking view and tells it to the courier, who enters it to confirm dropoff. A wrong code is refused, the delivery does not advance, and the courier is told in plain words that the code did not match.
A courier who cannot hand over the bag can mark it left at the door instead of entering the dropoff code. The record then says left at door, not delivered with a code, and the two are never confused.
The time a courier waits at the restaurant, from arriving to pickup, is recorded for each delivery in seconds and shown to an operator. The courier sees the customer's delivery address only while that delivery is active, and loses it after dropoff or when the order is taken away.
Architectural guidance
When a customer says the food never came, the only proof is what was recorded at the door: whose code, which courier, what time. Without it the platform pays every claim or loses customers who were genuinely left without. A courier who keeps an address after the delivery holds personal data they have no reason to have, and waiting time the platform never recorded cannot be raised with a restaurant that keeps couriers standing at the counter.
Acceptance criteria
When a courier declines an offer, the order is offered to the next courier at once. When a courier who accepted abandons the order before pickup, the order is offered again and an operator sees a flag naming the courier and the order.
When a courier has not arrived 10 minutes after the promised arrival time, the order is offered to another courier, the first courier is released from it, and an operator sees a flag. If the first courier turns up afterwards and tries to pick up, the attempt is refused and the courier is told the order has moved.
When 15 minutes pass after the food is ready with no courier assigned, an operator sees a flag on that order, once, and offers keep going. While the order waits, the customer sees that a courier is being found, in those words. The platform never deactivates a courier on its own: a flag is a record for an operator to read.
Killing and restarting the platform while a flag is pending produces the same flags it would have produced without the restart, each once.
Architectural guidance
Nothing announces a courier who never arrives. The order sits ready, the food cools, and the customer finds out by phoning, while the client's team has no way to see which orders are stuck. A platform that waits for a message that never comes strands the order until somebody notices, and an operator who is told nothing cannot help.
Acceptance criteria
A zone in which no courier is on shift stops taking new orders from restaurants in that zone. A customer trying to order from such a restaurant is told in plain words that delivery is not available right now. Customers ordering from restaurants in other zones notice nothing.
The zone takes orders again as soon as one courier goes on shift in it. An operator can also pause and resume a zone by hand, and a zone paused by an operator stays paused when couriers are on shift. Orders already accepted in the zone keep their place and are offered when a courier appears.
With 10 couriers taken off shift without notice, any zone left with nobody on shift stops taking orders and the others keep selling.
Architectural guidance
A customer who pays for delivery in a zone with nobody on shift waits for a courier who is not coming, then cancels, and the client refunds the order by hand. Selling should stop where the platform cannot deliver and start again by itself, because nobody on the client's team is watching the zone list at 20:00 on a Friday.
Acceptance criteria
Two couriers who accept the same offer at the same moment produce one assignment. One courier is told the order is theirs, the other is told in plain words that the order has gone, and the customer's tracking view, the operator's history and the courier pay each show one courier. Repeat the test at least 500 times, and no run produces two couriers on one order.
A courier who accepts after the 45 seconds ended and the order moved to the next courier is refused and the order stays with the later courier. A courier accepting at the same moment the customer cancels ends with one outcome: the order is cancelled and the courier is told, or the order is assigned and the cancel is handled by the cancel rule, never both.
Architectural guidance
With offers going one at a time the race looks impossible, and it happens anyway: a slow phone's accept lands just after the offer moved on. Two couriers then drive to the restaurant, one is sent home unpaid, and the restaurant hands the food to whoever arrives first. A single test run passes by luck, which is why the check repeats the same moment hundreds of times.
Architectural walkthrough
This Phase has to survive couriers who say yes twice, say nothing, or never arrive.
An offer goes to one courier at a time, so it looks as if two couriers can never hold the same order. They can. An offer runs out after 45 seconds, the next courier receives it, and the first courier's accept arrives from a phone with a weak signal a moment later. Both drive to the restaurant. One goes home unpaid, the restaurant hands the bag to whoever stands at the counter first, and the courier who lost has a reason to stop working for the platform.
Timing costs money in the other direction. A courier sent at the moment the kitchen accepts stands at the counter for the whole prep time, paid by the platform and unable to take another order. With 120 couriers on shift handling 200 orders an hour at the dinner peak, couriers are already about 83 percent busy, so every minute of waiting is a minute some other customer's food has no courier.
Absence is the quietest failure. A courier who never arrives sends nothing, so the order sits ready, the food goes cold, and the customer learns about it by phoning. The same goes for a zone where every courier has gone home: the platform keeps selling delivery nobody will make, and the client refunds those orders by hand.
Capture and book the money
Produces the card charge after delivery, for the lines delivered only, and a record of where every cent of each completed order went, with tips kept apart from courier base pay. Refunds, statements and payouts are left for later Phases.
Acceptance criteria
A delivered order is charged to the customer's card after the 30 minute report window ends, and not before. The amount is the lines delivered, with tax, fees and tip, minus any refund approved inside the window. An order whose second line (1,300 cents) ran out has a hold of 3,389 cents and a charge of 2,024 cents, and the customer's card shows only 2,024.
An order cancelled after acceptance and before pickup is charged 2,800 cents, the food subtotal only. Killing the platform after it has asked the bank to charge and before it has the answer ends with the customer charged exactly once for the right amount, and the order showing a completed charge.
If the bank refuses the charge after delivery, the platform writes the amount off, the restaurant and the courier are still paid in full, the customer is not asked again, and support sees a case with the order and the amount. Nothing is charged for an order the kitchen did not accept.
Architectural guidance
Charging the held amount and handing the difference back later shows the customer a charge for food they never received, and customers phone support about it. A charge refused after the food was delivered is lost money unless the client has already decided who bears it.
Acceptance criteria
For any completed order, an accountant can open one view and see where every cent went: what the restaurant is owed for the food, the tax the restaurant owes, the platform's commission, the delivery and service fees net of tax, the tax on those fees, the courier's base pay, the courier's tip and the card provider's fee (1.5 percent of the amount charged plus 25 cents, rounded half up). All of these amounts except the base pay and the provider's fee add up to the customer's total. The base pay and the provider's fee are shown as the platform's own costs.
The basket of two lines (1,500 and 1,300 cents) with a 200 cent tip shows: customer total 3,389, restaurant 2,055 plus 231 tax, commission 514, fees net of tax 322, tax on fees 67, tip 200, base pay 350, provider fee 76. With the second line removed: total 2,024, restaurant 1,101 plus 124 tax, commission 275, provider fee 55. Cancelled after acceptance: total 2,800, restaurant 2,055 plus 231 tax, commission 514, provider fee 67.
A correction to an order appears as a correction, with the original amounts still visible beside it. No order has parts that differ from its total by even one cent.
Architectural guidance
The client's weekly job recomputed commission and courier pay from order totals at the end of the week. A rule nobody had decided ended up buried in that calculation, and when the accountant asked why a figure was what it was, nobody could say. Money whose parts cannot be shown cannot be audited, refunded fairly or defended in a dispute.
Acceptance criteria
A courier's tip reaches the courier whole. Base pay (350 cents per delivery) and the tip are shown as two separate amounts to the courier and to an operator, and no tip is ever counted against base pay.
A tip goes back to the customer only when nothing was delivered. An order that was delivered and then refunded still pays its tip to the courier. A courier with ten low-paying deliveries and ten large tips sees ten base pays and ten tips, each unchanged.
Architectural guidance
Couriers read their pay for the tip first, so a figure that hides it costs the client the couriers it most needs.
Acceptance criteria
A test generates 10,000 orders with random baskets of one to six lines at odd prices, modifiers, tips from 0 to 1,000 cents, and a mix of removed lines, cancels after acceptance and refunds approved before the charge. For every order the parts add up to the customer's total to the cent, and the sum over all 10,000 does too. The card provider's fee on each order is 1.5 percent of the amount charged plus 25 cents, rounded half up, and is booked as the platform's own cost beside the base pay.
The same random seed produces the same result, the run's output with its count of orders and its count of mismatches (zero) is committed, and changing the tax rounding to work on the whole basket instead of per line makes the test fail.
Architectural guidance
Rounding goes wrong by a cent only on baskets with odd prices, so one worked example never shows it.
Architectural walkthrough
This Phase has to survive taking the wrong amount, taking it twice, and not being able to explain it.
The card hold is the most the customer could owe. What the customer owes is the order's final amounts, after any line that ran out and after any refund approved inside the 30 minute report window. Charging the whole hold and sending the difference back later feels safe, and it shows the customer a charge for food nobody delivered. Customers phone about it, and the client pays for that line on the next invoice from the bank.
A process can die between asking the bank to charge and hearing the answer. Nobody then knows whether the money moved, and the guess is wrong in one of two ways: the customer is charged twice or the platform delivers a dinner it was never paid for. A refused charge after the food has been eaten is lost money, and restaurant and courier must still be paid.
The client's accountant found another failure: courier tips counted toward the base pay the client promises for each delivery, so couriers kept none of the tip the customer meant for them, and nobody had decided that. Rounding is one more. Tax is taken out per line and rounded half up, which is wrong by a cent for baskets with odd prices in ways one worked example never shows. At 1,000 orders a day those cents add up to a gap the accountant cannot trace to any order.
Track the courier and the ETA
Produces a live view for the customer with status and an ETA, courier positions that are accepted even when they arrive hours late, and the rule for how long those positions are kept. Refunds and payouts are left for later Phases.
Acceptance criteria
A customer opening their order sees its status in plain words from placing to delivery (waiting for payment, waiting for the restaurant, being prepared, ready, on the way, delivered, ended) and an ETA that is recomputed as the order advances. For an order promised ready in 20 minutes with the customer in the restaurant's own zone (6 minutes by the client's travel-time table), the ETA shown at acceptance is 26 minutes away and moves when the kitchen changes the prep time.
A customer sees only their own orders. Asking for another customer's order is refused. At the dinner peak the view keeps answering at about 12 reads a second. A customer who cannot load the view loses nothing: the order is still cooked, delivered and charged.
Architectural guidance
A customer who cannot see where the order is phones the client, and at 1,000 orders a day the phone line becomes the bottleneck before any courier does. An ETA guessed once at placement stays wrong all evening, and every minute it is wrong is a promise broken in front of the customer.
Acceptance criteria
A courier phone sends a position every 15 seconds while on shift. A batch of positions uploaded 2 hours late, 480 positions in one upload, is accepted, sorted by the time each position was taken, and does not move the courier backwards on the customer's view or change the ETA. A position older than the newest one already shown never replaces it.
The same position sent twice appears once. A position stamped at a time when the courier was not on shift is refused. The late upload has no effect on any other courier's view.
Architectural guidance
Phones in a lift or a tunnel send nothing, then everything. The customer reads a jumping ETA as a broken promise, not as a signal gap.
Acceptance criteria
A courier's positions are recorded only while on shift. Positions are deleted 30 days after the delivery they belong to: with the clock moved to 30 days and 1 second after delivery they are gone, and just before that they are still there. When a courier asks to be erased, their positions disappear at once.
After erasure the courier's name, phone and positions are gone, while the deliveries, the pay records and the evidence for any bank dispute stay, identified by the courier's ID, for 7 years. An operator looking up an erased courier's delivery sees the ID and no personal data.
Architectural guidance
A trail of where a person was and when, kept for no reason, is a risk the day someone asks for it or gets it out. Erasing a courier has to take the person and leave the work.
Acceptance criteria
A named test, with its command in the README, uploads 480 positions 2 hours late in one batch and finds the courier not moved backwards and the ETA unchanged. The same position sent twice appears once, a position from a time the courier was off shift is refused, and the late upload changes no other courier's view. For an order promised ready in 20 minutes and 6 minutes of travel the ETA shown at acceptance is 26 minutes away, and it moves when the kitchen changes the prep time. With the clock at 30 days and 1 second after delivery the positions are gone, and just before it they are still there. After a courier is erased, name, phone and positions are gone while deliveries and pay records stay by ID, and a customer asking for another customer's order is refused.
Architectural guidance
A courier pin that jumps backwards after a late upload makes customers cancel orders that are on their way. A position kept past its limit is personal data the client may not hold.
Architectural walkthrough
This Phase has to survive late data and data kept too long.
Couriers lose signal in cellars, lifts and tunnels. Their phones then send nothing for an hour and everything at once. If the platform treats the last batch it received as the latest news, the courier jumps back to where they were two hours ago, the ETA jumps with them, and the customer reads that as a broken promise and phones support.
A customer's view is read far more than it is written. Each viewer reloads every 10 seconds, which is about 12 reads a second at the dinner peak, and every one of those reads is a customer deciding whether to phone the client.
The client also keeps every courier position forever next to the order. A trail of where a person was and when is personal data. Nobody has a reason to hold it for years, and a breach or a request from the courier makes it a problem. Payouts, tax records and bank disputes still need to know that a delivery happened and who made it, so deleting the trail cannot mean deleting the order.
Refund and answer disputes
Produces refund cases from customer reports, refunds that end with the same money for the restaurant, the courier and the customer whether the card was charged yet or not, and the platform absorbing the fee the provider keeps after a charge, the cost placed on the right party, a decision on not-received claims, and answers to bank disputes. Payouts are left for the next Phase.
Acceptance criteria
A customer can report a problem with an order in plain categories: item missing, wrong item, lost, damaged, not received, or a request for goodwill. Support sees each report as a case that carries the order's history: items, amounts, the kitchen's answers, the courier, the codes entered and the times.
A report sent twice, by double tap or by retry, produces one case. A customer can report only their own orders, and a report on someone else's order is refused. A report made after the 30 minute report window is accepted too.
Architectural guidance
A problem reported by phone and typed into an order total leaves no trace of why the money moved. Support that cannot see the order's history decides blind, and a customer who reports twice gets two cases that two agents resolve differently.
Acceptance criteria
Support can refund an order fully or partly. A refund approved inside the 30 minute report window, before the card is charged, lowers the charge. A refund approved after the charge sends money back to the card. For the same order, the money the restaurant and the courier each end with is the same either way, and so is the commission. The card provider keeps its fee on a charge that was made, so the platform ends with the fee of the charge it paid: the platform absorbs the difference on the after-charge path. For the 3,389 cent basket with the 1,300 cent line refunded, the restaurant ends with 1,101 plus 124 tax and the platform with 275 commission on both paths, and the provider fee is 55 cents on the first path and 76 cents on the second.
A refund can never exceed what the customer paid. The same approval submitted twice at the same moment refunds once, and the second submission is answered with the first one's result. A refund approved at the moment the charge is made ends in one consistent result.
Architectural guidance
A refund a minute before the charge and one a minute after look the same to the customer and are different transactions to the bank. Two agents approving the same refund pay the customer twice, and that money does not come back.
Acceptance criteria
The cost of each refund lands on a party by the client's table. A missing or wrong item is the restaurant's cost. Lost or damaged in transit is the platform's cost, with a flag for an operator naming the courier. Goodwill is the platform's cost. A not-received claim is decided from delivery evidence in the next Checkpoint.
The restaurant sees each refund deducted on its statement with the reason. A flag is a record an operator can read, and it changes no courier's pay and deactivates no one.
Architectural guidance
The courier flag exists so a pattern of lost food reaches a person who can look, because an automatic penalty would punish couriers on one customer's word.
Acceptance criteria
A not-received claim is denied when the dropoff code entered at delivery was the customer's own code. The customer is told in plain words, with the time and the fact that their code was used. A claim is approved as lost in transit, at the platform's cost with a courier flag, when the courier marked the order left at the door or no delivery was recorded.
A denied claim can still be granted by support as goodwill, as a separate case. The tip returns to the customer only when no delivery was recorded at all.
Architectural guidance
Without a record taken at the door, a not-received claim is one person's word against another's. A platform that always believes the customer pays for food somebody ate, and one that never does loses customers who were really left without. The rule is only as good as the record the courier's code and the left-at-door mark created.
Acceptance criteria
When the bank opens a dispute, support sees it with the order and the 7 day deadline. Support can answer it with the order's evidence: which courier delivered, at what time, whether the customer's code was entered or the order was left at the door, what was ordered, when the kitchen accepted and the amount. With the clock moved 7 days and 1 second past the dispute, answering is refused and an operator sees the dispute as missed.
The bank stand-in decides won or lost. A won dispute changes nothing. A lost dispute returns the amount to the bank and is carried to the payouts in Phase 11. A dispute on an order whose customer has been erased can still be answered with the evidence, identified by the customer's ID and with no personal details.
Architectural guidance
Disputes answered with screenshots are lost because the platform cannot show who delivered or when. If erasing a customer also erased the evidence, the platform would be unable to defend an order it really delivered.
Acceptance criteria
A test takes at least 200 generated orders with varied baskets and refunds each one twice: approved before the charge and approved after. For every order the net money of the restaurant, the courier and the customer is identical on both paths, to the cent, and so is the platform's, except for the card fee: the platform's net on the after-charge path is lower by exactly the fee the provider keeps on the charge less the fee it would have taken on the lowered charge.
A refund and a charge made at the same moment, repeated at least 500 times, always end in one consistent result with no double money back. The same approval submitted twice at once refunds once on every run.
Architectural guidance
The two paths agree only if somebody checked every order. The window between a refund and a charge is a few seconds that matter once in a thousand orders, so the test has to hit it on purpose.
Architectural walkthrough
This Phase has to survive refunds that depend on timing and claims that depend on one person's word.
A refund approved a minute before the card is charged and one approved a minute after look the same to the customer. For the bank they are different transactions. If the platform works them out differently, the restaurant's statement and the courier's pay change with the timing of a click, and nobody can say which figure is right. The bank also keeps its fee on the charge it has already made, so the platform pays for a refund that comes late. Two support agents approving the same refund at the same moment, or one agent pressing twice, can pay the customer twice.
The cost of a refund belongs to whoever caused it. If the platform absorbs every refund, a restaurant that packs the wrong item never hears about it. If restaurants absorb every refund, they pay for food lost in transit. The client's own table decides it, and a courier is flagged for an operator to read, never penalised on one customer's word.
A customer who says the food never arrived is one person's word against another's. The client's bank disputes were answered with screenshots because nobody had recorded who delivered an order or when. A lost dispute costs the amount, the bank's fee and the next payout of whoever was paid for it. The evidence also has to survive the customer asking to be erased.
Pay restaurants and couriers
Produces a weekly statement and payout for each restaurant and each courier, and the correction when a dispute is lost after a party was paid. The tools for an operator are left for the last Phase.
Acceptance criteria
Each Monday every restaurant receives a statement and a payout for the previous Monday to Sunday in Europe/Amsterdam. An order delivered on Sunday at 23:30 falls in that week and one delivered on Monday at 00:10 falls in the next, including in the week the clocks change.
The statement lists each order of the week with its date, food amount, tax, commission, refunds deducted and amount owed. The restaurant can check it against its own till line by line, and the payout equals the statement total. A restaurant sees only its own statement. A balance of zero or less is stated and nothing is paid.
Killing the payout run halfway and running it again leaves every restaurant paid exactly once.
Architectural guidance
A statement that does not match the restaurant's till gets argued line by line by a person at the client. A run killed halfway leaves the question of who got paid, and rerunning it to be safe pays some restaurants twice, which is money that does not come back.
Acceptance criteria
Each Monday every courier receives a payout for the previous Monday to Sunday in Europe/Amsterdam. It shows base pay (350 cents per delivery) and tips as separate lines, with the delivery count. A delivery refunded after it was delivered still pays its base pay and its tip.
Starting the payout run twice, including twice at the same moment, pays every courier once. No line combines tips with base pay, and a tip never lowers the base pay owed. A courier carrying an operator flag is still paid.
Architectural guidance
A courier checking the payout looks for the tip first. A single combined figure hides whether it arrived, which is what went wrong on the client's Friday. A run started twice by two operators or by a retry pays every courier twice.
Acceptance criteria
When a dispute is lost after the parties were paid for the order, the amount each received for that order is deducted from that party's next payout. The party sees the deduction on the statement with the order and the reason. A payout can go negative: nothing is paid, the balance is carried to the following payout, and the statement says so.
A statement already issued is never rewritten. A dispute lost before the payout is simply not paid out.
Architectural guidance
The bank takes the money back whenever it decides, which can be weeks after the party was paid.
Acceptance criteria
A test takes the generated orders of several weeks, including refunds, lost disputes and carried negative balances, and shows that every payout equals its statement total and the sum of the orders it covers, to the cent. A single cent of difference fails the test.
After a restaurant or courier is erased on request, the same test still passes: the name, phone and address are gone and the money records remain, identified by ID. The financial, tax and order-evidence records are kept for 7 years: with the clock moved 7 years and 1 day past an order they are removed, and just before that they are still there.
Architectural guidance
A payout that is right on the day and wrong after an erasure or a reversal is found when a restaurant complains. Tax law needs the money records to stay, and the seven-year limit means they also have to leave on time.
Architectural walkthrough
This Phase has to survive a payout that is wrong, run twice or left half done.
Restaurants asked for a weekly statement that matches their own till, and the client's does not. A restaurant that finds one wrong line argues about every line, and the client's finance person ends up reconciling by hand. A week is also ambiguous: an order delivered at 23:30 on Sunday belongs to a different statement from one delivered at 00:10 on Monday, and the week when the clocks change contains a day of 23 or 25 hours.
A payout run can be killed halfway or started twice by two people. Rerunning after a kill pays some restaurants twice. Not rerunning leaves others unpaid, and the client has no way to tell which is which. Money paid twice does not come back.
The bank decides a dispute whenever it decides, which can be weeks after the restaurant and the courier were paid for the order. Rewriting a statement already sent means the party's own records no longer match. Ignoring the loss means the platform pays for the order twice. A party asking to be erased must not make any of this stop adding up.
Operate the platform
Produces what an operator needs to trace an order and retry what could not be processed, then the proofs: a simulated dinner peak, one capability stopped at a time, one updated at a time, and every failure at once. Nothing new is sold in this Phase.
Acceptance criteria
An operator enters an order number and sees everything that happened to the order, in time order: placement, the card hold, the message to the kitchen and its answer, the courier's offers, pickup and dropoff, the charge, any refund, any flag and any support case. Each line has a time and says in plain words what changed. After the platform was killed and restarted in the middle of the order, the history shows no gap and no repeated line.
If the customer has been erased, the history shows their ID and no name, phone or address. Someone who is not an operator cannot open the history, and an order number that does not exist is answered with that fact.
Architectural guidance
When the Friday happened, finding out what had happened to one order meant opening several tools and guessing from times. An operator on the phone with a customer has minutes. A history with gaps sends them hunting while the customer waits.
Acceptance criteria
Send one answer the platform cannot make sense of, such as a tablet answer with a missing field, among 100 good ones. The 100 good ones are processed. The bad one is shown to an operator with its order and the reason it failed, and nothing behind it waited.
An operator can retry it once the cause is fixed, and it is processed once, including when the retry is pressed twice at once. A message that has failed 5 times stops being tried and waits for an operator. The number of messages waiting is visible, and nothing is dropped without a trace.
Architectural guidance
One malformed message retried forever stops everything behind it. One that is thrown away loses an order's answer, and nobody finds out until the customer phones. Both are the Friday in miniature.
Acceptance criteria
One command plays 400 orders over 2 simulated hours using the clock you control, with 120 couriers on shift, a busiest minute of 10 orders, and restaurants and couriers answering as people would. It finishes in minutes of real time. Every order ends in exactly one outcome (delivered, rejected by the kitchen, unanswered, cancelled, payment failed) and the counts per outcome are reported.
While the simulation runs, the tracking view is read at about 120 reads a second, ten times the real peak of 12, and 95 percent of reads are answered in under 200 ms. The results of the run, with those figures, are committed to your repository.
Architectural guidance
A problem found in a simulation costs an afternoon. Found in production, it costs a dinner service.
Acceptance criteria
A test stops each of seven capabilities in turn and restarts it, and the README says how. With menu publishing stopped, customers still see the last published menu and can order from it. With card payments stopped, customers can browse and track existing orders, and a new order is refused in plain words with nothing held. With the kitchen connection stopped, customers still order from other restaurants and the unreachable restaurant shows as unavailable.
With courier dispatch stopped, restaurants still accept orders and customers see that a courier is being found. With tracking stopped, nothing else changes. With refunds stopped or payouts stopped, orders are still placed, cooked, delivered and charged.
After each restart the stopped capability catches up. No order is lost or counted twice, every order ends in one outcome, and no customer is charged for an order the kitchen did not accept.
Architectural guidance
This is the Friday: one broken capability, and the customer side keeps selling. The test names what must still work, so the answer is never that it depends.
Acceptance criteria
While 10 orders a minute keep arriving, one visible rule is changed in each of four areas in turn: the pricing (delivery fee 249 to 299 cents for new orders only), how long the kitchen has to answer, how long a courier has to answer an offer, and what the tracking view shows. The product keeps answering throughout.
No order placed during any change is lost, doubled, refused or left with a wrong total. An order placed one second before the fee change is still charged 249, and one placed after is charged 299. For each change, the number of orders placed equals the number of orders that end in exactly one outcome.
Architectural guidance
Releases also happen at lunchtime. An update that drops requests while it runs loses orders and charges. A change that reprices orders already placed breaks the rule that the customer pays what they saw.
Acceptance criteria
The simulated dinner peak of 400 orders over 2 simulated hours runs with every failure at once: the kitchen connection down for 20 minutes, the bank returning errors for 5 minutes, every kitchen and bank message sent twice, 10 couriers taken off shift without notice, and order placement stopped for 60 seconds in the middle of the run.
The run passes only if every order ends in exactly one outcome, no hold stays open past its deadline, the books balance to the cent, and no customer is charged for an order the kitchen did not accept. The same seed gives the same result on a rerun, and breaking any of the four conditions on purpose fails the run. The report is committed.
Architectural guidance
Each failure is survivable alone. The Friday came from several at once, and a run that only passes on a calm day proves nothing about the evening the platform was built for.
Architectural walkthrough
This Phase has to survive the Friday that started the project: the connection to the kitchen tablets down for 2 hours 40 minutes, 212 customers paid for food no kitchen saw, and the client's team found out from the customers.
When one order goes wrong, an operator on the phone has minutes. If the history of that order has gaps, or sits in several tools, the operator guesses from timestamps. One message the platform cannot make sense of can hold up everything behind it if it is retried forever, and can lose an answer nobody notices if it is thrown away.
A product that stops everything when one capability stops is as bad as one that keeps selling when the kitchen is gone. An update that drops orders while it runs turns every lunchtime release into a loss. A platform that works for one order at a time can still fail at the dinner peak, where everything that waits does so with a hundred others.
Each of these failures is survivable alone. The Friday came from several at once, so the last Checkpoint runs them together, and its pass condition is the client's: every order ends in exactly one outcome, no hold stays open past its deadline, the books balance to the cent, and no customer is charged for an order the kitchen did not accept.
Architectural walkthrough
One outcome for every order
The client's Friday happened because the customer side, the kitchen side and the courier side each held their own idea of whether an order was alive. The customer side had taken the order and the card charge. The kitchen side had never heard of it. Nobody was responsible for noticing the difference, so 212 customers waited for food that no one was cooking.
Every order in this platform must end in one outcome that the customer, the restaurant, the courier and the bank all agree on. An order the kitchen never answers has to end, and the customer has to see that it ended before they cancel in frustration. An order that ends early has to give back what it took.
Money moves last
The steps run in a fixed order: hold the card, ask the kitchen, find a courier, and take the money last, for the lines actually delivered. Each alternative to this order has a price, and the client's Friday shows the first one.
Charging at checkout is the simplest flow and the one the client runs today. Every rejection, timeout and outage then needs a refund, and the customer has watched their money leave for food nobody cooked. A card hold takes nothing until the order is delivered.
Hiring the courier before the kitchen accepts finds a courier faster. The price is a courier standing at a restaurant for an order the kitchen then rejects.
Letting the bank, the kitchen or the courier decide on its own that an order is finished is quicker to write. The price is three parties with three answers to the same question, which is the Friday again.
Clocks
Every step has a clock: the bank challenge 10 minutes, the kitchen 5 minutes, the courier offer 45 seconds, the courier's arrival 10 minutes past the promised time, the card hold its expiry. If the platform forgets a clock when it restarts, an order waits forever with the customer's card held. If it remembers a clock twice, the customer is told twice that their order was cancelled, or a courier is offered an order that another courier already has.
A restaurant accepting and a customer cancelling at the same moment are two true facts about one order. Two couriers tapping the same offer at the same moment are two true facts about one offer. Each pair has to end in exactly one outcome, and the loser has to be told.
Messages from outside
The bank sends the same message twice, or sends the second one first. The restaurant's tablet answers an order that the customer cancelled a minute ago. A courier's phone uploads positions hours late from a car park with no signal. Each of these costs the client a wrong answer: a hold captured twice, an order revived after it ended, a courier shown in the wrong place.
A crash is the same problem from the inside. A process that dies after saving a payment and before telling the kitchen leaves a customer paying for food nobody is cooking, and nobody finds out until the customer phones.
Money and the people behind it
The tip defect is an accounting mistake that nobody noticed because nobody could see where each cent went. A refund issued before the card was charged and one issued after it must end with the same money for the restaurant, the courier and the customer. The platform ends with the same money too, except for the card fee that the provider keeps once a charge has been made. A dispute lost after a restaurant was paid must still be recovered from somewhere, and a restaurant, a courier or a bank must be able to check every cent against a statement.
Personal data adds a second duty. A courier's position, a customer's address and a customer's name are kept only as long as the client's rules allow, while the records the tax office and the bank may ask for stay, identified by ID only.
One capability stopped
Last Friday only the kitchen connection was down, and the product went on selling as if nothing had happened. The client needs a decided answer for every outage: with card payments stopped, customers can still browse menus and follow orders already placed. With courier dispatch stopped, restaurants keep accepting and the orders wait. With tracking stopped, nothing else changes. A change to one capability has to ship while the rest keep serving at 10 orders a minute without losing one.
Where it shows if you cut a corner
The Phase 12 dinner peak plays 400 orders over 2 simulated hours with the kitchen connection down for 20 minutes, the fake provider returning errors for 5 minutes, every kitchen and provider message sent twice, 10 couriers taken off shift without notice and order placement stopped for 60 seconds. It passes only if every order ends in exactly one outcome, no hold stays open past its deadline, the books balance to the cent and no customer is charged for an order the kitchen did not accept.
If the platform charges before the kitchen accepts, the 20 minutes of kitchen downtime fail that last condition. If a deadline is forgotten when order placement comes back after its 60 second stop, holds stay open past their deadline. If a refund or a payout is worked out differently from how the order was settled, the 10,000 generated orders in Phase 8 and the refund comparison in Phase 10 fail first, and the payout reconciliation in Phase 11 fails after them.
Related Links
- Belastingdienst: keeping your recordsfinancial, tax and order-evidence records stay for 7 years after a customer or courier is erased.
- Belastingdienst: 9% VAT on food and drinksfood tax is 9 percent of the tax-included price.
- Stripe: webhook signaturesa request to the restaurant's tablet is signed with HMAC-SHA256 over the timestamp and the raw body and refused after 5 minutes.
- Insurance Journal: DoorDash settlement over tipstips and courier base pay are never counted against each other.
- Deliveroo: accepting orders automaticallyan order the kitchen does not answer within its window is rejected automatically, like the 5 minute rule here.
- DoorDash: how to accept an ordera courier offer lasts under a minute, like the 45 second offer here.
- Uber Eats: order errorsa missing or wrong item is the restaurant's cost.
- Business Insider: how to cancel an Uber Eats ordera cancel before the restaurant accepts costs the customer nothing.