Case study
Avel
تعداد نفرات رو انتخاب کن و میزهای آزاد رو ببین.
What it is
Avel is everything a café does online, on one server: its website and menu, a menu that helps you choose, games for the table while you wait, table booking with online payment, and one admin panel that runs all of it.
It started as two projects: the café's website, which I built alone, and a booking system whose back end I built while a teammate built the front end. I merged them into one server, one database and one panel, moved the back end to strict TypeScript and rebuilt every page in React. Then I kept going.
Avel is the first café on it. Underneath is a template: the name, logos and contact details live in one file, so the next café is a rename away.
- You book a time, not a seat. Here you pick your exact table on the real floor plan.
- Two people can book the same table. One transaction at a time makes that impossible.
- Guests can't decide what to order. A few quick questions, then one to three picks from the real menu.
- Waiting at the table is dull. Eleven party games on one phone, even when the Wi-Fi drops.
- Changing the layout means changing code. Every table and every chair is data, edited in the panel.
- Role
- Everything: server, data model, every page, the panel
- Team
- Solo. The first booking front end was a teammate's
- Type
- Café website, menu, games, booking and payments
- Stack
- TypeScript, Express, Prisma, PostgreSQL, React
- 71menu items, tagged
- 11games, one phone
- 24tables, 3 halls
- 204automated tests
Part one
For the guest
One evening at Avel, from booking the table to getting up from it.
01
A seat, not a slot
The demo at the top is the booking page in miniature. Pick a day, a party size and a time, and the tables that fit light up on the café's floor plan. Each table has its own range: a four-seat table can take two, but not five. One that fits exactly glows darker than one with seats to spare. If no single table is right, up to four connected tables are offered together.
Before the hold the guest confirms their number with an SMS code, which also signs them in. The table is then held for ten minutes while they pay. The invoice comes once the payment is confirmed, with a file for the phone's calendar and a reminder by SMS before the visit. Every booking leaves fifteen minutes for the table to be cleared.
- Searchday, guests, time
- Picka table or a group
- VerifySMS code, signed in
- Hold10 minutes
- PayZarinpal
- Invoice+ calendar, reminder
02
No table twice
A seat anyone can pick is a seat two people can pick at once. When two guests tap the same table in the same moment, both requests reach the server together. Checking that the table is free and creating the hold happen inside one serializable transaction, so only one can win. The other is told plainly and asked to pick again. When PostgreSQL aborts a transaction only because another ran beside it, it is retried on its own.
The price is read from the server's settings, never from the request. Every trip to the gateway is its own payment, so paying on an old tab still counts; if the hold ran out and the table went meanwhile, the booking goes to a manager instead of vanishing, and a second payment is recorded as owed back.
میز برات نگه داشته شدHeld for ten minutes.
Serializable
این میز همین الان توسط شخص دیگری رزرو شد؛ یک گزینهی دیگر انتخاب کن.409: someone else just took it.
03
On the night
The table is held; the evening comes. The guest finds the café's page: its three spaces, what people order most, a gallery, the address on a map, and opening hours that come straight from the panel.
The menu is split into tabs (café, breakfast, restaurant) that the manager adds, renames and reorders. Products carry paid add-ons, and the same pizza with extra cheese is its own line in the order list a guest keeps on their phone to show the waiter. A sold-out item stays on the menu, greyed, and is never suggested.
04
Pick for me
Seventy-one items is a lot to choose from. A round button on the menu asks what you are after, a few quick questions follow, and one to three items come back, each with its reason.
The questions are not a fixed list. After every answer each product is scored again, and the next question is the one that best splits what is still in the running, weighted by how much guests care. A question that would barely split them is never asked, and an answer nothing fits is never offered.
The café tags its own menu. A category's tags pass to its products, and a product only overrides what differs: a decaf coffee changes the caffeine answer and inherits the rest. Before it went live a script played 1,000 simulated guests on the real menu to tune it.
05
Games at the table
The order is in; now the wait. While the food is on its way, one phone goes round the table. There are eleven games: Spy, Heads Up with the phone on your forehead (tilt it down for a guess), Charades, Taboo, Mafia with the phone as the narrator's script, Ludo, Chess, Backgammon and three board games.
Nothing about the players reaches the server. The games and their 830 cards load once and stay on the phone, so they still open when the café's Wi-Fi drops, and a game survives a reload or a call.
Every bot is my own, with no outside engine. Tic-tac-toe never loses, chess searches captures to the end, and this one looks six moves ahead. Try to beat it.
- جاسوس
- گوشی رو پیشونی
- پانتومیم
- کلمات ممنوعه
- مافیا
- منچ
- شطرنج
- تخته نرد
- دوز
- چهار در یک ردیف
- نقطهبازی
نوبت توئه: یه ستون رو بزن.
The bot runs in your browser, as it does on the café's phones.
Part two
Behind the counter
Everything the guest touched tonight, and how the café runs it without me.
06
One panel, three roles
The booking, the menu, the questions behind «انتخاب برای من», the games and their cards: all of it lives in one panel, with hours, closures, prices and reports. Reviews wait there for approval, then play on the site like a chat, each with the café's reply. Who can touch what is decided in one file on the server; the panel only hides the buttons.
Closing early or blocking a hall never cancels a booking by itself: the panel lists the guests it falls on, with their numbers, so the staff can call them. Cancelling a paid booking records a refund owed until a manager marks it paid back.
07
The café is data
Even the room is in the panel. Nothing about the layout is written in code: every table can be moved, turned and resized, its chairs added or removed one by one, its seats, minimum and maximum set by hand, and which tables may be joined chosen.
A whole new plan is applied with one command. Tables that leave are deleted if no booking ever used them; otherwise they are retired, gone from the map and every search while past bookings keep their number. It refuses while upcoming bookings sit on a table that would go.
ویرایش میز ۱۲
- چرخش
- ۰ درجه
- ظرفیت
- ۶
- حداقل نفرات
- ۳
- حداکثر نفرات
- ۶
08
Built to hand over
Avel is the first café on it, not the last.
-
A café in one file
The name, address, phone, map pin and logos come from one file. Pages, SMS texts, invoices and the payment description all read it.
-
Photos made safe
Uploads are checked by their content, not their name, then turned into one WebP at most 1200 px, with the GPS position and camera data stripped.
-
204 tests
Roles, holds, payments, closures, the recommender and every game's rules and bots, chess checked against the standard perft counts.
-
One server to run
Express serves the API and the pages; in development Vite runs inside it. Every old address still works through a permanent redirect.