Projects

Lounge Booking

A Telegram Mini App for booking the three shared lounges in my residential college at NUS. About 130 residents use it, and for a while a bug broke it for 40% of them.

The app: a floor switcher for Levels 9 to 11, upcoming bookings for Level 9, a month calendar and a My Bookings list
Pick a floor, see what's already taken, then pick a date. Nobody signs up: the name at the top comes from Telegram.

Why I built it

Garuda House, my house at the College of Alice & Peter Tan (CAPT), has shared lounges on Levels 9, 10 and 11. People need to see what's free and book a slot without clashing with someone else. The app belongs to Garuda Techs, the house committee's tech team, which I'm part of.

I made it a Telegram Mini App because that's where residents already talk to each other. It opens inside the chat and Telegram already knows who you are, so there's no sign-up or password, and every booking comes with a name attached.

What it does

  • Each lounge has its own calendar and bookings.
  • You can book several hours in a row at once, and the server checks for overlaps on that floor.
  • Consecutive hours show up as one block, like 12:00–15:00.
  • Each floor has a strip of upcoming bookings, so you can see what's taken at a glance.
  • Admins can cancel bookings, and the list of admins lives in an environment variable.

From mid-February I reworked the first version into the one residents use now, fixed the bugs below, and built the interface and the admin tools. It runs on Node.js, Express and SQLite, hosted on Railway.

Decisions

One row per hour

Each booked hour is its own row in the database, which keeps the overlap check simple because an hour is either taken or it isn't. The interface merges consecutive hours so people see 12:00–15:00 instead of three separate entries.

Admins in an environment variable

Committee members change. Adding or removing an admin is a variable change on Railway, with no code change or redeploy.

SQLite on a volume

For one house's bookings, a separate database server would just be one more thing to run. The SQLite file sits on a Railway volume so it survives restarts and redeploys.

What went wrong

The app couldn't find 40% of users' bookings

Friends testing it found that their bookings weren't showing up, because big Telegram IDs were being saved as 6123456789.0 and lookups never matched. I wrote about how I tracked it down in a note.

The rate limiter was blocking the wrong people

Behind Railway's proxy, every request looked like it came from the proxy instead of from each resident, which threw off the per-user rate limit. Setting Express to trust the proxy's forwarded address fixed it.

Identity came from the client

The early version took the user's Telegram ID from the request, so someone could send a hand-made request and act as another resident. In August a teammate moved identity to the server. Every request now carries Telegram's signed initData, and the server checks the signature before trusting it. User-supplied names are now escaped too, which closed a stored XSS hole.

The best part

Seeing people actually use it. Bookings used to go through a Telegram channel that turned into a long list of messages, and now people just open the bot instead. One of my friends even told me he'd been telling the other houses about it, since some of them didn't have their own booking bot yet, which made me pretty happy.