Case study · tickets.eu-co.co.uk
EUCO Tickets.
A box office for a student orchestra: online sales, signed QR tickets, and a door app that keeps working when the venue's Wi-Fi doesn't.
This is about tickets.eu-co.co.uk only: the ticketing site, its backend and the door app. It is a separate site from the orchestra's main website (www.eu-co.co.uk), which is written up on its own page.
- Role
- Designer, developer and the person who runs it on the night
- Built with
- FastAPI · PostgreSQL · Astro · Directus · Stripe
01 · The problem
Cash, a paper list, and no way to sell ahead
EUCO sold tickets the way most student societies do: on the door, for cash, off a list on a clipboard. It worked until audiences grew.
Before
- No advance sales, so the committee couldn't know a concert's size until people turned up
- No live capacity, so a sell-out was discovered at the door
- Check-in meant a paper list, a pen and a queue
- Every figure afterwards was reconciled by hand
After
- Tickets on sale online the moment a concert is published in the CMS
- Capacity enforced by the server, with a short hold while someone pays
- A phone scans each QR code and checks it against the live list
- Every sale and every entry is a row in one database
02 · The system
Six moving parts, one source of truth
Select a part to see what it owns. The rule that shaped everything: committee members edit content in Directus, but money and attendance live in Postgres and nowhere else.
Backend API
Owns: Pricing, capacity holds, orders, tickets, scans, exports
The only code that decides what something costs, whether seats remain, and whether a ticket is valid. 8 migrations, a test suite around the money rules.
03 · Life of a ticket
From basket to the door, in five steps
Step through one order and watch the rows change. The design goal was that every step can fail, retry or arrive twice without issuing a ticket nobody paid for.
Choose tickets
The browser sends ticket types and quantities, not prices. The backend reads the concert from the CMS, checks seats left, prices every line in pence, adds the booking fee and creates a pending order with a short hold on those seats.
- status
- pending
- total_amount_pence
- 2100
- booking_fee_pence
- 100
- hold_expires_at
- +31 min
Asking for more seats than remain is a 409, and the rate limiter caps order attempts per minute.
04 · Try to forge a ticket
Why a screenshot of someone else's QR code isn't enough
This runs the same signing scheme as the real system, with a demo secret, entirely in your browser. Break the signature and watch the check fail.
…This is the genuine signature the server issued.
Attack it
Scanner verdict
How it works. The QR value is the ticket id followed by an HMAC-SHA256 of it. Without the secret, which lives only on the server, nobody can produce a matching pair, and changing even one bit of either half breaks the check.
What it doesn't do. A valid signature only proves a ticket was issued. Whether it has already been used or refunded is state, so the server still looks at the ticket row (under a lock) on every scan.
The secret in this demo is public and fake. It runs the same maths as backend/app/qr.py via the browser's Web Crypto.
05 · The door
Scanning when the venue Wi-Fi is not your friend
Concert halls are stone buildings full of people on one cellular mast. The door app asks the server first and falls back to a downloaded list. Two doors, two Wi-Fi switches, six tickets: try to get someone in twice.
1 · Hold a ticket up to the camera
2 · The door phone
3 · The server's record
- Alex M.not arrived
- Sam P.not arrived
- Jo B.in 18:52 · Door 1
- T. Leenot arrived
Event log
Nothing yet. Try this: switch both doors offline, scan Alex M. on Door 1 and again on Door 2, then reconnect them one after the other.
Two phones that are both offline can't know about each other, so both admit the same ticket. When they reconnect the server settles it: the first scan to arrive is recorded and the other is flagged for a human, not silently dropped. That is the honest trade for never turning a queue away at the door.
06 · Pricing rules
Money in whole pennies, decided on the server
The browser only displays a price; the server recomputes it from the CMS every time. These are the real rules, with example ticket prices.
What the server charges
| 2 × Adult | £10.00 each |
| 1 × Student | £6.00 each |
| Booking fee (one per paid order) | £1.00 |
| Total | £27.00 |
Sent to Stripe Checkout as one line per ticket type, plus a separate booking-fee line when it applies.
Why whole pennies?
Amounts are integers of pence everywhere (database, Stripe, maths). 20% off £6.00 is 480p exactly; a percentage that lands between pennies rounds half up, in one place, on the server. Floating-point pounds would drift and the totals would stop matching Stripe's.
07 · Decisions and trade-offs
Choices I'd defend, and what they cost
Hosted Stripe Checkout, not a custom card form
WhyCard details never touch our servers, which removes most of the security and compliance surface for a volunteer-run system.
CostLess control over the payment page; we customise around it instead (branding, fee line, expiry).
A ticket row exists only after payment
WhyThe webhook is the only thing that creates tickets, so a ticket existing is itself proof of payment. Stripe event ids are stored, so a replayed webhook does nothing.
CostThere is a gap between paying and the ticket arriving, so the order page polls and the email follows.
Signed QR codes, checked on every scan
WhyThe QR carries the ticket id plus an HMAC only the server can produce, so codes can't be guessed or invented. The server re-verifies and takes a row lock on every scan, so two phones can't both admit the same ticket.
CostA valid signature only proves the ticket was issued; status (used, refunded) still needs the database.
Server first at the door, with an offline fallback
WhyOnline scans are authoritative. If the server doesn't answer within a few seconds, the app checks a downloaded list and queues the entry to sync, so a dead signal slows nobody down.
CostOffline, two doors can't see each other. Sync settles it afterwards, and the app flags the clash instead of hiding it.
A separate, server-rendered ticket site
WhyThe orchestra's main website is static: fast, cacheable and cheap to host. Checkout, ticket pages and the door app need live data, so they live on their own server-rendered site at tickets.eu-co.co.uk.
CostTwo front-ends to deploy, and content the committee edits for the main site goes live on a rebuild rather than instantly.
Directus for content, Postgres for facts
WhyCommittee members already needed a friendly place to edit concerts, ticket types and discount codes. The backend reads from Directus but never writes to it, so a CMS mistake can't corrupt an order.
CostPrices are read from the CMS at purchase time, so the order stores what was actually charged, not a reference.
08 · What I learned
Things I'd do again, and things I'd change
I'd do again
- Put the awkward rules (holds, refunds, free-ticket limits, the fee) in tested code on day one, not in a spreadsheet
- Make the door tool boring: big result, one colour per outcome, a guest list for when a camera won't focus
- Write the operating guide alongside the software, because the people using it are volunteers who change every year
I'd change or add
- Wallet passes: the data model has a field for them, but they were never built
- Tap-to-pay on the door: it can't run from a web page, so it would need a card reader or a QR-pay link
- Decide up front who owns the system after I leave: a case study is not a handover document
Need something like this built?
Tell me a bit about what you need and I'll reply within a couple of days.