Build a Table Book for a Small Bistro
A ten-table bistro keeps its bookings in a paper notebook, forgets that a party stays for 90 minutes, and puts two parties on the same table. You will build the booking book that gives each party the smallest table that fits, refuses a booking that clashes and says why, and keeps cancelled and no-show bookings on record.
The brief
The client
I own a bistro in Amsterdam with ten tables and thirty-six seats, and I take every booking myself on the phone, into a paper notebook. I am the host, the person who answers the phone and seats the guests. A party that books for 19:30 sits for about an hour and a half, which I call a sitting, and I forget that when someone rings for 20:30 and the same table looks free on the page.
Last Saturday two parties turned up for table 4, and a party of six was written onto a table for two because it was the only empty line. I do not need an app for guests, only one place where I type a name, a phone number, how many people and when, and it tells me which table they get or why they cannot have one.
The problem
The notebook shows a table as free whenever its line on the page is empty, so a table that is still occupied looks available. Each clash leaves a party turned away at the door or seated late, and the host decides by memory which table fits which party. The host also cannot see at a glance which tables are free at 20:00 when a walk-in appears, a party that arrives with no booking and asks for a table.
A no-show, a party that booked and never arrived, keeps its line in the notebook, so the host cannot tell whether to hold that table or give it away. A cancelled booking is crossed out and forgotten, so a guest who cancels every other week looks the same as a guest who never booked.
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
- Keep a list of the bistro's tables with the number of seats each has.
- Let the host see and change the bistro's day: the opening time, the last time a sitting may start, and the sitting length in minutes. A change shows everywhere at once.
- Take a booking for a guest name, a phone number, a party size, a day and a time, and give the party the smallest free table that fits it.
- Never hold one table for two bookings at overlapping times, and never put a party on a table with too few seats.
- Refuse a booking with a reason the host can read, and save nothing. The reasons are: the party size is not 1 or more, the time has already passed, the time is before opening, the time is after the last seating, no table is big enough, and every big-enough table is held at that time.
- Cancel a booking so its table is free again, and mark a no-show so the host can seat a walk-in at that table. Both stay on record.
- Show one day's bookings in time order with their table and state, and answer which tables are free at a time for a party of a given size.
- Let the person or the request supply the current time for a booking, so the refusal for a time that has passed can be tried without waiting. This exists for testing.
Deliverables
- A running program with your own choice of interface: a web page, an API that other programs call by sending requests, or a command-line tool. It keeps its data when it is closed and started again.
- A README that takes a reviewer from an empty book to a finished Saturday in 10 minutes, with the steps to take a booking, cancel one, mark a no-show and read the day's list.
- A document with the bistro's tables and hours and at least 10 example bookings, each with the table the owner expects or the reason for the refusal.
- A table of at least 8 pairs of times with the expected answer for each, worked out by hand before any program decides overlaps.
- An automated test set, code that drives the book and checks its answers against what you expect, that replays a full Saturday with one command and compares the result with a list worked out by hand beforehand.
Out of scope
- Accounts and logins. The bistro has one book and one host. Do not put this tool on the internet, because anyone who can reach it can read every guest's phone number and cancel any booking.
- A booking page for guests, reminders by text message or email, and guest accounts. The host types every booking, and the rule matters more than the screens.
- Two hosts booking the last free table at the same moment. Your program handles one booking at a time here. The intermediate project, Build a Till and Stockroom for a Tapas Bar, deals with several sellers drawing on the same limited count.
- A waiting list that offers a cancelled table to the next party. It is a second rule on top of the first.
- Deposits, card guarantees and no-show fees. They need a payment provider, and this project holds no money.
- Joining two tables for a large party. It changes the rule from one table to a set of tables.
- Orders, the menu, the kitchen and stock. The book ends when the party is seated.
- Staff rotas, several sites and reports on guests served. Each is a project of its own.
- Different hours per weekday and closed days. One daily schedule keeps the overlap rule visible.
- Checking that a phone number is a real phone number. The host types what the guest says.
Architectural constraints
- Every booking time is Amsterdam clock time (Europe/Amsterdam), and shows the same hour whatever the machine running the program is set to.
- Every duration is a whole number of minutes.
- Two bookings on one table overlap when each starts before the other ends. A booking that starts exactly when another ends does not overlap it.
- Only a booking that is still booked holds a table. Cancelled and no-show bookings stay on record and hold nothing.
- When two tables both fit a party, the one with fewer seats is taken, and if still tied, the lower table number.
- A change to the sitting length, the opening time or the last seating never changes a booking already taken.
- A refusal for a time that has passed can be tried without waiting: the person or the request can supply the current time, for testing.
- Saved data survives closing and restarting the program.
Prerequisites
You can write a small program in a language of your choice and have saved data to a database or a file once. You do not need to know how a booking system works or any particular framework. You do not need to know how a small bistro seats its guests; the first Phase explains the business and the words the brief uses. Having written one automated test helps.
Free to start. An account is what keeps track of the checkpoints you finish.
Describe the bistro and store its tables
Produces a written description of the bistro's evening with example bookings, the ten tables and three settings saved, and bookings saved and read back. Leaves every booking rule for later, so this book still accepts two parties on one table.
Acceptance criteria
You write a document in your repository that describes the bistro. It lists the ten tables with their numbers and seat counts: tables 1 to 4 seat 2, tables 5 to 8 seat 4, and tables 9 and 10 seat 6, which makes 36 seats. It gives the three settings: the bistro opens at 17:00, the last sitting may start at 21:00, and a sitting lasts 90 minutes.
The document holds ten example bookings for Saturday 14 Nov 2026. Each one has a guest name, a phone number, a party size, a start time, and either the table the owner expects or the reason for the refusal. The examples are read in order as one evening, so each answer depends on the bookings before it. Every example also states the current time it assumes.
At least two examples are refusals, and they give different reasons. At least one pair of bookings touches on a table: one sitting ends at 21:00 and the next starts at 21:00 on the same table, and the document says the second booking is allowed. At least one example shows a party of 2 taking a four-seater because all four two-seaters are held. No refusal names a table.
Architectural guidance
Answers written after the program exists tend to copy whatever the program did. If a rule is misread, the wrong answer then looks right, and nobody notices until a real party turns up at a table that is already taken. Work each answer out by hand from the rules in the brief, so the examples show your reading of the rules. These ten examples are also the first cases the later Phases have to agree with.
Acceptance criteria
After the first start the README describes, the program shows the bistro's ten tables, each with a number and a seat count: tables 1 to 4 with 2 seats, tables 5 to 8 with 4 seats, tables 9 and 10 with 6 seats. It also shows three settings: opening time 17:00, last seating 21:00 and sitting length 90 minutes.
After the program is closed and started again, the same ten tables and the same three settings are shown. Starting the program a second time, or following the README's first-start steps again, leaves ten tables, not twenty. A table with fewer than 1 seat is refused with a reason, and nothing is saved.
The README says how the host changes the three settings. Changing the sitting length from 90 to 120 and restarting shows 120 wherever the sitting length appears, with no other change anywhere.
Architectural guidance
A host who closes the program at midnight and finds the tables gone on Monday has lost the book. If the tables load again on every start, the host ends up with twenty tables and bookings land on seats that do not exist. A sitting length that is typed in several places gets changed in some of them, and the book then contradicts itself: the list says a table is free and the booking says it is not.
Acceptance criteria
A person or a request can save a booking with a guest name, a phone number, a party size, a day, a start time and a table number that they name by hand. The day and time are entered as Amsterdam clock time. Saving Ana, 3 people, Saturday 14 Nov 2026 at 19:30, on table 5 and then closing and restarting the program, asking for that day shows one booking with the guest, phone number, party size 3, table 5, start 19:30, end 21:00 and state booked.
Running the program with the machine's time zone set to America/New_York still shows start 19:30 and end 21:00. After the sitting length is changed to 120, a new booking for 19:30 on table 6 shows end 21:30, and Ana's booking still shows end 21:00.
A booking that names a table number that is not one of the ten is refused with a reason, and nothing is saved. No other rule is checked yet: a second booking on table 5 at 19:30 is also saved. The README lists this as a known gap that a later Phase closes.
Architectural guidance
A start time with no zone is read on whatever machine runs the program, so the same booking shows a different hour on a server in another country and the host seats a party an hour early or late. A misspelt state such as "cancled" would leave a booking that is neither held nor cancelled, and the host would not know which.
Architectural walkthrough
How a small bistro seats its guests
A bistro in Amsterdam has ten tables and thirty-six seats. The owner is also the host, the person who answers the phone and seats the guests. Guests book by phone with a name, a phone number, how many people are coming and a time, and the host writes it in a notebook.
A party that books for 19:30 occupies its table for about an hour and a half, which the host calls a sitting. A table that looks free at 20:30 may be occupied by the earlier party until then. The host picks a table that fits the party. Some guests arrive with no booking, and some who booked never arrive.
The words this brief uses:
Host: the person who takes bookings and seats the guests.
Party: the group of guests under one booking, with a size.
Sitting: how long a party holds its table, about an hour and a half.
Last seating: the latest time a sitting may start.
Walk-in: a party that arrives with no booking and asks for a table.
No-show: a party that booked and never arrived.
Table: a place with a fixed number of seats.
Why the first decisions are cheap to change
This Phase has almost no rules. You decide what the program knows about the bistro and what a saved booking holds. Both decisions are cheap to change today and awkward once the rules lean on them.
The failure this Phase must survive is a change of mind by the owner. Suppose the owner changes the sitting from 90 minutes to 120. Every booking already in the book now ends half an hour later than the guest was promised, and two parties who were safely apart on Tuesday overlap on Wednesday without anyone having booked anything. A booking has to keep the end time it was given when it was taken.
You also write down ten example bookings with the answers you expect, before any rule exists. The Phase ends with a book that saves a clash on purpose, and you note that gap in the README. A later Phase closes it, and the examples you wrote here are the first thing it has to agree with.
Take bookings by the rule
Produces bookings that are accepted onto the smallest free table that fits, or refused with a reason. Leaves cancelling, no-shows and the day's list for later.
Acceptance criteria
You write a document in your repository that holds a table of at least 8 pairs of bookings on the same table. Each row gives both start times, the sitting length, both end times, and the expected answer: overlap or no overlap. The expected answers are worked out by hand and written before any program decides overlaps.
With a 90-minute sitting the table includes these rows: 19:30 and 21:00 on the same day do not overlap, because the first ends exactly when the second starts. 19:30 and 20:59 overlap. 19:30 and 19:30 overlap. 18:01 and 19:30 overlap by one minute, and 18:00 and 19:30 do not overlap. 21:00 on Saturday and 21:00 on Sunday do not overlap. With a 120-minute sitting, 19:30 and 21:00 overlap.
The document states the rule in one sentence in your own words, and every row agrees with that sentence.
Architectural guidance
A host who compares only start times accepts 20:30 on a table held from 19:30 to 21:00, and two parties stand at one table. A host who only checks whether the new start falls inside the old sitting accepts 18:30 against 19:30, and the two sittings still collide at 19:30. A sitting that ends at 21:00 leaves the table free for a sitting that starts at 21:00, and a book that gets this wrong turns a party away on the night the bistro is full. The table you write here is the proof that the rule handles all three.
Acceptance criteria
A person or a request can ask which tables are free on a given day at a given time for a given party size, and gets a list of table numbers back. Asking changes nothing in the saved data.
Start from an empty book with the 90-minute sitting. Save a booking on table 5 for Saturday 14 Nov 2026 at 19:30 and a booking on table 9 at 21:00, both saved the Phase 1 way, with a table number you name by hand. Asking for 20:00 and 3 people returns tables 6, 7, 8 and 10, in that order. Table 5 is missing because its sitting runs 19:30 to 21:00, and table 9 is missing because its sitting starts at 21:00, before the new sitting would end at 21:30. Tables 1 to 4 are missing because they have only 2 seats.
Asking for 21:00 and 3 people returns tables 5, 6, 7, 8 and 10, because table 5 frees at 21:00. Asking for 20:00 and 6 people returns table 10 only. Asking for 7 people returns an empty list and not an error. The list is ordered by seats, fewest first, and then by table number.
Architectural guidance
The list must also come back in the same order every time, or two runs give two answers and an expected answer can no longer be written down. Asking which tables are free is a question and must not use up a table.
Acceptance criteria
A person or a request can now save a booking without naming a table. From an empty book, a booking for Ana, 2 people, Saturday 14 Nov 2026 at 19:30 gets table 1 and the saved booking records table 1, start 19:30, end 21:00 and state booked. Three more parties of 2 at 19:30 get tables 2, 3 and 4 in that order. A fifth party of 2 at 19:30 gets table 5, a four-seater, and not table 9.
A party of 5 at 19:30 gets table 9, and a party of 6 at 19:30 gets table 10. A party of 2 booked for 21:00 gets table 1, because the 19:30 sitting on table 1 ended at 21:00. From an empty book, four parties of 4 at 19:30 take tables 5 to 8, and a fifth party of 4 at 19:30 gets table 9.
A party that fits no free table is not saved at all. The reason it gets arrives in the next Checkpoint. Running the same sequence on an empty book twice gives the same tables both times.
Architectural guidance
A book that gives a party of 2 a six-seater leaves the party of six who rings later with nothing, and the host turns away a booking the bistro could have taken. If two runs of the same bookings give two different tables, the host cannot predict where a party sits and the examples cannot be checked. A booking that finds no table must leave the book as it was, so a refused party never holds a seat.
Acceptance criteria
A booking can carry the current time, supplied by the person or the request, for testing. The real clock is used when none is supplied. Every case below uses the current time Saturday 14 Nov 2026 at 18:00 and the 90-minute sitting, and starts from an empty book unless it says otherwise.
Each refusal returns a reason in words the host can read, and nothing is saved. The six reasons differ from each other. A party of 2 for Saturday 17:30 is refused because the time has passed. A party of 2 for Sunday 15 Nov 2026 at 16:59 is refused as before opening. A party of 2 for Sunday at 21:01 is refused as after the last seating. A party of 7 for Sunday at 19:30 is refused because no table is big enough. After two parties of 6 are booked for Sunday at 19:30, a third party of 6 for Sunday at 20:00 is refused because every big-enough table is held, while a party of 2 for Sunday at 20:00 is accepted. A party of 0 is refused with a reason about the party size.
The edges are accepted: Sunday 17:00, Sunday 21:00, and Saturday 18:00, which equals the current time. When more than one reason applies, the first in this order is given: party size, time passed, before opening, after last seating, no table big enough, every big-enough table held. So a party of 7 for Sunday at 16:00 gets the before-opening reason. After each refusal, the day's bookings are exactly what they were before it.
Architectural guidance
A bare "error" sends the host back to the phone to guess what went wrong. A booking for a time that has already passed looks fine to a program that never looks at the time, and the host seats a party in the past. A refusal that depends on the real clock gives a different answer every minute, so it cannot be tried without waiting for the right minute, and a test that passes today fails when the date moves on. When two reasons apply to one booking, the host should always hear the same one.
Acceptance criteria
A person runs one command from the README and gets each case below reported by name as passed or failed. The overlap table written in this Phase's first Checkpoint is run through the book, and every row gives the answer written beside it. With the 90-minute sitting and the current time Saturday 14 Nov 2026 at 18:00, from an empty book, four parties of 2 at 19:30 get tables 1 to 4 in that order, a fifth gets table 5, and a party of 2 at 21:00 gets table 1. A party of 2 for Saturday 17:30 is refused as passed, one for Sunday 16:59 is refused as before opening, one for Sunday 21:01 is refused as after the last seating, and a party of 7 is refused as no table is big enough. Saturday 18:00, equal to the current time, is accepted. After each refusal the day's bookings read exactly as before. Running the whole sequence on an empty book twice gives the same tables. Changing one expected answer makes the run report that case as failed.
Architectural guidance
A rule that handles the middle of the evening and fails at its edges looks fine until a full Saturday, when it turns a party away or seats two on one table. Expected answers copied from the program's output cannot catch either, so they come from the table worked out by hand.
Architectural walkthrough
This Phase turns the saved bookings of Phase 1 into a book that decides. The failure it must survive is a book that disagrees with itself: the list of free tables shows table 6, the booking is then refused for table 6, and nobody can say which one is wrong. The host sees both answers and trusts neither.
The first Checkpoint is a table of time pairs with answers you work out by hand. You write them before any program decides, so the table cannot copy a mistake from the program. The pairs include the awkward ones: back to back, one minute of overlap, and the same start. A rule that handles the middle of the evening and fails at its edges looks fine until a full Saturday.
The clock causes a second failure: the refusal for a time that has already passed depends on what time it is now.
From here on, any example that involves the refusal for a passed time sets its own current time. The real date moves on after you write this, and an example that depends on today stops being true.
Run the evening
Produces cancelling, no-shows, the day's list and a replay of a full Saturday that proves the whole book. Leaves guests, money and several hosts out.
Acceptance criteria
A person or a request can cancel a booking by identifying it. Every case below uses the current time Saturday 14 Nov 2026 at 10:00 and the 90-minute sitting. Start from an empty book and book Ana, 2 people, at 19:30 first, then nine more parties at 19:30: three more parties of 2, four parties of 4 and two parties of 6. Ana gets table 1 and all ten tables are held.
A party of 2 booked for 20:00 is refused because every big-enough table is held. After Ana's booking is cancelled, a party of 2 booked for 20:00 gets table 1, Ana's old table. The day's list for Saturday shows 11 entries in time order, with entries that start at the same time ordered by table number. Ana's entry is still there and shows the state cancelled. The new party shows the state booked.
Cancelling a booking that is already cancelled is refused with a reason, and its state does not change. Cancelling a booking that does not exist is refused with a reason.
Architectural guidance
A table that stays held after its booking is cancelled turns away a party the bistro could have seated. Erasing the booking frees the table too, but it also erases the fact that the guest ever booked, and the host can no longer tell a guest who cancels every other week from one who never booked. The evening in the criteria fills every table on purpose, so only the cancelled booking's table can answer the new party.
Acceptance criteria
A person or a request can mark a booking as a no-show by identifying it, at any time while the booking is in the booked state. Every case below uses the 90-minute sitting. Start from an empty book and book Ana, 2 people, at 19:30 on Saturday 14 Nov 2026, which gets table 1, and then three more parties of 2 at 19:30, which get tables 2, 3 and 4.
With the current time set to Saturday 19:45, asking which tables are free now for 2 people returns tables 5, 6, 7, 8, 9 and 10, in that order. After Ana's booking is marked as a no-show, the same question returns tables 1, 5, 6, 7, 8, 9 and 10. A walk-in party of 2 booked for 19:45 gets table 1. A walk-in is a party that arrives with no booking.
Ana's entry stays in the day's list with the state no-show. Marking a booking as a no-show works with the current time set to 19:00, before the party was due. Marking a booking that is cancelled, or already a no-show, is refused with a reason, and its state does not change.
Architectural guidance
A no-show that keeps its table held leaves a table empty while a walk-in stands at the door. A booking that can be cancelled and then marked as a no-show shows up twice in the host's counts, once as each. The host decides when a party is not coming, so the table must free the moment the host says so, whether or not the sitting has begun. The no-show stays on record, because a guest who books and never comes is something the host will want to look up.
Acceptance criteria
One command in the README runs an automated replay of a whole Saturday and prints how many checks passed and how many failed. The replay starts from an empty book with the ten tables and the 90-minute sitting, plays at least 20 bookings, 3 cancellations and 2 no-shows, and ends by comparing the day's list with an expected list kept in a separate file in your repository. The expected list was worked out by hand before the first run.
The replay includes at least one booking refused for each of five reasons: the time has passed, before opening, after the last seating, no table big enough, and every big-enough table held. It also includes one booking that starts at the moment another ends on the same table, and the expected list shows both accepted.
The replay sets its own current time on Saturday 14 Nov 2026, so running it twice gives the same result, and running it on another day does too. It leaves the bistro's real saved data untouched. Changing one line of the expected list on purpose makes the run fail and print which line differs.
Architectural guidance
A single example hides mistakes that a whole evening finds: a cancel that left a table held, or a booking at 21:00 refused after a sitting ended at 21:00. A check that has never failed proves nothing, so change one expected line and watch the run catch it. A replay that depends on today's date passes this week and fails next week, and a replay that writes into the bistro's real book spoils the real bookings.
Architectural walkthrough
The book now takes bookings. This Phase handles what happens to a booking after it is made. The failure it must survive is a table that stays held when it should be free, and the opposite: a guest's history that disappears when the table frees.
The last Checkpoint replays a whole Saturday against a current time you set, so the result is the same on every run and any later change that breaks a rule shows up as a line that differs.
Architectural walkthrough
The book answers for every booking before it
Whether table 5 is free at 20:30 depends on every booking already made for that night, on how long each one sits, on how many people each party has, and on whether any of them was cancelled. A book that only records what the host typed knows none of that. This project turns on one rule: a booking holds its table for a whole sitting, no table is held by two bookings at overlapping times, and a party is never put on a table with too few seats.
A booking at a different minute can still clash
Take Ana, booked on table 5 for 19:30. Her sitting runs until 21:00. A second party rings for 20:30 and asks for table 5. The two start times differ, and if the book accepts it, two parties stand at one table. That is the notebook's bug.
A party who asks for table 5 at 18:30 is a different case. Their start is before Ana's, yet their sitting runs until 20:00 and collides with hers. A book that looks only at start times gets the first case wrong. A book that only asks whether the new start lands inside an existing sitting gets the second case wrong.
The end of a sitting leaves the table free
Ana's sitting ends at 21:00, so a party booked at 21:00 on the same table is the normal case, not a clash. A book that treats 21:00 as still taken turns that party away, and the bistro loses a table on the night it is full.
The same evening on any machine
A start of 19:30 means nothing until it says where. If the book follows the clock of the machine running it, a host on a server in another country sees a different hour, and a party is told to arrive an hour early or late. Phase 1 saves bookings so that 19:30 reads as 19:30 in Amsterdam from the first booking on.
A promise made stays made
The owner decides that a sitting is 120 minutes and not 90. Every booking already in the book must keep the end time its guest was promised. If they all end half an hour later, two parties who were safely apart on Tuesday overlap on Wednesday, and nobody booked anything in between.
The smallest table that fits
A book that gives the first free table it finds gives a party of 2 a six-seater, and the party of six who rings later finds none. The host then turns away a booking the bistro could have taken. The same bookings must also give the same tables on every run, which is what lets you write one expected answer per example.
Cancelled stays on record
Erasing a cancelled booking frees the table, and it also erases that the guest ever booked. The host can then no longer tell a guest who cancels every other week from one who never booked. A cancelled or no-show booking frees its table and stays in the day's list, with its state in plain words.
Where it shows if you cut a corner
A 20:30 booking accepted on a table held until 21:00 means the book ignores how long a sitting lasts. A party of 2 on a six-seater while a two-seater is free means the book takes whatever table it finds first. A 21:00 booking refused after a 19:30 one ended at 21:00 means the book counts the end of a sitting as taken. A table that never frees after a cancel means the book still counts the cancelled booking. The Saturday replay in the last Checkpoint exposes all four, because its final list was worked out by hand before the program ran.