Skip to content
Lesson 29

What software architecture is

Architecture is the few choices that are expensive to change later. Learn the two ideas that decide whether a change takes an hour or a week, and which decisions deserve your care.

The lesson in text

Click a paragraph to hear it.

01One number, six days

Tuesday morning at StayHub. Maya, the product manager, has a simple request: free cancellation should go from 24 hours before check-in to 48 hours. It's one number. It took six days.

And it still wasn't right. The admin panel kept saying 24 hours. The support team trusted it, and 37 guests were refused a refund they were owed.

Nobody was careless. The servers were fine, and the deploy took twenty minutes. The problem was the shape of the code. That shape has a name: architecture.

In this lesson, you'll learn what architecture really is, the two ideas that decide whether a change takes an hour or a week, and the questions to ask Claude Code before it builds anything big.

02A hotel building

Think of a hotel building. Repainting a room takes an afternoon. New curtains, new lamps, a new menu at the bar: easy, cheap, done by Friday.

Now try to move the lift shaft. Or the plumbing. Or the main staircase. That's a construction project: walls come down, floors close, and every room around it is affected.

Software architecture is the lift shafts and the plumbing of your code. It's the few choices that are expensive to change later, because everything else leans on them.

In practice, it's two kinds of choices: where code and data live, and which part is allowed to depend on which. Not boxes on a whiteboard, but the real structure, the one the code actually has.

The hotel building, and your code
In the hotelIn your codeCost to change
Repainting a roomRenaming a function, changing a colourMinutes to hours
New curtains, a new bar menuSwapping a small libraryAn hour
Moving the lift shaftChanging the main databaseMonths
Moving the plumbingChanging who owns which data, and who may depend on whomMonths
Architecture is the bottom of this table: the few choices everything else leans on, so they cost the most to change later.

03How a rule spreads

So how did one number take six days? Go back four years. StayHub has two engineers and one file that checks: up to 24 hours before check-in, cancellation is free. Everything fits in two heads.

Then the admin panel needs the rule, so someone copies it there. The nightly refund job needs it: another copy. Then the invoice PDF, then seven email templates. Each copy was the fastest thing to do that day.

Four years later, StayHub has fourteen engineers in three teams, and the rule lives in eleven places. When Maya asked for 48 hours, the deploy was quick. The rest of the six days went into finding every copy.

One rule, eleven places, and one home
Before: 11 copies
  • · Booking API computes "48 h"
  • · Admin panel computes "24 h"
  • · Nightly refund job computes "48 h"
  • · Invoice PDF computes "48 h"
  • · 7 email templates computes "48 h"
6 days to change, and two screens disagreed.
After: one home in Booking
canCancelFree(booking, now)
  • · API, admin panel, refund job: call it
  • · PDF and templates: display the answer
Next change: one file, about an hour.
Before: every place computed the rule itself, and one change missed the admin panel. After: Booking owns one function; the others call it or only display its answer.

And they missed one. The admin panel still said 24. Two screens gave two different answers, and guests paid for it.

Back to the hotel. Imagine the check-out time printed on a sign in every room, in the lift, in the welcome letter and on the website. Change the time, and you hunt for every sign. Miss one, and guests get two answers.

04One home per rule

The fix starts with a question: who owns this rule? At StayHub, cancellation belongs to the Booking team. So the rule gets one home, inside Booking: one function that answers, can this booking still be cancelled for free?

Every other place calls that function. The admin panel asks it. The refund job asks it. The templates and the PDF don't calculate anything anymore: they only display the answer they're given.

This idea is called cohesion: things that belong together live together. High cohesion means one rule, one home. Next time, 48 becomes 72 in one file, in an hour.

In the hotel, reception decides the check-out time, and the screens in the rooms only show what reception says. Change it at the desk, and every screen is right.

05Loose edges

The second idea is about the edges between parts. When a guest cancels, StayHub refunds them through a payment provider. In the old code, the cancellation rule called the provider's own code directly, in several places.

That's coupling: how much one part needs to know about another. Tight coupling means a change in one place forces changes in every place it touches. Switch payment providers, and you'd rewrite the cancellation rule too.

Think of the sockets in a hotel wall. Nobody wires a hair dryer into the wall. The wall offers a standard socket, and any hair dryer with the right plug works. Change the brand, and the walls stay closed.

In code, the socket is called a port: Booking says, I need a way to refund a booking. The plug is an adapter: a small piece that connects that port to the real payment provider. Change providers, and only the adapter changes.

A port and an adapter: the socket and the plug
Cancellation rule
Refund port
Adapter
Payment provider
refund booking LIS48213
plugged in here
the provider's own call
refunded
Booking only knows its own port (“I need a way to refund a booking”). The adapter is the only code that knows the payment provider. Switching providers means writing a new adapter; the rule doesn't move.

So good architecture is tight inside each part and loose between parts: high cohesion, low coupling. Almost every idea you'll meet in this module is a way to get those two.

06The plan and the real building

Now a trap. One Thursday evening, the Booking team renamed a column in the bookings table, from state to status. Their tests were green. The architecture diagram said only Booking uses that table.

But a Search job, drawn on no diagram, read that column every night at two in the morning. It crashed. Search stopped updating which rooms were free, so sold-out rooms stayed on the site.

Guests picked those rooms and failed at checkout. By morning, Maya's booking numbers had dropped. The diagram described what someone intended. The code did something else.

The diagram said one thing, the code did another
  1. Thursday eveningBooking renames bookings.state to status. Tests green. The diagram says only Booking uses the table.
  2. 2:00 at nightA Search job, on no diagram, reads bookings.state. It crashes.
  3. Through the nightSearch stops updating which rooms are free. Sold-out rooms stay on the site.
  4. MorningGuests pick those rooms and fail at checkout. Booking numbers have dropped.
The fix: Booking owns the table, Search asks Booking through its interface, and a check fails the build when one part reads another part's data.

In the hotel, it's the floor plan that shows an empty wall, and the builder who knocks it down and finds a water pipe. Architecture lives in what the code really uses and which data it really touches.

So make the boundaries real. A check that fails the build when one part reaches into another part's data turns the diagram from a wish into a rule.

07One-way and two-way doors

Not every choice deserves that much care. Jeff Bezos, Amazon's founder, sorted decisions into two kinds. A two-way door: you walk through, and if you don't like it, you walk back. A one-way door: once you're through, coming back is slow and costly.

Choosing a library to handle dates is a two-way door. You can swap it in an hour. Decide fast and move on.

The main database, a partner API that 1,800 hotels have built on, which team owns the bookings data: those are one-way doors. Slow down, compare the options, and write the decision down.

One-way or two-way door?
DecisionDoorSo
A library that handles datesTwo-waySwap it in an hour. Decide fast.
A button style, a page layoutTwo-wayChange it next week if it's wrong.
The main databaseOne-wayEvery part leans on it; moving it takes months.
The partner API 1,800 hotels built onOne-wayChanging it breaks 1,800 integrations.
Which team owns the bookings dataOne-wayEverything that reads bookings depends on it.
One-way doors get a short decision record: the problem, the options, the choice and why, and a line that starts with “revisit if”.

A good decision record is short: the problem, the options, what you chose and why, and one line that starts with "revisit if". For cancellation: revisit if Booking ever needs to release on its own schedule.

08Your job as lead

Claude Code is fast, and it will happily put a rule wherever the file it's editing happens to be. Speed today can build eleven copies tomorrow. So architecture is a decision you make, not one you leave to the agent.

Say you ask it to make free cancellation 48 hours. It answers: done, I changed it in the cancel controller, and all 212 tests pass. Then you search, and you still find 24 in three other files.

Don't accept it, and don't just ask for three more patches. Ask first: list every place that computes this rule, and whether it computes or only displays. Then: propose one home for it that every screen calls.

Before anything big, keep four questions ready. Who owns this rule? Where else is it computed? What does this part depend on, and through which port? And is this a one-way door, or a two-way door?

Let's recap. Architecture is the lift shafts: the choices that are expensive to change. Give each rule one home: that's cohesion. Keep the edges loose: that's coupling. Trust the code, not the diagram, and save your care for one-way doors. Next, the biggest door of all: one app, or many small services.

Check yourself

0/10 answered
  1. 1Which of these is an architecture decision?

  2. 2In the hotel picture, what is the architecture?

  3. 3Changing free cancellation from 24 to 48 hours took six days. What was the real cause?

  4. 4Claude Code says: "Done, I changed it in the cancel controller, all 212 tests pass." You still find 24 in three other files. What do you do?

  5. 5What does high cohesion mean?

  6. 6Claude Code proposes that the cancellation rule call the payment provider's code directly. What's the risk?

  7. 7Booking renamed a column. The diagram said only Booking uses that table, yet a Search job crashed at 2 a.m. What's the lesson?

  8. 8Which of these is a two-way door?

  9. 9You face a one-way door. What should you do?

  10. 10Claude Code is about to build a loyalty points feature that many screens will show. Which question should you ask first?

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 →