How prabhu0023/client-saas works
DoctorDesk is a WhatsApp-first clinic appointment platform with a staff portal. Its patient workflow routes inbound WhatsApp events to a clinic, processes booking or messaging intents, offers timezone-aware slots, books appointments, and sends replies. Staff separately manage availability and appointments, handle patient inbox threads, and receive due-reminder processing. The README documents these capabilities; unsampled modules appear as directory-level subsystem nodes, and edges are limited to relationships supported by excerpts, the source index, or README.
Main entry points: route.ts Inbound webhook · admin.ts Service-role client · messages.ts Thread data access · send.ts WhatsApp sending
Components 29
Patient WhatsApp
- Inbound webhook
src/app/api/whatsapp/inbound/route.ts - Clinic routing
src/lib/clinics/resolve-by-account.ts - Contact lookup
src/lib/whatsapp/wacrm-client.ts - Conversation session
src/lib/whatsapp/session.ts - Message flow
src/lib/whatsapp/text-flow.ts
Scheduling
- Booking queries
src/lib/whatsapp/query.ts - Slot generation
src/lib/availability/slot-generation.ts - Timezone conversion
src/lib/availability/timezone.ts - Booking transaction
src/lib/booking/book.ts - Reminder dispatch
src/lib/reminders/send-due.ts - Reminder cron
src/app/api/cron/reminders/route.ts
Staff Portal
- Appointment dashboard
src/lib/portal/appointments.ts - Availability management
src/app/(portal)/availability/actions.ts - Availability view
src/app/(portal)/availability/page.tsx - Staff dashboard
src/app/(portal)/dashboard/page.tsx - Appointment board
src/app/(portal)/dashboard/KanbanBoard.tsx - Appointment actions
src/app/(portal)/dashboard/actions.ts - Patient inbox
src/app/(portal)/inbox/page.tsx - Thread detail
src/app/(portal)/inbox/[threadId]/page.tsx - Inbox actions
src/app/(portal)/inbox/actions.ts - Reply form
src/app/(portal)/inbox/ReplyForm.tsx - Thread data access
src/lib/portal/messages.ts
Data and Messaging
- Supabase database
- Staff authentication
src/lib/portal/auth.ts - RLS server client
src/lib/supabase/server.ts - Service-role client
src/lib/supabase/admin.ts - WhatsApp sending
src/lib/whatsapp/send.ts
Other components
- Patient
- WhatsApp / wacrm
Connections 36
- Patient → WhatsApp / wacrm: sends message
README.md - WhatsApp / wacrm → Inbound webhook: delivers webhook
src/app/api/whatsapp/inbound/route.ts - Inbound webhook → Clinic routing: resolves clinic
src/app/api/whatsapp/inbound/route.ts - Inbound webhook → Conversation session: loads session
src/app/api/whatsapp/inbound/route.ts - Inbound webhook → Contact lookup: resolves phone
src/app/api/whatsapp/inbound/route.ts - Inbound webhook → Message flow: dispatches text
src/app/api/whatsapp/inbound/route.ts - Message flow → Booking queries: reads booking data
src/lib/whatsapp/text-flow.ts - Booking queries → Slot generation: generates slots
src/lib/whatsapp/query.ts - Slot generation → Timezone conversion: converts times
src/lib/availability/slot-generation.ts - Message flow → Booking transaction: books appointment
src/lib/whatsapp/text-flow.ts - Inbound webhook → WhatsApp sending: sends response
src/app/api/whatsapp/inbound/route.ts - WhatsApp sending → WhatsApp / wacrm: sends WhatsApp
src/lib/whatsapp/send.ts - WhatsApp / wacrm → Patient: delivers reply
README.md - Booking transaction → Service-role client: uses service role
src/lib/booking/book.ts - Service-role client → Supabase database: reads and writes
src/lib/supabase/admin.ts - Slot generation → Service-role client: reads schedule
src/lib/availability/slot-generation.ts - Booking queries → Service-role client: queries records
src/lib/whatsapp/query.ts - Availability view → Availability management: submits changes
src/app/(portal)/availability/page.tsx - Availability view → Staff authentication: requires staff
src/app/(portal)/availability/page.tsx - Availability view → Timezone conversion: formats dates
src/app/(portal)/availability/page.tsx - Staff dashboard → Appointment dashboard: loads appointments
src/app/(portal)/dashboard/page.tsx - Staff dashboard → Staff authentication: requires staff
src/app/(portal)/dashboard/page.tsx - Staff dashboard → Appointment board: renders board
src/app/(portal)/dashboard/page.tsx - Appointment board → Appointment actions: submits transitions
src/app/(portal)/dashboard/KanbanBoard.tsx - Patient inbox → Thread data access: loads threads
src/app/(portal)/inbox/page.tsx - Thread detail → Thread data access: loads thread
src/app/(portal)/inbox/[threadId]/page.tsx - Thread detail → Reply form: renders reply
src/app/(portal)/inbox/[threadId]/page.tsx - Reply form → Inbox actions: submits reply
src/app/(portal)/inbox/ReplyForm.tsx - Inbox actions → Thread data access: checks thread
src/app/(portal)/inbox/actions.ts - Inbox actions → WhatsApp sending: sends staff reply
src/app/(portal)/inbox/actions.ts - Thread data access → RLS server client: uses RLS client
src/lib/portal/messages.ts - Staff authentication → RLS server client: uses auth client
src/lib/portal/auth.ts - RLS server client → Supabase database: queries RLS data
src/lib/supabase/server.ts - Reminder cron → Reminder dispatch: runs due reminders
src/app/api/cron/reminders/route.ts - Reminder dispatch → Service-role client: reads appointments
src/lib/reminders/send-due.ts - Reminder dispatch → WhatsApp sending: sends reminders
src/lib/reminders/send-due.ts