Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
11 KiB
Design
Product design: docs/superpowers/specs/2026-12-04-event-ticketing-design.md (approved 2026-12-04). This file holds the technical contracts. Change 1 (add-event-ticket-orders) already built the ticket table with code, the attendee columns, event_lead_uuid and the checked_in_* columns, so this change mostly fills them in.
Context
- Tickets and orders:
- Orders and tickets live in services-counter:
TicketOrderServicehandles the request andbyToken;TicketOrderStaffServicehandles mark paid, cancel and resend;TicketOrderMailersends the order emails;TicketOrderExpiryJobexpires holds. - mobile-api's
PublicPageServiceholds the public order endpoints andAdminTicketServicethe staff ones. - The gateway's
JWTAuthFilterlists the counter paths that are public.
- Orders and tickets live in services-counter:
- Venue self check-in:
EventCheckInService.lookupreturnsCHECKED_INorFORM.- The walk-in form posts to the existing register path with
attend=true.
- Capacity: "a registered invite counts toward capacity" already holds.
EventGuestService.register,TicketOrderService.createandEventHeadcountServiceall add registered guests, walk-ins and held tickets. No work here. - Leads:
RegistrationService.register(RegisterRequest)does the QR-registration matching and takessource,consentNoticeId,consentAtandattend. It returns the event lead uuid. - Portal:
clientApiredirects to/loginon a 401./api/auth/sessiondoes not redirect, and tells whether a staff session exists.qrcode.reactdraws QRs in the browser only.
Goals / Non-Goals
Goals:
- Ticket codes on payment.
- The
/t/<code>page with its public and staff views. - Attendee naming on the order page.
- Attendee consent.
- The paid email with the tickets, the ticket email, and resend ticket.
- Door check-in.
- Self check-in rules on ticketed events.
- The ticket counts.
Non-Goals:
- Payment gateway.
- Merch.
- Member accounts.
- WhatsApp ticket delivery: an attendee named with a mobile only gets no message; the buyer forwards the link.
- Transferring a ticket to another order.
- Printing tickets.
Decisions
-
Codes are issued when the order becomes Paid. This happens inside the same transaction as the status change, at three places:
TicketOrderService.create(free order),TicketOrderStaffService.markPaid(Awaiting payment or Expired), and nowhere else. Codes use the existing 22-characterRegistrationLinkService.newToken();uk_ticket_codeguards uniqueness. Cancelling keeps the code, and validity is computed: the order isPAIDand the ticket isACTIVE.- Alternative: codes at request time. Rejected, because an unpaid order would then carry QRs that look real.
-
Ticket state, computed in one place.
TicketState.of(order, ticket)returnsVALID,CHECKED_IN,AWAITING,ORDER_CANCELLED,ORDER_EXPIREDorTICKET_CANCELLED. The public page, the staff view, check-in and self check-in all use it. -
Renaming replaces the code. The attendee save is
POST ticket/attendeewith the order token, ticket id, name, mobile, email andpermission. In one transaction it:- checks the order token and that the order is
PAID; - checks the ticket is
ACTIVEand not checked in; - sets a new code,
attendee_named_at, the attendee fields, and clearsattendee_consent_at,attendee_notice_idandevent_lead_uuid; - after commit, sends the Ticket email when an email is set.
- Normalisation and the
MOBILE_OR_EMAIL_REQUIRED, name-length and email-format errors reuse the QR registration helpers in mobile-api.
- checks the order token and that the order is
-
Consent creates the lead through
RegistrationService.register. It is called with sourceTICKET, no salesperson, the company's current notice andattend=false. At check-in it is called withattend=true. The returned event lead uuid is stored on the ticket. An attendee whose details match a lead is linked to it, as QR registration already does.- Unnamed tickets: the consent needs a name and contact, so on the public page it is offered only for a named ticket. At the door, staff enter them first.
-
Staff view detection. The
/t/[code]page first calls the portal's/api/tickets/{code}, which answers 401 at once when there is no session and otherwise callsGET /api/admin/tickets/{code}. Only when that fails does it load the public view (GET /api/public/tickets/{code}), so a door scan never counts toward the publictkt:loadlimit. That call is guarded by@AdminModule("BO_EVENTS")and scoped by company in mobile-api withloadEvent(uuid, null), so another company's event is a 404. On 401, 403 or 404 the page stays public. The admin call uses a plainfetch, notclientApi, so a signed-out visitor is never bounced to login. -
Check-in.
POST /api/admin/tickets/{code}/checkintakes optional{name, mobile, email, consent}, which are required when the ticket is unnamed. Refusals are 409 with the codesALREADY_CHECKED_IN|<time>,NOT_VALID|<state>andNOT_EVENT_DAY. The update is conditional (checked_in_at IS NULL), so two scanners cannot both check a ticket in; the loser getsALREADY_CHECKED_IN. The action is@Audited. -
Self check-in on a ticketed event. For
tickets_enabledevents only,EventCheckInService.lookupchecks, in order:- the oldest
ACTIVEticket on aPAIDorder of the event, not checked in, whose attendee mobile or email matches, or whose attendee is blank and whose order's buyer mobile or email matches. It is checked in withchecked_in_by = 'self', and the lead is marked attended when the ticket has one; - a registered guest of the event, as today;
- otherwise the result is
SHOW_TICKET.
The walk-in register path refuses a ticketed event with 409
TICKETS_ONLY. The welcome uses the attendee's first name, or the buyer's for an unnamed ticket. - the oldest
-
QR PNG in mobile-api.
GET /api/public/tickets/{code}/qr.png:- checks the code shape and validity through counter
ticket/byCode; an invalid or unknown code is 404; - encodes
<admin-portal-base>/t/<code>with zxingQRCodeWriterat 300 px, written byImageIO; - responds
Cache-Control: private, max-age=300; - counts toward the
tkt:loadlimit.
The portal proxies it like the page images. Emails use the absolute portal URL in
<img src>. - checks the code shape and validity through counter
-
Order page tickets. Counter
byTokenaddstickets: [{id, typeName, attendeeName, code, state, checkedInAt}]only when the order is PAID. mobile-api passes them through without attendee mobile or email: the counter does not return those to the public call at all. -
Emails.
TicketOrderMailer:- PAID: gains one block per active ticket: the type, the QR
<img>and the link. It ends with "Name your attendees: ". - New kind TICKET: sends one ticket to its attendee (or to the buyer, when staff resend an unnamed ticket), with the consent invitation link pointing to the ticket page.
- All of them are sent after commit and are best effort, as today.
- PAID: gains one block per active ticket: the type, the QR
-
Counts.
EventHeadcountService.HeadcountgainsticketsAwaiting,ticketsPaidandticketsCheckedIn, from one grouped query over active tickets joined to their order status. The portal's GuestsCard shows them when the event sells tickets. -
Limits.
tkt:load:<ip>allows 120 per 10 minutes, for the ticket page and the QR together.tkt:submit:<ip>:<event>allows 60 per 10 minutes, for naming and consent. Naming first looks up the order by its token, which counts toward the order page'sord:load:<ip>limit (120 per 10 minutes).- Staff check-in has no IP limit: it is an authenticated admin call.
Data
sql/01-ticket-attendees.sql (services-counter, additive):
ALTER TABLE `ticket`
ADD COLUMN `attendee_named_at` datetime NULL,
ADD COLUMN `attendee_consent_at` datetime NULL,
ADD COLUMN `attendee_notice_id` bigint NULL,
ADD KEY `idx_ticket_event_mobile` (`event_uuid`, `attendee_mobile_e164`),
ADD KEY `idx_ticket_event_email` (`event_uuid`, `attendee_email`);
sql/02-ticket-labels.sqlholds the labels, cut fromnpm run i18n:sql.sql/99-rollback.sqldrops the three columns and two keys. Codes stay, because change 1 owns the column.
Endpoints
| Layer | Method and path | Auth |
|---|---|---|
| counter | GET ticket/byCode/{code} |
public via gateway |
| counter | POST ticket/attendee (order token, ticket id, attendee, permission) |
public via gateway |
| counter | POST ticket/consent (code, notice id) |
public via gateway |
| counter | POST ticket/staff and POST ticket/checkin (company id and code in the body) |
JWT (from mobile-api admin) |
| counter | POST ticketOrder/resendTicket (company, event, order and ticket ids in the body) |
JWT |
| mobile-api | GET /api/public/tickets/{code}, GET .../qr.png, POST .../consent |
public |
| mobile-api | POST /api/public/orders/{token}/tickets/{ticketId}/attendee |
public |
| mobile-api | GET /api/admin/tickets/{code}, POST /api/admin/tickets/{code}/checkin |
BO_EVENTS |
| mobile-api | POST /api/admin/events/{uuid}/orders/{orderId}/tickets/{ticketId}/resend |
BO_EVENT_TICKETS |
| gateway | public: GET /counter/ticket/byCode/[A-Za-z0-9_-]{22}, POST /counter/ticket/attendee, POST /counter/ticket/consent |
|
| portal | /t/[code] page (public in the route guard); proxies for each mobile-api path above |
Risks / Trade-offs
- Mobile-only attendees get no ticket message. The buyer shares the link. Mitigation: the order page shows each ticket's link with a copy button. WhatsApp delivery can follow once the business account is linked.
- A forwarded ticket link works for whoever holds it. This is the same as any paper ticket; check-in is one-time. Mitigation: renaming replaces the code.
- Staff view on a phone needs a signed-in session in that phone's browser. That is the existing portal login; the door staff sign in once.
- New dependency
com.google.zxing:core, MIT-style Apache 2.0, no transitive dependencies, used only for the email PNG. - Self check-in matching an unnamed ticket to its buyer lets the buyer check in once per unnamed ticket. Each lookup takes one ticket, which matches the buyer bringing friends whose names were never given. ponytail: no per-person cap; add one if abuse is seen.
Migration Plan
- Run
sql/01-ticket-attendees.sqlbefore the new services-counter starts. It is additive, and the old images ignore the columns. - Deploy services-counter, mobile-api, api-gateway and the portal.
- Run
sql/02-ticket-labels.sql. - Orders paid before this release have tickets without codes. A one-off statement in
01gives every active ticket on a PAID order a code, usingREPLACE(TO_BASE64(RANDOM_BYTES(16)), ...)trimmed to the 22-character URL-safe form. - Rollback: the previous images, then
99.
Open Questions
None for the owner. Builder calls are recorded above (decisions 4, 5 and 7) and in the release note.