Sidequest
An invitation board for adults at UBC, live at sidequest.looseword.ca. It is built on Next.js, TypeScript and Supabase, with one PostgreSQL function that enforces request, offer and accept before any chat opens. Matching rounds are paused.
What it is for
Sidequest is a board for setting up in-person plans at UBC. A person chooses friendship, dating or either, and writes a concrete idea for meeting in public. The board shows approved plans. It has no comments, likes, popularity counts or ranked people.
A reader who likes a plan sends one private request. The author decides whether to offer an introduction, and the reader makes the final choice before any chat exists.
The Boba Committee has one vacant seat.
Agenda: argue about toppings. We each buy our own drink. Previous committee experience is irrelevant.
What I worked with
Technology, and what I did with it
- Next.js, TypeScript, Vercel
- I built the board, the consent flow and a single catch-all API route in Next.js and TypeScript, deployed on Vercel.
- PostgreSQL: plpgsql dispatcher, advisory lock, RLS
- All 27 tables sit behind row-level security with no direct read access, and every action goes through one plpgsql dispatcher function. It takes a transaction advisory lock, applies a rate limit per action and checks each consent step before chat opens.
- Supabase Auth
- Member sessions run on Supabase Auth. Deleting an account clears the profile, messages, campus claim and stored photos, then deletes the sign-in identity.
- Supabase Storage (private bucket policy)
- Profile photos sit in a private bucket. Its storage policy checks whether the viewer may see that photo through a request or a connection, and uploads go only through a server route.
- SMTP (Nodemailer), Resend, HMAC digests
- Campus verification codes go out over SMTP with Nodemailer, or through Resend. Each code is stored only as an HMAC digest.
- Web Push
- Browser alerts are generic, with no names or message text, so private activity stays inside the app.
- Edmonds' blossom algorithm
- For the optional matching rounds (paused), the app carries its own TypeScript implementation of Edmonds' blossom algorithm for maximum matching.
How an invitation moves
One invitation from the board to an agreed plan, with the route each person calls and the state the database moves to.
- AuthorPosts a plan on the board.
- ServerNext.js on Vercel. One route for every action.
- DatabasePostgreSQL on Supabase. One dispatcher function holds the rules.
- SenderReads the board and asks to join.
The server accepts only a UBC student address and mails it a six-digit code. It stores an HMAC digest of the code, never the code. A code expires after ten minutes and allows five attempts.
POST /api/sidequest/campus/request { "email": "<name>@student.ubc.ca" } POST /api/sidequest/campus/confirm { "code" }The author saves an exact preview, then publishes it with explicit consent to that text and that audience. A moderator approves that revision before it appears. Changing the text clears the consent and needs a new review.
POST /api/sidequest/board/preview POST /api/sidequest/board/publishThe sender writes a short message and confirms what they are sharing. The database creates a response in state pending. It expires after 72 hours, or when the post does. The sender sees no author profile yet.
POST /api/sidequest/responses { "postId", "revision", "intent", "availability", "message", "shareConfirmed": true } -> response.status = 'pending'Only the author can make this move, and only on a pending response. Offering reveals who the author is to the sender.
POST /api/sidequest/responses/{id}/offer if r.status <> 'pending' then raise exception 'RESPONSE_CHANGED'; -> response.status = 'offered'Only the sender can accept an offer. In one transaction, the database rejects the accept if either person already has an active introduction. Otherwise it creates the connection, both memberships and the first message, and marks their other open requests unavailable.
POST /api/sidequest/responses/{id}/accept -> response.status = 'accepted' insert connections, connection_members x 2, messages x 1Chat is text only. Either person can propose a place, time, budget and length, and both confirm the same version. Any edit resets both confirmations. Either person can end the conversation, block or report at any point.
GET, POST /api/sidequest/connections/{id}/messages PUT /api/sidequest/connections/{id}/plan POST /api/sidequest/connections/{id}/plan/confirm
Consent enforced on the server
If the browser enforced the three steps, a modified client could open a chat alone. So each step is a state change in the database, and the database checks who is making it. Press the steps in order, or try them out of order.
Press each step in order
offeredOnly the sender can accept the offer and open chat.The gate uses the real response states: pending, offered and accepted. Blocking or pausing closes an open connection, and pausing board contacts stops new requests, offers and acceptances.
One dispatcher, rules in SQL
The browser talks to one catch-all Next.js route. The handler maps each path to an action name and calls a SQL function with that name and a JSON payload. All 27 tables sit in a private schema with row-level security and no direct read access.
The dispatcher opens every mutating action the same way: cap the payload size, take one transaction lock so two requests cannot both claim the last free slot, then apply that action's rate limit.
create function sidequest_private.dispatch(p_action text, p_payload jsonb) returns jsonb ...
-- One transaction lock serializes pair allocation and membership changes.
if p_action not in ('state','messages', ...) then
perform pg_advisory_xact_lock(78236421);
end if;
-- This is the real rate boundary; calling the RPC directly cannot bypass it.
if not sidequest_private.rate_limit(sid, ...) then
raise exception 'RATE_LIMITED';
end if;Main routes
GET /api/sidequest/board- Approved plans, by public or campus audience and by activity, 20 to a page.
POST /api/sidequest/board/preview, /publish, /withdraw- The author's own plan: save a preview, submit it for review, take it down.
POST /api/sidequest/responses- Request contact on a plan.
POST /api/sidequest/responses/{id}/offer, /accept, /decline, /cancel- The moves each side can make on a request.
/api/sidequest/connections/{id}/messages, /plan, /plan/confirm, /end- Chat, the shared plan, and ending the conversation.
POST /api/sidequest/block, /report- Block a person, or report them to the moderators with a written reason.
/api/sidequest/photos- Upload, read and delete private profile photos, through the server only.
POST /api/sidequest/account, GET /account/export- Delete the account, or export your own data.
POST /api/sidequest/campus/request, /confirm- The campus mailbox check.
Rate limits, per person, enforced in SQL
message- 60 per minute
plan, confirm- 20 per minute
profile, invitation, photo- 20 per 5 minutes
decision, block- 30 per 5 minutes
account- 10 per 5 minutes
report- 10 per hour
campus code request- 5 per hour
Design decisions
The rules live in the database
Anyone with a session can call the database function directly, so a rule checked only in the browser or the route is not a rule. State changes, rate limits and capacity checks all run inside the SQL dispatcher.
Instead of checks in the client or in the route handlers alone.
Request, offer, accept
The author sees who is asking before deciding. The sender sees nothing about the author until an offer, and makes the final choice. Neither side can open a chat alone.
Instead of a like or a match that opens a conversation in one step.
One introduction at a time
A person has one active introduction across the board and the rounds, at most three live requests, and no more than three different people in 48 hours. The same two people cannot be paired again for seven days. The aim is fewer open threads that go nowhere.
The board comes first, rounds are optional
Scheduled matching rounds help coordinate a small launch, but they should not lock visits to a weekly rhythm. The ongoing board is the main experience, with organizer-run rounds as a separate mode.
Instead of a weekly reveal as the main rhythm of the product.
Friendship needs no dating profile
Friendship shares only a campus name. Dating adds a private profile, preferences that must match in both directions, and photos the other person is authorized to see.
Photos never leave private storage
The bucket is private. Signed-in users have a read rule that checks whether this photo is visible to them through a request or a connection, and no rule to write. Uploads go through a validated server route.
Deleting an account deletes the sign-in
Deletion removes the profile, the photos in storage, the campus claim and the person's messages, deletes the sign-in identity, signs out every session and writes a receipt. Limited moderation and security records may remain.
Generic browser notifications
A browser alert reads "New Sidequest activity", with no name, photo or message text, and opens the private inbox.
Matching rounds
Rounds are the optional second mode. An organizer opens a round for up to 80 people. Each person is shown at most three others and has 48 hours to answer yes or pass.
When the round closes, the mutual yeses form a graph, and one person can sit in several of them. To introduce as many people as possible, with one introduction each, the server runs Edmonds' blossom algorithm for maximum matching on a general graph. The app carries its own TypeScript implementation.
Real rounds are paused. No schedule has been published.
Status
Sidequest is live at sidequest.looseword.ca for adults 18 and over at UBC Vancouver. It is not affiliated with UBC. The invitation board is open, and optional matching rounds are paused with no published schedule.