Skip to content
Lesson 36

The system design method

Six steps, in a fixed order, from a vague request to a design you can defend: ask, estimate, define, draw, dig, decide. Worked on StayHub's new reviews feature.

The lesson in text

Click a paragraph to hear it.

01Boxes before questions

Tuesday morning at StayHub. Maya, our product manager, wants guest reviews on every hotel page, in four weeks. Ten minutes into the meeting, the whiteboard already shows Kafka, Cassandra and five new services. Those are big tools, built for very big systems. It looks serious.

Then Lina, our senior engineer, asks one simple question: how many reviews do we get a day? Nobody knows. The whole design was drawn before anyone asked.

In this lesson you'll learn the method senior engineers use instead: six steps, in a fixed order, from a vague request to a design you can defend. And when Claude Code proposes an architecture, that order is exactly what you check.

02An architect

Think of an architect designing a house. A good one doesn't start with the floor plan. First, she asks questions. How many people will live here? Does anyone work from home? How cold are the winters?

Then she does a little maths. Five people, two showers a day each: that's the size of the water heater. She decides where the doors, the windows and the sockets go. Only then does she draw the plan.

Next, she looks hard at the parts where a mistake is expensive: the foundations, the staircase. And finally she tells the client what she chose and what it costs. An open kitchen is friendly, but noisier.

Designing software works the same way, in six steps: ask, estimate, define, draw, dig, and decide. Each step gives the next one what it needs. Skip one, and you're guessing.

Six steps, in this order
StepThe architectYour designIt gives you
1 · AskWho lives here? Cold winters?What it does, and how wellRequirements
2 · Estimate5 people × 2 showers a dayReviews a day, page views a second, storageThe size of the problem
3 · DefineDoors, windows, socketsThe API and the data tableThe contract
4 · DrawThe floor planThe boxes and arrowsThe high-level design
5 · DigFoundations, staircaseThe hardest one to three partsWhere it would break
6 · DecideOpen kitchen: friendly, noisierWhat we chose, gave up, and when we'd revisitA decision you can defend
Each step produces what the next one needs. The boxes come fourth, not first.

03Step 1 · Ask

Step one: ask. Who uses it, what do they do, and what's out of scope? For reviews: only guests who finished a stay can write one. Text and photos. Hotels can reply. Translation? Not now.

Those are functional requirements: what the system does. Write them as a short list. Each line is something a guest or a hotel can do.

Then come the questions most people forget: how well must it work? These are non-functional requirements. How fast, how available, how safe with the data, and how much it may cost.

For reviews, Maya and Lina agree on three. The reviews part of the page loads in under 200 milliseconds. A review a guest submits is never lost. And a new review may take a few minutes to appear.

StayHub reviews: the two kinds of requirements
Functional: what it does
  • · Guests with a finished stay write a review (one per booking)
  • · Text and photos
  • · Hotels can reply
  • · Out of scope for now: translation
Non-functional: how well
  • · The reviews part of the page loads in under 200 ms
  • · A submitted review is never lost
  • · A new review may take a few minutes to appear
The features say what to build. The non-functional list decides the architecture: "within minutes" is what later allows a background job and a cache.

Here's the surprise. Two systems with the same features can need completely different designs. The features say what to build. The "how well" decides the architecture.

04Step 2 · Estimate

Step two: estimate. Turn the requirements into a few rough numbers, the way the architect counts showers. Not exact numbers. The right size.

StayHub gets about 2,500 bookings a day, and roughly 30% of guests leave a review. That's 750 reviews a day. A day has 86,400 seconds, so that's one new review every two minutes.

Reading is bigger. Hotel pages are opened about 120,000 times a day: about 1.4 times a second on average. At the busiest moment, say ten times more: about 14 a second.

Each review's text is about one kilobyte. So a whole year of reviews is under 300 megabytes. That would fit on your phone.

The estimate, line by line
2,500 bookings × 30% = 750 reviews a dayhow many writes
86,400 s ÷ 750 ≈ 115 sone review every two minutes
120,000 page views ÷ 86,400 s ≈ 1.4 a secondaverage reads
1.4 × 10 ≈ 14 a secondthe busiest moment
750 × 1 KB × 365 ≈ 274 MB a yearunder 300 MB of text
→ one table in the PostgreSQL we already runno Kafka, no Cassandra
Every number ends with what it changes. An estimate that changes nothing is decoration.

Now the most important habit: every number must change something. One write every two minutes? A single table in the database we already run handles thousands a second. So Kafka and Cassandra are ruled out by the numbers, not by taste.

05Step 3 · Define

Step three: define the contract, the way the architect places the doors and windows. What can the outside world ask the system? That's the API: get a hotel's reviews, get its rating summary, post a review.

Writing it down raises questions right away. Can anyone post a review? No: the request must carry a booking number. And checking for spam takes time, so the answer is "received, pending", not "published".

Then the data. One table of reviews, shaped around the question it will be asked most: the newest reviews for this hotel. And one rule the database enforces by itself: one review per booking.

Step 3: the contract and the table
The API
GET /hotels/42/reviews?sort=newesta hotel's reviews
GET /hotels/42/rating-summarythe average, for every page
POST /reviews { "bookingId": "b_5521", "rating": 9, "text": "…" }only with a booking
202 Accepted { "status": "pending" }received, not yet published
The table
reviews(id, hotel_id, booking_id, rating, text, status, created_at)one row per review
UNIQUE (booking_id)one review per booking, enforced by the database
INDEX (hotel_id, status, created_at)the most asked question: newest reviews for this hotel
Writing the API raised two questions at once: who may post (a booking number is required) and what to answer while spam is checked (202: received, pending).

06Step 4 · Draw

Step four: draw the boxes. Only now, and only the boxes that a requirement or a number asks for.

The guest's browser calls the StayHub app we already run, which gets a new reviews module. Reviews go into our PostgreSQL database. Photos go to file storage, and the CDN serves them from copies close to the guests.

Spam checks run in the background, so the guest gets an instant thank you. And every box points back to something: the CDN to photo traffic, the background job to "never lost" and "within minutes".

Step 4: every box points back to something
BoxWhy it's there
Reviews module in the existing appOne write every two minutes needs no new service
The PostgreSQL we already runUnder 300 MB a year; one review per booking is a database rule
File storage + CDN for photosPhoto bytes are the heavy traffic; they stay off our app servers
Background job for spam checks"Never lost" and "visible within minutes": the guest gets an instant thank you
Cache for the rating summaryThe 200 ms target on every hotel page (step 5)
The whiteboard's Kafka, Cassandra and five services had no line in this table. That's the test for over-engineering.

Now compare with the whiteboard: Kafka, Cassandra, five services. Not one of those boxes pointed to a requirement. That's how you spot over-engineering: ask each box, which number needs you?

07Step 5 · Dig

Step five: dig into the hardest part, like the architect checking the foundations. You only have time for one to three parts, so pick the place where heavy load, real risk and a stated target meet.

For reviews, it isn't posting. That happens every two minutes. It's reading. Every hotel page shows an average rating, and it has to load in under 200 milliseconds.

The naive way computes the average over a hotel's 3,000 reviews on every page view: about 90 milliseconds, on the same database as checkout. The better way: when a review is approved, update one small summary row, and keep a copy in a cache, a fast memory for answers that are asked again and again. Now each page view costs about 2 milliseconds.

Step 5: the rating on every hotel page
Naive: compute it on every view (~90 ms, on the database checkout uses)
Hotel page
StayHub app
PostgreSQL
show hotel 42
average of 3,000 reviews?
8.6 (after ~90 ms)
Better: a summary row, updated on approval, kept in the cache (~2 ms)
Hotel page
StayHub app
Cache
show hotel 42
summary of hotel 42?
8.6 · 3,000 reviews (~2 ms)
Do the work on the rare event (a review is approved, every two minutes), not the frequent one (a page view, up to 14 a second). The price: the rating can be a few minutes behind, which the requirements allow.

Notice the trick: do the work on the rare event, a new review, not on the frequent one, a page view. The price is that the rating can be a few minutes behind. And the requirements said that's fine.

08Step 6 · Decide

Step six: decide, out loud. Say what you chose, what you gave up, and what would make you change your mind.

Karim, our CTO, pushes back: investors will ask about ten times growth, so build reviews as a separate service now. Lina does the maths. At ten times, that's one review every twelve seconds, and about 140 page views a second. Still one table.

So the decision: a module in the app we have, with a clean boundary, plus a written trigger: revisit if reviews pass 50 writes a second. What was given up is on paper, and nobody has to guess later when the design stopped fitting.

09When a step is skipped

What happens when a step is skipped? Omar, our on-call engineer, remembers last July. The deals page had been designed for its average traffic: about three requests a second.

Then marketing sent a summer-sale email to 400,000 people. Four hundred requests a second, each running a heavy query on the main database. The database hit its limit, checkout waited in line behind the deals page, and bookings failed in the best sales hour of the month.

One line in the design would have caught it: the peak. Always estimate the busiest moment, not just the average, and write down what it changes.

10Your job as lead

When you ask Claude Code to design a feature, ask for the six steps, in order, in a short design doc, before any code. And give it your real numbers. Never let it invent the traffic.

Then check three things. Does every box name the requirement or the number that needs it? Did it estimate the peak, not only the average? And does it say what it gave up?

Let's recap: ask, estimate, define, draw, dig, decide. Questions first, then numbers, then boxes. Below the video you'll find the text, the diagrams and ten questions. In the next lesson, we get fast at the numbers themselves.

Check yourself

0/10 answered
  1. 1Which of these is a non-functional requirement for StayHub reviews?

  2. 2Why does the method estimate before it draws any boxes?

  3. 3Claude Code's design doc for reviews opens with "Kafka, Cassandra, five services" and says "Estimates: to be done after the architecture is agreed." What do you ask for?

  4. 4StayHub gets about 750 reviews a day. Roughly how often does a new one arrive?

  5. 5Two teams build a reviews feature with exactly the same features, but end up with very different designs. Why can both be right?

  6. 6You have time to dig deep into one part of the reviews design. Which one?

  7. 7The summary row is updated when a review is approved, and cached. What did the design give up?

  8. 8The deals page was designed for about 3 requests a second. A sale email brought 400 a second and checkout failed. Which step was missing?

  9. 9Karim wants reviews built as a separate service now, "for 10× growth". At 10×, reviews are one write every twelve seconds. What's the best answer?

  10. 10You review a design Claude Code drew. Which question catches over-engineering best?

Free account

Save your progress — create a free account

Free. No card. Your finished lessons follow you to any device, and you can ask questions in the community.

Create my free account
Founding members

Every lesson is free while we build. Lock in €9/month for later.

The first 100 members keep the founding price for as long as they stay. Reserving is free: no card, nothing is charged.

See the founding offer

Questions from the community

All questions →