LLD · 01 System Design: LLD

What Is Low-Level Design?

What Is Low-Level Design?

A meeting-room booking app has a perfect architecture diagram, and still books two people into the same room at the same time. The bug is inside one box, and the inside of the box is what low-level design is for. We design it the way an LLD interview runs: requirements, entities, the class diagram, method signatures, the code and its tests, and then a change request. All five LLD artifacts, built for one small feature, with real Python that runs and real tests that pass.

Chapters

Cheat sheet

Code

A 73-line booking module with 7 unit tests and 4 integration tests on a real SQLite database (11 passed), then the "rooms can be booked by a whole team" change request (15 passed, with the old tests untouched). Python 3.14 and pytest:

The one rule at the heart of it: two time slots overlap when each one starts before the other one ends. So back-to-back meetings, 10:00 to 11:00 and then 11:00 to 12:00, don't clash: a slot includes its start but not its end.

Sources

Transcript

Here's a design for a meeting-room booking app: an app, a booking service, and a database. Every box is right. Now Ana books room 4B from ten to eleven, and Ben books the same room from ten thirty to eleven thirty. Both get a confirmation. Nothing on this diagram is wrong.

The bug is inside one of the boxes: a check that compares the start times, and nothing else. In an interview, this is the moment the interviewer points at the booking service and says: great, now design the inside. That's low-level design, and today we'll do it from start to finish.

This is Just Known. From unknown, to known. Episode one of our low-level design series: what is low-level design? System design works at two zoom levels. Zoomed out is high-level design: which services there are, which databases, how they talk to each other, and how the whole thing scales and survives when a machine fails.

Zoom into one box, and you're in low-level design: which classes live inside it, what each one is responsible for, which methods they offer, what data they hold, and what happens when two requests arrive at once. High-level design keeps the system up and fast. Low-level design keeps the code correct, and easy to change and test. This series is about the inside of the box. A high-level design series will come later.

Low-level design makes five kinds of decisions. Which classes exist, and what each one is responsible for. How they relate: who owns what, and who calls whom. The method signatures: exactly what goes in, what comes out, and what can go wrong. The data: the structures in memory, and the tables on disk.

And concurrency: what has to stay correct when many requests run at the same time. Get those right, and the code is maintainable, extensible, and testable. Those three words are what this whole series is about. Those decisions get written down as five artifacts: a class diagram, a sequence diagram, the table schemas, the method signatures, and the tests. By the end of this episode, we'll have all five for one small feature, with real code that runs and real tests that pass.

And we'll build them the way an LLD interview runs: requirements first, then the entities, the class diagram, the method signatures, the code and its tests, and finally, a change request that puts the design to the test. Step one: requirements. Don't design anything yet; ask questions first. For our feature, the answers are these. Rooms have a name and a number of seats.

A person books a room for a time slot. Two bookings of the same room must never overlap. Only the person who booked can cancel. And anyone can search for free rooms, for a time and a head count. Just as important is what's out of scope, for now: recurring meetings, reminders, and time zones.

Then push on the edges. Is ten to eleven, then eleven to twelve, a clash? No: back to back is fine. Can a slot end before it starts? Never.

Those answers will become tests. Step two: entities. A useful trick: the nouns in the requirements are candidate classes, and the verbs are candidate methods. It goes back to 1983, when Russell Abbott showed how the nouns in a plain English description suggest the data types, and the verbs suggest the operations. The nouns give us a room, a time slot, and a booking.

A person matters too, but here a person is just a name, so for now it stays a string. The verbs, book, cancel, and find free rooms, need a home that can see every booking, so they go on a booking service. The time slot is worth a class of its own, even though it's only a start and an end. It's a value: once it's made, it never changes, and it's the one place that knows whether two slots overlap. Step three: the class diagram.

Each box is a class, with its name on top, then its data, then its methods. A plus sign means public, and a minus sign means private. A booking points to exactly one room, and one time slot. The booking service holds the rooms, and owns the bookings. Its dictionaries and its lock are private, so nothing outside can go around the rules.

Notice where the cancel rule lives: on the booking, as can cancel. The booking knows who made it, so it's the right object to answer who may cancel it. We'll read every kind of arrow properly in episode three. Step four: method signatures. A signature is a contract: what goes in, what comes back, and what can go wrong.

Book takes a room name, a time slot, and a person, and returns the new booking. If the slot clashes, it raises room unavailable. Cancel takes a booking ID and a person, and raises a permission error if they're not allowed to cancel it. Free rooms takes a slot and a head count, and returns a list of rooms. Agreeing on these first means the caller, the tests, and the code itself can all be written against the same promise.

Step five: the code. The heart of this whole feature is one line, in the time slot class. Two slots overlap when each one starts before the other one ends. Ana's ten to eleven, and Ben's ten thirty to eleven thirty: ten is before eleven thirty, and ten thirty is before eleven. Both are true, so they clash.

Now try eleven to twelve. Eleven is not before eleven, so there's no clash. Back-to-back meetings are fine, because a slot includes its start, but not its end. Frozen makes a slot impossible to change, and the check when it's made means a backwards slot can't exist at all. The whole module is seventy-three lines.

Here's book running, as a sequence diagram. Time flows down the page, and each arrow is a call. Ana's request reaches the booking service, which takes its lock, then asks each existing booking's time slot: do you overlap this one? None do, so it creates booking number one, and returns it. Ben's request takes the same path, but this time, a slot answers yes, so the service raises room unavailable instead.

We'll learn sequence diagrams properly in episode four. For now, notice what they show that a class diagram can't: the order of the calls. Now the data. Bookings must outlive the program, so they go in a database, and each class becomes a table, or doesn't. A room becomes the rooms table.

A booking becomes the bookings table, pointing to its room. The time slot doesn't get a table at all: a value like that becomes two columns, starts at, and ends at. And the booking service is behavior, not data, so it has no table. The database guards the rules too. A check constraint rejects a booking that ends before it starts, and the overlap rule comes back as a query, with the same two comparisons, in SQL.

One trap: SQLite only checks that a booking's room exists if each connection turns that check on. Without it, a booking for a room that doesn't exist goes straight in. One more decision: concurrency. A real service handles many requests at once. If Ana's request and Ben's request both check the room before either one writes, both see it free, and we're back to a double booking.

So the check and the write must happen as one step. That's the lock. One request at a time goes through the check and the write, and the other waits its turn. Deciding where the locks go is low-level design too. In episode twenty-two, we'll watch this race happen for real.

Now the tests: eleven of them. Seven are unit tests: the time slot and the booking service on their own, with no database. The other four are integration tests, which run the real schema in a real SQLite database. Look at which cases they pick: the edges. Back-to-back slots, a backwards slot, someone else trying to cancel.

That's where bugs hide, and where a good tester looks first. All eleven pass. But do they catch anything? We put the cold open's bug back in, comparing start times only, and ran the unit tests again. Three of them failed.

With these tests, that bug never ships. Step six: the change request. Rooms can now be booked by a whole team. First, clarify: anyone on the team can cancel a team booking, and the team has to fit in the room. Now use the artifacts to see the blast radius, before writing any code.

The class diagram gains a team class, and a room-too-small error. The booking gets an optional team, and its can cancel rule widens. Book gets a team parameter, with a default, so every old call still works. Cancel doesn't change at all, because the rule lives on the booking. And two new tables hold the teams and their members.

Then we write it. The code gains nineteen lines and loses four. The eleven old tests weren't touched, four new ones join them, and all fifteen pass. How much design is enough? Too little, and you get the cold open.

Too much, and a seventy-three-line feature turns into twenty classes, built for changes that never come. Design for the requirements you have, and keep the pieces clean, so the next change is easy. We didn't add teams until someone asked, and when they did, the change stayed small. That balance is the real skill, and the rest of this first act gives you the tools for it. Interview corner.

What's the difference between high-level and low-level design? And what does a low-level design actually produce? Pause here, and try answering in thirty seconds.

Here's a strong answer. High-level design is the whole system: which services and databases exist, how they talk, and how it scales and survives failures. Low-level design is the inside of one component: its classes, their responsibilities and relationships, the method signatures, the data, and the thread safety. It produces class and sequence diagrams, table schemas, method signatures, and tests, and it aims for code that's correct, easy to change, and easy to test. To stand out, name the edge cases out loud before you're asked: back-to-back slots, and two requests at once.

Let's recap. High-level design picks the boxes; low-level design builds what's inside one. It decides the classes, their relationships, the signatures, the data, and the concurrency, and it writes them down as diagrams, schemas, signatures, and tests. And a change request is how you find out whether the design was any good. Here's the road ahead.

Act one: thinking in objects, ending with a parking lot. Act two: the classic design patterns. Act three: concurrency and thread safety. Act four: data, contracts, and tests. Act five: low-level design on Android, in Kotlin.

And to finish, a full mock interview. Next, the foundation under all of it. That's episode two: object-oriented programming in practice, the four pillars. This is Just Known. From unknown, to known.

Note: Ana, Ben, the teams and the rooms are made-up examples; every line of code, test and output on screen is from a real run (Python 3.14.3, pytest 9.2.0, SQLite 3.50.4). Pictures marked "illustration" are not real output.
Narration voice generated with Google Gemini text-to-speech.