AMA booking platform
The AMA booking platform lets a visitor discover an open time, prepare a Booking Brief, pay for a 60-minute AMA Session, and receive the information needed to attend. It joins the site's availability rules with Google Calendar, Stripe, a meeting service, and email so that a paid Booking stays useful even when an external service needs more time or needs recovery.
System boundary
The platform covers the visitor journey from public AMA information through session completion. A Booking is a paid claim on one AMA Session start time. It includes the Guest, the Booking Brief, the meeting choice, and the Booking lifecycle.
The public surface is separate from the owner surface. Visitors use the editorial AMA page, booking flow, confirmation page, and private Manage Link. The owner uses the AMA admin area to set hours, review Bookings, resolve Alternate Time Requests, and recover work that needs attention.
Visitor journey
The visitor journey turns an open time into a paid and usable AMA Session. Each stage gives the next stage enough information to continue without making the visitor create an account.
flowchart LR
A[AMA information] --> B[Availability]
B --> C[Slot Hold]
C --> D[Stripe Checkout]
D --> E[Verified payment]
E --> F[Booking]
F --> G[Meeting and calendar details]
G --> H[Email and Manage Link]
H --> I[AMA Session]
H --> J[Reschedule or cancel]
Availability discovery
The availability view shows start times that are open for a 60-minute AMA Session. It combines recurring Availability Windows with Date Overrides in the Schedule Time Zone, then removes calendar conflicts, active Slot Holds, Bookings, notice violations, and buffer conflicts. The visitor sees the result in a chosen display time zone. See AMA availability for the schedule model and slot rules.
The public booking flow also provides an Alternate Time Request when no listed time works. This is an unpaid request. It does not reserve a time or charge the visitor.
References: lib/…/service.ts• L261-361 lib/…/engine.ts• L138-247 components/…/booking-flow.tsx• L153-239
Intake and Slot Hold
After the visitor chooses a time, the flow collects a name, email, topics, and Booking Brief. The Booking Brief states what would make the hour valuable and can include supporting links. The visitor also chooses Google Meet or Tencent Meeting.
Submitting the form creates a Slot Hold. A Slot Hold is a temporary 15-minute claim on the selected start time while the visitor completes payment. The system checks the time again when it creates the hold, so a time that became unavailable is returned to the flow for a new choice.
References: components/…/booking-flow.tsx• L353-376 components/…/booking-flow.tsx• L508-575 lib/…/service.ts• L230-270 lib/…/policy.ts• L1-20
Payment and Booking creation
Payment takes place on Stripe Checkout. The site sends the visitor to Stripe with the AMA Session price and a return link. The Stripe webhook, not the return link, confirms payment and creates the Booking.
The payment path is safe to retry. A repeated checkout request reuses the hold's payment session, and a repeated or late webhook does not create a second Booking. If payment arrives after the Slot Hold expires, the system tries to reclaim the original time. If another Guest now owns it, the Booking becomes a Finalizing Booking with needs_reschedule; the Guest receives a private path to choose another time or receive a refund.
See AMA booking lifecycle for the state changes and recovery paths.
References: lib/…/service.ts• L275-385 lib/…/service.ts• L387-553 lib/…/webhook.ts• L22-76
Confirmation and session access
The confirmation page reads the server state after the visitor returns from Stripe. It keeps checking while payment or finalization is in progress. It does not show a confirmed session until the server has the matching paid state.
Once the Booking is ready, the Guest receives the session time in the Guest's time zone, the selected meeting service, the meeting link, the calendar invitation, and a private Manage Link. The confirmation email and the Manage Link remain the main recovery channel when the visitor leaves the confirmation page.
References: components/…/booking-confirmation.tsx• L173-262 components/…/booking-confirmation.tsx• L369-443 lib/…/templates.ts• L148-226
Booking management
The Manage Link is a private capability link for one Booking. It lets a Guest view the Booking without an account and, when the policy allows it, reschedule or cancel it.
Guests can reschedule or cancel until 24 hours before the session. An eligible cancellation starts an automatic full refund. A reschedule checks the current availability again and preserves the paid Booking while moving its time. A Booking in needs_reschedule can choose a new time even though its original time is no longer usable.
References: lib/…/manage.ts• L45-143 lib/…/manage.ts• L146-239 components/…/manage-booking.tsx• L126-246
External service coordination
External services provide time conflicts, payment proof, meeting access, calendar invitations, and message delivery. The platform treats each service as a dependency of a larger Booking process rather than as the source of Booking truth.
Calendar and meeting services
Google Calendar supplies free and busy time for availability and stores the calendar event for a confirmed Booking. When Google Meet is selected, the calendar event also asks Google to create the meeting link.
Tencent Meeting supplies the meeting room through its server-side meeting service. The platform places the Tencent link in a normal calendar event. Tencent rooms do not guarantee a move or delete action, so cancellation and rescheduling use the provider's available action when possible and record the remaining limitation.
See AMA external integrations for the provider boundaries, credential posture, and recovery behavior.
References: lib/…/service.ts• L59-64 lib/…/calendar.ts• L14-49 lib/…/tencent.ts• L380-435 lib/…/service.ts• L196-224
Durable follow-up
Payment verification starts work that may outlive one web request. Durable follow-up creates meeting artifacts, sends confirmation and reminder email, updates artifacts after a reschedule, issues refunds, removes external artifacts, and purges the Booking Brief after 90 days.
The work runner claims each task for a short lease. A successful task is completed. A temporary provider error returns it to the queue with bounded backoff. A terminal error stays visible for owner action. This keeps a paid Booking in finalizing rather than presenting provider delay as payment failure.
Provider work has both a per-request timeout and a shared deadline for one drain. The shared deadline reaches all provider calls in that drain, including retries. If it expires during a task, the active task is re-queued and work not yet started is deferred for a later run. The runner also keeps headroom for late follow-up work, so the scheduled sweep remains able to recover reminders, retries, and expired Slot Holds.
A successful payment or Guest action can start an inline drain so new work begins without waiting for the next scheduled sweep. The inline drain is an early start, not a replacement for the scheduled worker. Both paths use the same leased operation queue and recovery rules.
References: lib/…/handlers.ts• L110-195 lib/…/handlers.ts• L288-401 lib/…/deadline.ts• L6-34 lib/…/runner.ts• L48-140 lib/…/server.ts• L38-42 lib/…/server.ts• L236-261
Owner operations
The owner surface gives Cali control over both the schedule and the Booking ledger. It shows upcoming Bookings, Bookings that need attention, past Bookings, cancelled Bookings, and new Alternate Time Requests.
Owner actions include rescheduling, cancellation, refund exceptions, operation retries, and manual operation resolution. These actions use the same Booking rules as the Guest path where possible. Owner changes are authenticated, rate limited, and recorded as privileged actions.
The scheduled work endpoint releases expired Slot Holds and drains due durable work. The configured scheduler runs it at a regular interval. Successful payment and Guest management can also start an inline drain for newly queued work, while the scheduled sweep remains responsible for delayed work and recovery over time.
References: app/…/page.tsx• L74-176 lib/…/booking-http.ts• L45-72 app/…/route.ts• L4-16 vercel.json• L6-14 lib/…/server.ts• L236-261
Trust and data boundaries
The platform keeps payment, identity, schedule claims, and provider artifacts linked without exposing more data than each surface needs. Public mutation requests use same-origin checks and a pseudonymous rate limit. Manage Links disclose only the Booking associated with the private token and do not require an account.
The database keeps the Booking and its event history as the long-lived record. It also keeps provider references so retries can recognize existing calendar events, meeting rooms, payment events, and refunds. The Booking Brief is private working context and is purged 90 days after the session. Financial and scheduling records remain for reconciliation.
References: lib/…/manage-token.ts• L5-28 lib/…/http.ts• L69-99 lib/…/repository.ts• L282-336 lib/…/handlers.ts• L524-538
Related pages
- AMA availability explains how recurring hours, Date Overrides, calendar conflicts, and Booking claims become public times.
- AMA booking lifecycle explains Slot Holds, payment confirmation, Booking states, rescheduling, cancellation, and recovery.
- AMA external integrations explains Google Calendar, Google Meet, Tencent Meeting, Stripe, and email boundaries.
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to availability policy must remain consistent across the public slot preview, hold creation, reschedule checks, and the claim overlap rule.
- Changes to Stripe checkout metadata or webhook event handling must preserve the link from a paid provider event to one Booking and its Slot Hold.
- Changes to meeting provider names must update visitor choice data, Booking records, artifact creation, email wording, and provider cleanup behavior together.
- Changes to Booking time or status must account for pending reminders, finalization work, calendar artifacts, Manage Link views, and refund eligibility.
- Changes to Manage Link derivation or storage must preserve both email retry behavior and private-link revocation.
- Changes to the scheduled or inline work contract must preserve expired-hold release, reminder timing, provider deadline handling, and durable-operation recovery.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Google Calendar is disconnected, denied, expired, or revoked | Public times are unavailable and finalization cannot create or update calendar artifacts. | Availability reports a non-connected status and provider-backed routes fail closed until the connection is restored. |
| A Guest pays after the Slot Hold expires and another Guest took the time | The paid Booking cannot keep its original start time. | The webhook attempts to reclaim the interval and otherwise marks the Booking needs_reschedule with a no-cost recovery path. |
| Stripe sends the same event more than once | A second Booking or duplicate side effect could result. | Provider event ids and Checkout Session identity are persisted before or during the idempotent Booking path. |
| A provider call exceeds its request timeout or the drain deadline expires | The current operation may not finish, and later work may wait for another run. | Requests share the drain deadline. The runner re-queues interrupted work and defers work that it cannot start within its budget. |
| Meeting or email delivery fails after payment | The Booking lacks some session details or the Guest lacks a message. | Durable operations retry with leases and backoff. Terminal work remains visible for owner recovery. |
| A Guest changes a Booking after its 24-hour cutoff | An online time change or automatic refund would violate the policy. | The Manage service checks the cutoff before rescheduling and derives refund eligibility from the current Booking time. |
| Tencent does not expose a room delete or move action | An old Tencent room or invitation may need best-effort cleanup during cancellation or rescheduling. | The system records the provider limitation and still updates the Booking and calendar artifacts it controls. |
Key files
| File | Why to read it |
|---|---|
| lib/…/CONTEXT.md | Defines AMA terms such as Guest, Booking Brief, Slot Hold, Booking, Finalizing Booking, and Manage Link. |
| app/…/ama-page.tsx | Shows the public offer and the visitor-facing shape of the AMA Session. |
| components/…/booking-flow.tsx | Shows the visitor path from slot discovery through intake, Slot Hold, payment, and Alternate Time Request. |
| lib/…/service.ts | Connects schedule data, calendar free/busy data, holds, and Bookings to public availability. |
| lib/…/service.ts | Connects Slot Holds, Stripe Checkout, verified payment, Booking creation, and finalization work. |
| lib/…/manage.ts | Defines the Guest reschedule and cancellation rules used by the Manage Link. |
| lib/…/handlers.ts | Shows how meeting artifacts, email, reminders, refunds, cleanup, and privacy work continue after the request. |
| lib/…/deadline.ts | Defines the shared deadline and provider request limits that keep durable work bounded. |
| lib/…/runner.ts | Shows how delayed provider work is leased, retried, completed, deferred, or parked for recovery. |
| lib/…/server.ts | Shows how the booking, provider, security, and durable-work services are assembled and how mutations start inline work. |
| app/…/page.tsx | Shows the owner view of schedule health, upcoming Bookings, and attention work. |