How eliasasa/whatsapp-barber-booking works
WhatsApp Barber Booking is a barbershop appointment backend with two main entry points: customers message the bot to browse services, check availability, and book or cancel; administrators use authenticated APIs to manage appointments, clients, availability, services, bot controls, and WAHA sessions. The webhook processor filters incoming messages and dispatches conversation handling; the admin API routes operations to authentication and domain services. The README documents additional admin capabilities whose route internals were not sampled, so those are represented at the routes-directory level.
Main entry points: prisma.ts PostgreSQL data access · app.ts HTTP application · processWebhook.ts Webhook processor · routes Admin API routes
Components 27
Application entry
- HTTP application
src/app.ts - Webhook endpoint
src/routes/webhook.ts - Webhook processor
src/whatsapp/processWebhook.ts
WhatsApp conversations
- Conversation handler
src/whatsapp/core/handler.ts - Conversation state
src/whatsapp/conversation/conversationStore.ts - Bot conversation flows
src/whatsapp/flows - Availability flow
src/whatsapp/flows/availabilityFlow.ts - Services flow
src/whatsapp/flows/servicesFlow.ts
Admin operations
- Admin API routes
src/routes - Authentication routes
src/routes/auth.ts - Admin authentication
src/middleware/requireAdminAuth.ts - Admin identity service
src/services/auth/authService.ts - Login rate limiter
src/middleware/loginRateLimiter.ts - Client management routes
src/routes/clients.ts - Broadcast service
src/services/broadcast/broadcastService.ts - Bot state service
src/services/botState/botStateService.ts - Bot message service
src/services/botMessages/botMessageService.ts
Booking domain
- Client service
src/services/clients/clientService.ts - Appointment services
src/services/appointments - Available slots service
src/services/availability/ListAvailableSlotsService.ts - Service catalog
src/services/catalog
Persistence and integrations
- PostgreSQL data access
src/lib/prisma.ts - WhatsApp client
src/whatsapp/wahaClient.ts - WAHA admin client
src/whatsapp/wahaAdminClient.ts
Other components
- WhatsApp customer
- Admin user
- WAHA
Connections 39
- Admin user → HTTP application: calls API
README.md - WhatsApp customer → WAHA: sends messages
README.md - WAHA → Webhook endpoint: posts events
README.md - HTTP application → Admin API routes: mounts routes
src/app.ts - HTTP application → Authentication routes: mounts routes
src/app.ts - HTTP application → Client management routes: mounts routes
src/app.ts - HTTP application → Webhook endpoint: mounts route
src/app.ts - HTTP application → Broadcast service: mounts broadcast route
src/app.ts - Authentication routes → Admin identity service: delegates auth
src/routes/auth.ts - Authentication routes → Admin authentication: protects endpoints
src/routes/auth.ts - Authentication routes → Login rate limiter: limits login
src/routes/auth.ts - Admin authentication → Admin identity service: verifies admin
src/middleware/requireAdminAuth.ts - Admin identity service → PostgreSQL data access: reads admin records
src/services/auth/authService.ts - Admin API routes → Admin authentication: protects operations
README.md - Admin API routes → Appointment services: manages appointments
README.md - Admin API routes → Available slots service: queries slots
README.md - Admin API routes → PostgreSQL data access: accesses records
src/routes/services.ts - Client management routes → Client service: delegates client work
src/routes/clients.ts - Client service → PostgreSQL data access: reads and writes clients
src/services/clients/clientService.ts - Client service → WhatsApp client: resolves chat IDs
src/services/clients/clientService.ts - Webhook endpoint → Webhook processor: processes event
src/routes/webhook.ts - Webhook processor → Client service: checks client block
src/whatsapp/processWebhook.ts - Webhook processor → Bot state service: checks pause state
src/whatsapp/processWebhook.ts - Webhook processor → Conversation handler: dispatches message
src/whatsapp/processWebhook.ts - Webhook processor → Conversation state: updates conversation
src/whatsapp/processWebhook.ts - Webhook processor → WhatsApp client: sends replies
src/whatsapp/processWebhook.ts - Conversation handler → Conversation state: reads and updates state
src/whatsapp/core/handler.ts - Conversation handler → Bot conversation flows: dispatches flows
src/whatsapp/core/handler.ts - Availability flow → Conversation state: updates flow state
src/whatsapp/flows/availabilityFlow.ts - Availability flow → Available slots service: queries slots
src/whatsapp/flows/availabilityFlow.ts - Services flow → Conversation state: updates flow state
src/whatsapp/flows/servicesFlow.ts - Services flow → Service catalog: lists services
src/whatsapp/flows/servicesFlow.ts - Appointment services → PostgreSQL data access: persists appointments
src/services/appointments/createAppointmentService.ts - Available slots service → PostgreSQL data access: reads availability data
src/services/availability/ListAvailableSlotsService.ts - Service catalog → PostgreSQL data access: reads catalog
src/services/catalog/ListServicesService.ts - Broadcast service → PostgreSQL data access: records broadcasts
src/services/broadcast/broadcastService.ts - Broadcast service → WhatsApp client: sends campaigns
src/services/broadcast/broadcastService.ts - WAHA admin client → WAHA: controls sessions
README.md - Bot message service → PostgreSQL data access: reads message config
src/services/botMessages/botMessageService.ts