Skip to content

Build a Two-Location Online Shop

Davor Minchorov•Intermediate•6 to 7 weekends•October 29, 2026

A ceramics studio sells the same pieces from its workshop and its town shop and keeps overselling its limited drops and refunding by hand. You will build the replacement shop and prove it with a simulated trading day with failures injected.

The brief

The client

I run a small ceramics studio. We make mugs, bowls and vases in the workshop and sell them online and in a shop in town, about 60 online orders a day. The big pieces sit in the workshop and the small ones in the shop's back room, and we ship from both. When we released 30 glazed vases, 47 people paid for one in 25 minutes, because the site looked at the stock when the page opened and trusted it from then on. I wrote to 17 customers and refunded them by hand, and two were refunded twice because my partner and I both did it the same afternoon. An order that ships in two parcels has also been charged twice. I need a shop where the last vase sells once, where a piece held for a customer who walks away goes back on the shelf by itself, and where I can open an order and see exactly what happened to the stock and the money.

The problem

The shop keeps one stock number per product and checks it when a page loads. Two customers can pay for the last vase, and the second is found out only when someone goes to pack it. Stock sits in two places, but the shop sees one total, so the owner decides by hand which place ships which line, and an order for three pieces from both places is a note on paper.

Payment is taken at order time, so every cancellation and every short pick becomes a manual refund. The payment provider keeps a fee on each refund, so every avoidable cancellation after capture costs money. The product list on the shop front is rebuilt overnight, so a sell-out reaches the page up to a day late. Returns arrive with a note and no link to the order line, so refunds are typed in, and a typed refund can be sent twice.

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 the owner publish, change the price of and withdraw products, and show the shopper each product as in stock or out of stock, filtered by part of the name.
  • Hold stock for a shopper at checkout, at named locations, for 15 minutes, and never sell the same unit twice, even when 100 buyers ask for the last one at the same moment.
  • Let the studio receive stock, correct a count after a shelf check and move stock between the workshop and the shop, with moved units unsellable until received.
  • Take payment by card through a payment provider that answers late, repeats itself and speaks out of order, and never hold stock or money past its deadline.
  • Split an order across the two locations, ship each part as its own parcel, show the order as partly shipped, and charge the card once.
  • Cope with a line the packer cannot find by moving it to the other location or cancelling and refunding it.
  • Let a shopper or the owner cancel an order, or one line of it, before it is picked, with the stock released and the line's value returned.
  • Let a shopper return items until 14 days after the last parcel of the order is delivered, inspect them, restock or write them off, and refund only the returned lines with their share of shipping and discount, once.
  • Show an order's history from placement to refund in one view, ordered by when each thing happened, so the owner can tell a customer what happened to their stock and money.
  • Lose nothing and double nothing when the shop is killed between saving something and the work that follows, and erase a customer's personal fields on request.

Deliverables

  • Your repository starts the shop, the fake payment provider, the carrier stand-in and the simulated shoppers, packer and carrier with one command.
  • A README that takes a reviewer from a fresh clone to an order that shipped in two parcels, with its history on screen, in 15 minutes, and lists the command for each test.
  • A test suite covering each Phase's failure tests: the 100-buyer race, the scrambled provider messages, the carrier reports that arrive late or twice, the kills, and the trading day.
  • A way to run the studio's day faster than real time, and to make the payment provider answer late, repeat itself, speak out of order, time out after accepting a request or fail, and the carrier report late or twice.
  • A hold-rules note: every hold the shop makes, how long it lasts and what ends it.
  • A one-page note for the carrier: how to report a parcel shipped or delivered, and what the shop answers to a report it refuses.
  • An owner's guide of one page: how to read an order's history from placement to refund, and what to do when a refund fails.
  • The results of the simulated trading day from the final Phase, committed to your repository.

Out of scope

  • Search by attribute or free text. The product list filters by part of the name, because a search feature is a second system to keep right.
  • Reallocating held stock when a count drops, safety stock and an offline location. A count correction that would go below what is held is refused.
  • 3-D Secure and extra card authentication. The fake provider approves or declines.
  • Handling card numbers. The provider gives the shop a reference for a card, and no card number is ever stored.
  • VAT, credit notes and invoices. Tax rules are national, so every price is the amount the shopper pays, in euro cents.
  • Real carrier integration. A stand-in reports parcels shipped and delivered.
  • Promotions, accounts and emails. An order carries the discount and shipping amounts it is given, and the order view tells the shopper what happened.
  • Disputes and chargebacks. A refund ends when the provider settles it.
  • Deleting records after their retention period. Dutch law makes the studio keep its business records for 7 years (Belastingdienst), so erasure removes personal fields and keeps order, payment and refund records, identified by ID, for that period. Deleting them once the 7 years have passed is outside this brief.
  • Backorders. A line nobody can pick is cancelled and refunded.
  • Deployment. Everything runs locally with one command.
  • Payment methods other than cards, such as iDEAL. The studio takes cards only, because the card is authorised at checkout and charged when the first parcel leaves, and iDEAL takes the money at once.

Architectural constraints

  • Amounts are whole euro cents, and a share of shipping or discount follows one stated rounding rule and adds up exactly to the original amount.
  • A unit is never sold twice. Every unit that ships was received, and no count the shopper or the owner sees is below 0.
  • Every stock number the owner sees can be explained line by line from the changes behind it, and no change is edited afterwards. A shelf check that finds 28 where the shop said 30 adds a line of minus 2 with a reason.
  • Every hold has an end. Stock held for a basket lasts 15 minutes until the order is confirmed. A confirmed hold ends by shipment, by cancellation or when the card authorisation runs out. A card authorisation lasts 7 days. Whatever nothing else resolves still ends at its deadline. The 14-day return window ends 14 calendar days after the last parcel of the order is delivered, holds nothing and is checked when a return is requested.
  • Money is never captured before the first parcel of an order ships, and never captured twice.
  • Money is never refunded beyond what was captured, whatever the shop is asked to refund.
  • An order keeps the price it was started at. A later price change never reprices it.
  • No card number is ever stored, logged or shown.
  • A message that claims to come from the payment provider but is not signed correctly changes nothing.
  • A fact reported from outside, such as a parcel shipped or a payment authorised, counts at the time it happened and not at the time it arrived. The order history is ordered by those times.
  • Times the owner and shoppers see are in Europe/Amsterdam.
  • On request, a customer's name, email and delivery address are erased or replaced with a pseudonym everywhere the shop keeps them, while orders, payments and refunds stay, identified by ID.

Prerequisites

You have built one application with a database, on any stack. You do not need to know how a ceramics studio sells from two places, or how stock holds, card authorisation or refunds work; the first Phase explains the business and the words the brief uses, each Checkpoint says what goes wrong and what it costs the studio, and the design is yours. You need to be able to send many requests to your running shop at the same moment, because the race tests do that. The beginner project Build a Two-Room Stock and Order Book covers the same domain at a smaller size and is not required.

Create a free accountSign in

Free to start. An account is what keeps track of the checkpoints you finish.

Phase 1

Publish products and count stock

Produces the rules of one order written down by hand, a catalogue with a price history, stock counts at two locations that can always be explained, and a product list shoppers can trust to be roughly current. Leaves holding stock for a buyer for the next Phase: nothing can be reserved yet.

Research

Implementation

Implementation

Implementation

Architectural walkthrough

How a ceramics studio sells from two places

The client is a small ceramics studio. It makes mugs, bowls and vases in its workshop and sells them online and from a shop in town, about 60 online orders a day. Big pieces sit in the workshop and small ones in the shop's back room, and the studio ships from both. An order can need pieces from both places, and then it ships as two parcels.

A shopper picks pieces and the shop holds them for 15 minutes while the shopper pays. The shop takes cards only. At checkout the card is authorised, which sets the money aside without taking it, and the money is captured when the first parcel leaves. An authorisation lapses after 7 days if nobody captures it. The payment provider keeps a fee on each refund, so a cancellation after capture costs the studio money.

When a piece is missing from the shelf, the studio either picks it from the other place or cancels the line and refunds it. A shopper can return items until 14 days after the last parcel is delivered. The studio inspects them and puts them back on sale or writes them off. The studio also moves stock between the workshop and the shop, counts the shelves now and then and corrects the count. It keeps its business records for 7 years, which Dutch law requires.

The words this brief uses:

  • Location: a place that holds stock, here the workshop or the shop.

  • Hold: stock kept for a shopper at checkout for 15 minutes.

  • Authorisation: the card issuer's promise to pay, which sets the money aside.

  • Capture: taking the authorised money. It happens when the first parcel ships.

  • Partly shipped: an order of which some parcels have gone and some have not.

  • Transfer: moving stock between the workshop and the shop. Moved units cannot be sold until received.

  • Shelf check: counting the stock by hand and correcting the shop's number.

  • Restock and write-off: putting a returned piece back on sale, or recording that it is lost.

  • Refund: sending money back to the card for the returned or cancelled lines.

Why the holds and the stock come first

The old shop held one stock number per product and overwrote it. A shelf check that found 28 vases where the shop said 30 replaced one number with another, and nothing recorded that two vases had gone missing or when. The studio could not settle a count with a partner or answer a customer who asked where an item went.

Before any code, this Phase has you work one order through by hand, because a hold you cannot explain in writing is a hold that stays live after the customer has gone: 15 minutes of a vase, 7 days of a card balance, five vases in a van between the workshop and the shop. Each of them needs an end, and the owner needs to know which one is still live at any moment.

Stock has a second problem. Units sent between the workshop and the shop are in neither place while they travel, and if the shop counts them anywhere in between it sells five vases that nobody can pick. A transfer received twice, by two people at the same moment, must still add five units and not ten.

The product list on the shop front is only a hint. The old shop rebuilt it overnight, so a sell-out reached the page up to a day late and shoppers paid for pieces that were gone. A list that lags by a minute is acceptable. A list that never hears about a sell-out because the shop died at the wrong moment is not, and a sale never goes ahead or is refused because of what the list says.

Phase 2

Reserve stock with a deadline

Produces held stock for a basket taken from the right location, a 15-minute deadline that gives units back by itself, and a concurrent test that proves a unit sells once. Leaves payment and orders for later: a hold here has no order behind it.

Implementation

Implementation

Testing

Architectural walkthrough

When the studio released 30 vases, the site read the stock when the page opened and trusted it afterwards, so 47 people paid. This Phase settles that decision at the moment of asking: the shop grants a unit, and a unit it grants is held for 15 minutes and then given back.

Two buyers who both see "1 left" and both pay take the same vase. The failure does not show with one buyer at a time, so the only test that means anything sends many buyers at the same moment to the running shop. The failure gets worse with baskets of several pieces. A basket needs a vase from one location and mugs from the other, and two baskets that each take part of what the other needs can leave both shoppers waiting, with an error where "sold out" should be.

The location rule makes it harder than one counter. The studio wants a basket to ship from one place when one place can cover it, and from the place holding more of each piece when neither can. A basket sent to a location because of counts that another buyer changed a moment earlier ships from a shelf that no longer has the piece.

The deadline is the second problem. Most holds end with an order, but a shopper who closes the tab sends nothing. Without something that gives those units back on its own, a closed tab holds a vase until someone notices. A shop that dies halfway through giving units back must not leave a hold that shows as released while its units are still counted as held, or the other way round.

Phase 3

Take payment

Produces a fake payment provider that misbehaves on demand, and payments that hold card money for at most 7 days and stay true when the provider repeats itself or speaks out of turn. Leaves capture and refund for later Phases: money is only held here, never taken.

Implementation

Implementation

Implementation

Testing

Architectural walkthrough

The old shop charged the card when the customer ordered, so every cancellation became a manual refund and every refund cost the studio a provider fee. This Phase puts the order the other way round: ask the provider to hold the money, take it later, and show a payment that stays true when the provider repeats itself or speaks out of turn.

The provider's first answer only says it received your request. The outcome comes later, as a message the provider sends to your shop when something finishes. So the shop has to act correctly when it asks twice, when it hears twice, and when it hears in the wrong order. A request that timed out may still have succeeded, and treating the timeout as a failure leaves money held on a card that no order knows about.

Three words recur. An authorisation is the provider's promise to keep an amount on the customer's card for you, for at most 7 days. A release gives that promise back before you take the money. A lapse is the promise running out because nobody took the money in time. All three are holds with an end, like the stock hold in Phase 2.

A stand-in that always answers at once and in order cannot show any of this, so the first Checkpoint has you build one that can be late, repeat itself, reorder its messages and stay silent. The rest of the build is tested against it.

A payment must only move forward, and it must show when each fact happened on the provider's clock. Without that, a late "authorised" message pulls a released payment back to authorised, and the next Phase takes stock for money the shop has already given back.

Phase 4

Place and ship an order

Produces a priced order that gives back stock and card on any failure, one parcel per location, and a single capture at the first shipment. Leaves cancellation, returns and refunds for the next Phase: an order can be placed and shipped here, and nothing takes it back.

Implementation

Implementation

Implementation

Testing

Architectural walkthrough

The old shop charged the card for an order that shipped in two parcels once per parcel, and the owner found out when the customer wrote in. This Phase sells a basket correctly: price it once, hold the stock and the money, ship from each location, and take the money exactly once.

A placed order holds two things, stock and money, and whichever step fails must give back both. The case that finds the gap is an authorisation that reaches the shop after the stock hold has already expired. If only the stock is given back, the shopper's card stays held for 7 days for a vase they never got. Two different failures can also reach the same order at once, such as the expiry and a refused confirmation, and the shopper must not end up with two cancellations or two releases of the same hold.

The order's price is fixed when checkout starts, and the shipping and the discount are split across lines at that moment. A later refund for one line has to give back that line's part of both. Shares recomputed later from changed prices give a different answer from the one the order was priced with.

The money is taken once, when the first parcel ships. The carrier is a partner whose reports can arrive hours late and twice, and a delivery report keeps the time the parcel was delivered, not the time the upload arrived. If the shop dies after placing an order and before the parcels exist, the shopper has paid for an order that nobody packs.

The order view starts here. It must show what happened to a customer's stock and money in the order it happened, even when a late report describes something that happened before the facts that followed it.

Phase 5

Cancel, return and prove the whole

Produces short-pick handling, line and order cancellation, returns with inspection, refunds that cannot exceed what was captured, and a simulated trading day with failures injected. Leaves nothing for later: this Phase closes the build.

Implementation

Implementation

Implementation

Implementation

Implementation

Testing

Architectural walkthrough

The studio refunded 17 customers by hand and two of them twice. This Phase takes money back out of the shop, and the rule it turns on is that money out is capped by money in. A refund can never exceed what was captured, and the shop has to hold to that even when it is asked for more.

Cancelling an order or a line means different things depending on where the money is. Before capture, a whole-order cancel gives the held money back, and a cancelled line makes the later capture smaller. After capture, a cancel is a refund, and the provider settles a refund 10 seconds later, or fails it. The shopper and the owner see one action: cancel.

A refund must happen exactly once. A timeout after the provider accepted the request, a duplicate message, a shop that dies right after saving the cancel, and two people cancelling the same line at the same moment can each send the money twice. The provider also keeps a fee on every refund, so every avoidable second refund costs the studio twice.

When a packer cannot find a piece, the shop has to decide what happens to it once. If the shop decides twice, the line is moved to the other location and cancelled at the same time.

The last Checkpoint tests everything at once. Tests of single features pass while a card stays held after a provider outage, and the simulated day is where that shows. If the cap is missing, the day finds a refund sized from the order total when only one line came back.

Architectural walkthrough

The last vase sold 47 times

The old shop checked the stock when a page opened and trusted that answer until the customer paid. The page that said "in stock" and the moment the money was taken were never one decision, which is how 47 people paid for 30 vases in 25 minutes. The new shop has to refuse the 31st buyer at the moment they ask, whatever the product list on screen still says. Test this with many buyers at once. A shop that is right for one buyer at a time can still sell the same vase twice.

Every hold ends

Stock held for a shopper lasts 15 minutes. A card authorisation, the provider's promise to keep the money on the card for you, lasts 7 days. A shopper who closes the tab, a payment that never reports back and a step that failed halfway must each end with the units on the shelf and the card released.

Stock and money are two holds on two different things, and the shop has to give back both whichever step fails. The case that tests this is the authorisation that arrives after the stock hold has already expired. If the shop gives back only the stock, the shopper's card stays held for 7 days for a vase they never got.

Messages arrive late, twice and out of order

The payment provider and the carrier are outside the shop. The provider repeats a message when the shop answers slowly, sends one late when its own backlog grows, and can deliver two in the wrong order. A "released" message followed by a late "authorised" one must not bring the payment back to life. The carrier uploads a delivery report hours after the parcel arrived, and the time of the order's last parcel delivery starts the shopper's 14-day return window.

Dying in the middle

A shop process can die between saving an order and starting the work that follows. A placed order then never gets its parcels, or a refund is recorded and never sent. The opposite failure is worse for the studio: after a restart the same work runs a second time and a customer is refunded twice, which is what happened to two of the 17 customers.

Money out is capped by money in

A refund sized from the order total when only one line came back takes more money out than came in. A refund sent again after a timeout takes it out twice. The shop must know what was captured and refuse to give back more, whatever it is asked.

Where it shows if you cut a corner

The 100-buyer test in Phase 2 sells an eleventh unit if two buyers can both see the last one as available. The money test in Phase 5 finds a refund sized from the order total when a line was only partly returned. The final trading day finds a card still held after a provider outage, or a placed order with no parcels after a kill. Each test finds the defect before the next limited drop does.