Build a Box Office for a Village Hall Show
A village hall theatre group takes bookings in a shared spreadsheet and once sold 97 seats for a 90 seat show. You will build the small box office that counts seats, refuses a booking that does not fit, and checks each ticket once at the door, in the language and shape you choose.
The brief
The client
I run a community theatre group in a village hall that seats 90. We put on three performances of one play each season, and I take the bookings myself. Everyone books by email or phone, and I type them into a shared spreadsheet, then add up a column by hand to know how many seats are left.
For our last Saturday show I added wrong and sold 97 seats. I rang seven families the day before to tell them there was no room for them. On the night, a man showed us a printed ticket that his neighbour had already used, and we had no way to tell which of them was the real one. I want something small that two volunteers and I can run from one laptop.
The problem
The group tracks bookings in a spreadsheet and works out the seats left by adding a column by hand, so one slip sells seats that do not exist. A ticket is a name on a row, so a copied or forwarded ticket cannot be told from the original at the door.
Each oversold family costs the group an apology call and a regular who may not come back. The hall has 90 seats per show, so every wrong sale shows up on the night as a person with nowhere to sit.
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
- Add a performance with a title, a start time, a number of seats and a ticket price.
- List the upcoming performances with the start shown in the hall's local time and the number of seats left for each.
- Take a booking for a name, an email and a number of tickets (1 to 6) against one performance, and give back a booking reference, the total price and one unique ticket code per ticket.
- Refuse a booking that asks for more tickets than there are seats left, and refuse one for a performance that has already started. A refused booking saves nothing.
- Cancel a booking so that its tickets stop being valid and its seats count as free again.
- Look up a ticket by its code at the door, admit it once, and refuse a second use of the same code with a message that says when it was first used.
- Produce a door list for one performance: who booked, how many tickets each, and how many of those have been admitted so far.
- Keep performances, bookings and admissions when the program is closed and started again.
- Let the person or the request supply the current time, so that closing and edge cases can be tested without waiting for the real clock.
- Give every refusal as a message a volunteer could read aloud to the person standing in front of them.
Deliverables
- A program in the language and shape of your choice (a web page, an API that other programs call by sending requests, or a command-line tool) that keeps performances, bookings and tickets between runs.
- A document of the booking rules in plain sentences, written before the program.
- A set of automated tests, code that drives the program and checks its answers against figures you expect, that runs with one command, with the command written in the README.
- A README that takes a reviewer from a fresh copy of your project to the full evening output in 10 minutes. It also says how to supply the current time and how to make a booking stop partway for testing.
- The output of a scripted evening on a 10 seat performance, saved in the README next to the numbers worked out by hand.
Out of scope
- Taking payment. The client collects money by bank transfer and cash today, so a booking shows what is owed and nothing records whether it was paid.
- Two people booking the last seats at the same moment. This box office has one person typing at a time. Simultaneous buyers belong to the next project up, Build a Ticket Shop for a Small Music Venue.
- Holding seats while someone decides. A booking is made or it is not.
- Several groups, halls or organisers. One group and one hall keep the data small.
- Numbered seats and seat maps. Seats here are a count, which is all the client needs.
- Logins and accounts, for volunteers or for people who book. Anyone who can reach the tool can use every part of it, including cancelling a booking they only know the reference of, so do not put it on the internet.
- Sending email. Show the ticket codes on screen or in the output. Email delivery is its own job.
- Selling, transferring or reselling tickets between people, and refunds. Money handling stays out of this project.
- Searching the door list by name for a guest who lost their code. The client will print the list instead.
Architectural constraints
- Seats left always equals the seats of the performance minus the tickets of bookings that are still active, after every booking, cancellation and admission.
- A booking and all of its tickets exist together or not at all, even if the program stops in the middle of making them.
- Amounts are exact to the cent: a price of 12.50 is 1250 cents, and a total is never off by a fraction.
- A start of 19:30 means 19:30 in the hall's time zone (Europe/Amsterdam) wherever the program runs, and booking closes at that moment.
- Ticket codes are unique, at least 8 characters long, and cannot be guessed from other codes.
- Anything that depends on the current time uses the time the person or the request supplies when there is one, and the real clock otherwise. The option exists for testing.
Prerequisites
You can write a small program in a language of your choice and you have saved data to a database or a file once. You do not need to know a web framework, how automated tests work, or anything about queues or events. You do not need to know how a village hall theatre group sells its seats; the first Phase explains the business and the words the brief uses. The walkthroughs explain what goes wrong for the client and leave the way to build it to you.
Free to start. An account is what keeps track of the checkpoints you finish.
Know the show
Produces a written list of the booking rules and a small program that keeps performances and lists the upcoming ones with their seats left. No bookings are taken yet.
Acceptance criteria
A document in your project (a text or markdown file is fine) lists at least 8 booking rules, one sentence each. It covers: the fewest and most tickets one booking may ask for (1 and 6); what happens when 0 seats are left; when booking closes (at the moment the performance starts, so a booking asked for at that exact moment is refused); what cancelling does to the seats; what happens when someone tries to cancel after the performance has started (refused); what happens when someone tries to cancel a booking that has at least one ticket already admitted at the door (refused); and what the door does with a code that was already used.
You also work two examples by hand and show the numbers in the document. First, a 90 seat performance with 86 tickets booked: a booking of 5 is refused and a booking of 4 is accepted and leaves 0 seats. Second, a 10 seat performance with these steps in order: bookings of 4, 3, 3 and 1, then the cancellation of the second booking, then a booking of 2. The seats left after each step are 6, 3, 0, 0 (the booking of 1 is refused), 3 and 1.
The document ends with two or three sentences in your own words naming the rule you think is easiest to get wrong, and why.
Architectural guidance
Numbers worked out by hand give you answers to check the program against, and a program checked only against its own output agrees with itself whether or not it is right.
Acceptance criteria
A person or request can add a performance by giving a title, a start as a local date and time in the hall's zone (Europe/Amsterdam), a number of seats and a price in whole cents. Adding "Saturday show", 14 Nov 2026 at 19:30, 90 seats and 1200 cents works. Asking for the upcoming performances then shows it with the start written as 19:30 on that Saturday, 90 seats, a price of 1200 cents and 90 seats left. When several performances exist, the soonest comes first.
Running the program again on a computer set to a different time zone, for example Asia/Tokyo, still shows 19:30. Closing the program and starting it again still shows the Saturday show.
The listing accepts a current time supplied by the person or the request, and uses the real clock when none is given. This option exists for testing, so a performance can be in the past without waiting. With the current time set to 14 Nov 2026 at 19:29 Europe/Amsterdam the Saturday show is listed. At 19:30 or later it is not.
These are refused with a message that names the problem, and nothing is saved: an empty title, 0 seats, 90.5 seats, a price of -100, a price of 12.50 (the message says the price is in whole cents), and a start that is not a real date, such as 31 Nov 2026.
Architectural guidance
A seat count that is wrong by one sells a seat that does not exist, and nothing says so until a person has nowhere to sit.
Architectural walkthrough
How a village hall theatre group sells its seats
A community theatre group puts on one play a season in a village hall that seats 90, three performances of it. The organiser takes the bookings. Families, friends and regulars ask by email or phone for a number of tickets to one night, and each booking is a name, an email and a count. Seats are not numbered. The group collects the money itself, by bank transfer and cash.
On the night, two volunteers and the organiser work the door from one laptop. Guests arrive with a printed ticket, and a volunteer has to decide on the spot whether that ticket has a right to a seat. Booking for a night stops when its show starts, and 19:30 means 19:30 in the hall's own time zone.
The words this brief uses:
Performance: one showing of the play, with a start time, a number of seats and a ticket price.
Booking: one request for 1 to 6 tickets to one performance, made under a name and an email.
Booking reference: the reference a booking is given when it is made.
Ticket code: the code printed on one ticket. It is what the door checks.
Seats left: the seats of a performance that no active booking holds.
Admit: let a ticket holder in at the door. A ticket can be admitted once.
Door list: the printed list of who booked for one performance and how many have come in.
Why the rules come first
The client's failures came from rules nobody had said aloud. Does a cancelled booking give its seats back? Can a booking be made at the minute the show starts? What does the door do with a copied ticket? Each unanswered question is a place where the program will do something sensible that the client never wanted, and the volunteers find out on the night.
A performance also has to mean the same thing wherever the program runs. A start of 19:30 with no place attached is a different moment on a server in another country, and booking would close at the wrong hour for the hall. Prices carry the same trap: a total that is one cent off is a bug the client sees on the first bank transfer.
The listing shows seats left from the start, so a wrong count shows as soon as the first booking arrives in the next Phase. The check here is that an empty hall reads 90.
Take bookings
Produces bookings that give one ticket code per ticket, a refusal for a booking that does not fit, cancellation that gives seats back, and a test set that pins the edge cases. Leaves the door for the next Phase.
Acceptance criteria
Booking 3 tickets for the Saturday show (90 seats, 1200 cents) for "Ana Pop" with the email ana@example.com gives back a booking reference, a total of 3600 cents, and 3 ticket codes. The codes differ from each other and each is at least 8 characters long. The listing then shows 87 seats left, and still shows 87 after the program is closed and started again, with the booking and its codes still there.
A booking is refused with a message that names the problem, and nothing is saved, for each of these: 0 tickets, 7 tickets, 2.5 tickets, an empty name, an email with no @ in it (such as ana.example.com), and a performance that does not exist. Seats left stays at 90 after each refusal.
The codes cannot be guessed from one another. On a test performance with 2000 seats, make 300 bookings of 6 tickets each. The 1800 codes contain no repeats, and listed in the order they were made they do not come out in ascending order or differ by one.
A booking and its tickets exist together or not at all. Stopping the program in the middle of a booking, by the means your README describes, leaves no booking and no ticket, and the seats left is unchanged.
Architectural guidance
A code that follows a pattern can be guessed by anyone holding code 41, who then walks in on someone else's ticket, and a code that repeats another puts two families on one ticket.
Acceptance criteria
With 3 seats left, a booking of 4 is refused with a message that says only 3 seats are left. Afterwards seats left is still 3, and no booking and no ticket exist for that attempt. A booking of exactly 3 is accepted and leaves 0. With 0 left, a booking of 1 is refused with a message that says the performance is sold out, and seats left stays 0.
A booking for a performance that has started is refused with a message that says booking has closed. The person or request supplies the current time for these checks, as in the earlier Checkpoints. At the exact moment of the start a booking is refused, and one minute earlier it is accepted.
The four reasons for a refusal (bad input, not enough seats, sold out, closed) each have their own message. Every refusal leaves the data as it was.
Architectural guidance
The message matters: "only 3 seats are left" lets the volunteer offer a smaller booking, and a bare "no" does not. This check holds because one person books at a time, which is why simultaneous buyers are a non-goal.
Acceptance criteria
With 10 tickets booked on the Saturday show (80 seats left), cancelling a booking of 4 tickets by its reference raises seats left to 84. Looking up the booking by its reference shows it as cancelled.
Cancelling the same booking a second time changes nothing. The answer says it is already cancelled, and seats left is still 84, not 88.
Cancelling is refused with a message, and seats left does not change, for a booking reference that does not exist and for a booking on a performance that has already started. The person or request supplies the current time for the second check.
After the cancellation of the 4 ticket booking, a new booking of exactly 4 tickets is accepted and seats left goes back to 80.
Architectural guidance
A volunteer who clicks twice, or a family who ring a second time, can hand back 8 seats for a booking of 4. The hall is then oversold again, which is the client's original failure with a different cause.
Acceptance criteria
A set of automated tests runs with one command, and the README names the command. Each test starts from empty data of its own, so no test depends on another and none touches your real bookings. Each test sets the current time itself and never reads the real clock.
On a 10 seat performance the tests cover these cases, each with the expected seats left written in the test: a booking of 6 that is accepted and leaves 4; then a booking of 5 that is refused and leaves 4; then a booking of exactly 4 that is accepted and leaves 0; a booking of 0 tickets refused; a booking of 7 tickets refused; a booking of 4 cancelled and then rebooked into the freed seats; a cancellation made twice that frees the seats once; a booking one minute before the start accepted; and a booking at the exact start moment refused.
To show the tests can fail, temporarily change the capacity check so that it lets one extra seat through. At least one test fails. Paste the failing output into the README, restore the check, and run the tests again to show they all pass.
Architectural guidance
A test that reads the real clock cannot check the minute the show starts, and a test that depends on another test's leftovers passes or fails by order.
Architectural walkthrough
A booking is made while a family waits on the phone. If the program stops partway, the family holds a booking for three seats and two codes, and the volunteers find out at the door. If it saves first and checks afterwards, a booking that never fit exists and someone has to remember to undo it. A request for 4 seats with 3 left gets a no and a count that is still 3, and no explanation about the 3 tickets that were nearly saved.
Cancelling carries its own trap: a second cancellation of the same booking must not give its seats back again.
The Phase ends with tests because the rules break quietly at the edges: exactly full, one over, zero, and the minute the show starts. A test that cannot fail protects nothing, so you break the capacity check on purpose and watch a test fail.
Open the doors
Produces a door check that admits each ticket once, a door list for one performance, and a scripted evening that proves the whole box office against numbers worked out beforehand. Leaves email, payment and logins out.
Acceptance criteria
Giving the door a ticket code from an active booking admits it. The answer says it was admitted and shows the time, in the hall's zone. The person or request can supply the current time for this, which exists for testing.
Giving the same code a second time is refused with a message that includes the time of the first use, for example "already used at 19:12". Looking the code up afterwards still shows the first time. After the program is closed and started again, the ticket is still shown as used.
An unknown code is refused with its own message. A code from a cancelled booking is refused with a different message that says the booking was cancelled. Neither refusal changes anything.
Looking up a code without admitting it shows its state in one of three words: unused, used (with the time) or void. A code from a cancelled booking reads void.
Cancelling a booking that has at least one admitted ticket is refused with a message, and seats left does not change. Cancelling a booking whose tickets are all unused still works.
Architectural guidance
Two people carrying one printed ticket is the failure that started this project. If the second attempt replaces the time of the first, the volunteer loses the only fact that tells the neighbour from the owner. A code from a cancelled booking that still works at the door lets a family who cancelled walk onto a seat that was rebooked. A seat someone has sat in is not free, so cancelling that booking would oversell the hall.
Acceptance criteria
For a performance with three active bookings, Ana with 2 tickets, Ben with 4 and Cleo with 1, the door list has 3 rows sorted by name without regard to case. Each row shows the name, the number of tickets and the number admitted so far, which is 0 for every row at first. Below the rows it shows a total of 7 tickets and 0 admitted.
After 2 of Ben's tickets are admitted at the door, the list shows Ben with 4 tickets and 2 admitted, and the totals read 7 and 2. Nothing else was done to update it.
A fourth booking that was cancelled does not appear in the rows and is not in the totals. A performance with no bookings gives an empty list with totals of 0 and 0. A performance that does not exist is refused with a message.
Architectural guidance
Cancelled bookings among the rows have volunteers waiting for people who are not coming. A list sorted so that "ana" and "Ana" sit apart makes a volunteer look in two places for one guest.
Acceptance criteria
A script (or a test) starts from empty data, adds a 10 seat performance at 1200 cents starting 19:30 on 14 Nov 2026 in the hall's zone, and plays this evening. The bookings and the cancellation use the supplied current time 18:00 that day. The door steps use 19:10.
Book 4 tickets for Ana: accepted, total 4800, 6 seats left. Book 3 for Ben: accepted, total 3600, 3 left. Book 3 for Cleo: accepted, total 3600, 0 left. Book 1 for Dan: refused as sold out, 0 left. Cancel Ben's booking: 3 left. Book 2 for Eve: accepted, total 2400, 1 left. At the door, admit 4 of Ana's codes and 1 of Cleo's: 5 admitted. Retry one of Ana's codes: refused, with the time of its first use. Try one of Ben's codes: refused as cancelled. Try to cancel Ana's booking, still at 19:10: refused. Print the door list: Ana 4 tickets and 4 admitted, Cleo 3 and 1, Eve 2 and 0, with totals of 9 tickets and 5 admitted, and no row for Ben or Dan.
The output of the run is saved in the README next to these numbers, which you worked out by hand before running it, and they match line by line. Running the script a second time from empty data gives the same output. The README also takes a reviewer from a fresh copy of your project to this output in 10 minutes.
Architectural guidance
A run that gives different numbers the second time cannot be trusted by a reviewer.
Architectural walkthrough
The failure here is the client's printed ticket that two people carried to the door, where the volunteers could not tell the owner from the neighbour.
The door list is what volunteers trust when a queue forms. A total that has not caught up with an admission or a cancellation sends them back to counting heads, which is the spreadsheet again.
The Phase ends with a full evening on a 10 seat performance. Each part can pass its own tests while two parts disagree on a number, for example when a cancellation frees a seat that the door list still counts.
Architectural walkthrough
The client's two bad moments
Seven families were told the day before a show that there was no room for them, because a column added up by hand said fewer seats were sold than the 97 that were. On the night, two people held the same printed ticket and the volunteers could not say which of them had a right to the seat. Each costs the group an apology and a regular who may not come back. The box office has to make both impossible, and rare is not enough.
A seat count that is wrong by one
A count that is off by one sells a seat that does not exist, and nothing says so until a person with a ticket has nowhere to sit. The count goes wrong at the moments nobody watches: a cancellation, a booking that fails partway, a fix typed in by hand during a rush. The client's spreadsheet worked until the first slip, and a program that lets its seat count and its bookings disagree is the same spreadsheet with a screen.
A booking that is half there
A booking that does not fit must leave nothing behind. With 3 seats left and a family asking for 4, the answer the client can explain on the phone is a no and a count that is still 3. A program that stops partway through a booking leaves a family with a booking for three seats and two codes, and they find out at the door.
Tickets at the door
A ticket code that follows a pattern can be guessed by anyone holding code 41. A code accepted twice puts two people on one seat. The volunteer needs the time of the first admission to tell the neighbour from the owner, and a second attempt that replaces that time destroys the only evidence there is.
Time and money
A start of 19:30 is a different moment in each country. If booking closes at the wrong hour because the program runs on a computer in another zone, families are turned away early or let in after the curtain. A total that is one cent off is something the client notices on the first bank transfer. The current time also has to be settable from outside, because the minute the show starts cannot be tested by waiting for it. Once this box office works, the next problem up is two buyers going for the last seat at the same moment, which is the subject of Build a Ticket Shop for a Small Music Venue.
Where it shows if you cut a corner
Four symptoms show a cut corner. A seats-left figure that differs from the seats of the show minus the tickets of active bookings after a cancellation means the count is kept apart from the bookings. A refused booking that changes the count, or a stopped booking that leaves a family with fewer codes than tickets, means a booking is saved in pieces. A code admitted twice, or a second attempt that replaces the time of the first, means the door keeps no record of the one fact the volunteer needs. Booking that closes early or stays open after the curtain on a computer set to another time zone means the start was read on the wrong clock.