Skip to Content
Living documentation — last reviewed 2026-05-28
FeaturesScheduling BookingsScheduling & Bookings — Code Map

Scheduling & Bookings — Code Map

API

Module — class sessions (apps/api/src/class-sessions/)

FilePurpose
class-sessions.module.tsWires controller, service, R2 (logo presign), and dependencies (Memberships, Users, Email, DailyProgramming, Subscriptions, PaymentProviderConfig, Workouts).
class-sessions.controller.tsAll routes under organizations/:orgId/sessions.
class-sessions.service.tsCRUD + bulk + check-in + eligibility (~2300 lines).
dto/create-class-session.dto.tsclassTypeId, locationId?, coachMembershipId?, title?, startsAt, endsAt, capacity?, waitlistCapacity?, notes?, status? (‘draft’|‘published’).
dto/update-class-session.dto.tsPartialType(OmitType(CreateClassSessionDto, ['classTypeId'])) — class type immutable post-create.
dto/set-session-workouts.dto.tsworkouts: [{ workoutId, sortOrder }].
dto/inline-workout.dto.tsprogramId?, title?, description?, scoring?, timeCap?.
dto/self-checkin.dto.tsmethod: 'qr'|'gps', token?, expiresAt?, latitude?, longitude?.
dto/bulk-filter.dto.tsprogramId?, classTypeId?, dateFrom?, dateTo?, daysOfWeek?, startTimes? (HH:mm in org TZ), status?, includeBooked?.
utils/checkin.utils.tsgenerateQrToken, verifyQrToken, generateDisplaySignature, verifyDisplaySignature, haversineMeters, isWithinCheckinWindow, GPS_MAX_METERS.

Routes (prefix organizations/:orgId/sessions)

MethodPathHandler
POST/create
GET/list (by week, optional programId)
GET/upcoming-todayupcomingToday (owner/admin dashboard)
GET/today-workoutstodayWorkouts
GET/:idgetById
PATCH/:idupdate
PUT/:id/workoutssetWorkouts
POST/:id/workouts/inlinecreateInlineWorkout
POST/:id/publishpublish
POST/:id/unpublishunpublish
POST/:id/cancelcancel
POST/bulk-previewbulkPreview
POST/bulk-deletebulkDelete
POST/bulk-publishbulkPublish
GET/:id/bookingsgetBookings (roster, staff only)
POST/:id/check-in/:bookingIdcheckIn
DELETE/:id/check-in/:bookingIdundoCheckIn
GET/:id/qr-tokengetQrToken (staff, returns {token, expiresAt, checkinUrl})
POST/:id/display-urlgetDisplayUrl (staff, signed URL)
GET/:id/display-datagetDisplayData (@Public, sig+exp validated)
POST/:id/self-checkinselfCheckin
GET/attendance/:membershipIdgetAttendanceHistory

Module — bookings (apps/api/src/bookings/)

FilePurpose
bookings.module.tsImports MembershipsModule, UsersModule, SubscriptionsModule, NotificationsModule, PushNotificationsModule.
bookings.controller.tsMixed routes (org-scoped and bookings/my).
bookings.service.tsbook, cancel, adminCancel, waitlist promotion, credit accounting, analytics (getAttendanceSummary/Daily/Trend), getMyBookings.
dto/book-session.dto.tssubscriptionId? (UUID) — opt-in explicit plan selection.

Routes

MethodPathHandler
POST/organizations/:orgId/sessions/:sessionId/bookbook
DELETE/organizations/:orgId/sessions/:sessionId/bookcancel (self)
DELETE/organizations/:orgId/sessions/:sessionId/bookings/:bookingIdadminCancel
POST/organizations/:orgId/members/:membershipId/refund-creditrefundCredit
GET/organizations/:orgId/bookings/attendance-trendattendanceTrend
GET/organizations/:orgId/analytics/attendance/summaryattendanceSummary
GET/organizations/:orgId/analytics/attendance/dailyattendanceDaily
GET/bookings/mymyBookings

Web

Routes

RouteDescription
apps/web/src/app/[lang]/(protected)/dashboard/schedule/page.tsxWeekly calendar for staff.
apps/web/src/app/[lang]/(protected)/dashboard/schedule/sessions/[sessionId]/page.tsxSession detail (roster, workouts, check-in display).
apps/web/src/app/[lang]/(protected)/dashboard/schedule/sessions/[sessionId]/builder/page.tsxInline workout builder for a session.
apps/web/src/app/[lang]/(protected)/(member)/schedule/page.tsxMember weekly view.
apps/web/src/app/[lang]/(protected)/(member)/checkin/page.tsxQR/GPS check-in landing.
apps/web/src/app/[lang]/checkin-display/Public signed-URL display screen.

Hooks / API helpers

  • useApi (client) and serverFetch (server) — Clerk bearer attached automatically. See apps/web/src/hooks/use-api.ts, apps/web/src/lib/api.ts.
  • apps/web/src/components/dashboard/schedule/* — calendar grid, session sheet, bulk-ops dialog (TODO: verify exact paths).

DB tables involved

TableRole
class_sessionsThe session row itself.
class_session_workoutsJoin with sort order, cascade-delete on session/workout drop.
bookingsThe booking row + check-in metadata.
class_typesParent of session (mandatory FK).
programsParent of class_type; carries organizationId (the org-scoping anchor).
locationsOptional location on session; lat/lng powers GPS check-in.
membershipscoachMembershipId and bookings.membershipId.
organizationscancellationWindowHours, allowLateCancellation, timezone.
subscriptionsbookings.subscriptionId (nullable for staff).
audit_logsOne row per bulk-delete / bulk-publish batch with payload.

Shared schemas

  • libs/shared/src/lib/schemas/scheduling.schema.ts — Zod schemas for session response, booking response, bulk filter, eligibility (BookingEligibility, BookingPlanEntry, BookingBlockReason).
  • libs/shared/src/lib/schemas/day-of-week.tsdayOfWeekValues array used by bulk filter.
  • isStaffRole helper in @fitkit/shared — single source of truth for staff vs member.

Tests

FileWhat it covers
apps/api/src/class-sessions/class-sessions.service.unit.spec.tsCRUD, publish/unpublish guards, cancel side effects.
apps/api/src/class-sessions/class-sessions.bulk.unit.spec.tsBulk preview/delete/publish, filter resolution, audit logging.
apps/api/src/bookings/bookings.service.unit.spec.tsBooking transaction, capacity, waitlist, quotas, cancel + refund + promotion.
apps/web/e2e/specs/schedule*.spec.tsPlaywright flows (TODO: verify by ls apps/web/e2e/specs).