How aydeloreabaquita/pick-a-court works
CourtBook is a backend for discovering courts, checking availability, holding and managing reservations, collecting payment, and administering bookings. The principal flow is a player querying courts and conflicts, creating a booking hold, then starting checkout; PayMongo’s signed webhook updates payment and booking state. The graph follows documented API behavior and sampled handlers. Database schema and several routes are represented from the tree and README; their internal wiring is not inferred beyond documented behavior.
Main entry points: 001_initial_schema.sql Supabase database · auth.ts Auth guards · checkout/route.ts Checkout creation · paymongo/route.ts Payment webhook
Components 16
Court discovery
- Court listing
app/api/courts/route.ts - Availability
app/api/availability/route.ts
Reservations
- Player bookings
app/api/bookings/route.ts - Cancel booking
app/api/bookings/[id]/route.ts - Admin bookings
app/api/admin/bookings/route.ts
Payments
- Checkout creation
app/api/payments/checkout/route.ts - Payment webhook
app/api/webhooks/paymongo/route.ts - PayMongo client
lib/paymongo.ts
Access and data
- Health check
app/api/health/route.ts - Auth guards
lib/auth.ts - Session client
lib/supabase/server.ts - Service client
lib/supabase/admin.ts - Supabase database
supabase/migrations/001_initial_schema.sql
Other components
- Player / client
- Facility admin
- PayMongo
Connections 27
- Player / client → Court listing: lists courts
- Player / client → Availability: checks slots
- Player / client → Player bookings: manages bookings
- Player / client → Cancel booking: cancels booking
- Player / client → Checkout creation: starts checkout
- Facility admin → Admin bookings: views bookings
- PayMongo → Payment webhook: sends events
- Court listing → Session client: creates client
- Court listing → Supabase database: queries courts
- Availability → Service client: creates client
- Availability → Supabase database: reads conflicts
- Player bookings → Auth guards: requires user
- Player bookings → Supabase database: reads / creates
- Cancel booking → Auth guards: requires user
- Cancel booking → Supabase database: reads / updates
- Admin bookings → Auth guards: requires admin
- Admin bookings → Supabase database: queries bookings
- Checkout creation → Auth guards: requires user
- Checkout creation → Supabase database: reads / records
- Checkout creation → PayMongo client: creates session
- PayMongo client → PayMongo: requests checkout
- Payment webhook → PayMongo client: verifies signature
- Payment webhook → Service client: creates client
- Payment webhook → Supabase database: records / updates
- Auth guards → Session client: creates session
- Auth guards → Supabase database: checks claims / role
- Session client → Supabase database: auth access