Back to blog

Draw the system twice: why one sketch is never enough?

Thắng Đoàn
Thắng Đoàn

FotoFlow has two million users and six new engineers starting next month, so the team finally writes the architecture down. The first attempt is one giant diagram: boxes, arrows, class names and table columns on the same page, and nobody can read it. The second attempt is worse: a new hire designs the courier-like upload flow in an interview as pure class diagrams and never mentions that photo ingest arrives 40,000 times a second.

The map: high-level design

High-level design, HLD, decides what the parts are and how they connect: which services exist and what each owns, whether they talk by call or by event, where each kind of data lives, and what happens when traffic grows or a part fails. It is the level of every article in this series so far. Its output is a one-page diagram with the reasoning written next to it; if a box needs a paragraph to explain, that paragraph belongs to the LLD of that box.

Every arrow and store on that diagram is a decision with an alternative. Uploads publish events rather than calling the transcode service, so a slow transcoder cannot block an upload; payments get a relational database because it needs transactions; view counts get a fast key-value store because they are tiny, hot and always overwritten. HLD and LLD answer different questions for different readers.

The room: low-level design

Low-level design, LLD, opens one box: the modules or classes it is made of, the interfaces between them, its tables and indexes, its algorithms and error handling. Inside the upload service, a controller takes HTTP requests, an upload service holds the rules, a repository talks to the store, and a client wraps calls to the virus scanner. LLD also pins down the state machine, an upload can be cancelled while pending or processing but not once stored, the table with its index on (user_id, created_at) for "my uploads", and the awkward cases: what if the scan call times out, or the same upload arrives twice. Most production bugs live at this level: a state nobody allowed for, a missing index, a retry that charges twice.

Where they meet

The two levels meet at contracts. HLD fixes what a component promises, its API and the events it publishes; LLD decides how it keeps that promise. That split is what lets teams work independently: the upload service can rewrite everything inside its box as long as POST /uploads and PhotoUploaded keep meaning the same thing. Changing a contract is an HLD change: other teams must agree, and old and new versions must coexist for a while.

What this does not solve

A diagram is a snapshot, and snapshots rot: services appear and disappear while the wiki page keeps last year's truth, quietly lying. Tie the document to decisions rather than boxes, date every change, and review it when the HLD changes, which is rare and worth recording anyway. And the wrong zoom is the classic interview failure: twenty minutes on class diagrams without the 40,000-ingest number, or perfect boxes with no answer to "what if the scan is slow." Work top-down: requirements, numbers, then dive where the hard problems are. A design session runs: requirements, estimates, API, data model, HLD, deep dives, failure cases.

Open the last architecture diagram your team made. Which boxes no longer exist, and who would notice?
Your service's main API: if another team changed one field of it today, whose build would fail first?

The method is in hand; now it gets exercised end to end. Next in the series: FotoFlow wants short share links: could you design one today?

Sources

System Design Primer

Google SRE Books

Designing Data-Intensive Applications

Share:

Recommended for you

Enjoyed this article?

Subscribe for new articles. No spam. Unsubscribe anytime.

No pasting. This is the challenge.0/200

Typed live, never pasted.