Developer Resourcesconsultation
Consultation Module Feature List
Consultation booking module features, admin slot management, and customer booking flows.
Consultation Module - Feature List
1. Overview
Consultation module provides consultation slot management and booking capabilities.
- Admin manages slot availability and booking follow-up status.
- Customers can discover open slots and submit booking requests.
- Booking notifications are queued to the notifications runtime.
2. Exposed Routes
| Surface | Route prefix |
|---|---|
| Admin slots | /api/admin/consultations/slots |
| Admin bookings | /api/admin/consultations/bookings |
| Customer API | /api/consultations |
| Mobile-composed customer API | /api/mobile/consultations |
3. Core Features
| Feature | Behavior |
|---|---|
| Slot inventory | Date/time slot records with active toggle and unique (date, start_time) |
| Booking capture | One booking per slot (consultation_booking_slot_uq) |
| Bulk slot generation | Interval-based slot generation from weekday/date range input |
| Booking state | pending -> contacted |
| Guest + auth support | Public booking accepts guest payload; logged-in booking links customer_id |
Data integrity guardrails:
- Slot deletion restricted when a booking exists (
ON DELETE RESTRICT+ service guard). - Slot time check enforced (
start_time < end_time). - Booking contacted-state check enforced by DB constraint.
4. Admin Features
- list/detail consultation slots
- create consultation slots in bulk from day-pattern + interval
- update/delete consultation slots
- toggle slot active/inactive status
- list/detail bookings
- update booking status to
contacted
5. Customer Features
- view available consultation slots (
GET /consultations/slots) - book a consultation slot as guest or logged-in user (
POST /consultations/book) - view own booking history when authenticated (
GET /consultations/bookings)
6. State Models
6.1 Slot lifecycle state
6.2 Booking state model
6.3 Customer booking journey
7. Queue/Worker Features
7.1 Notification Jobs
Queued on booking success:
| Job Type | Trigger | Dedup Key |
|---|---|---|
notification.send_email | Booking created (always) | consultation:booking:{bookingId}:email |
notification.send_push | Booking created when customerId present | consultation:booking:{bookingId}:push:{customerId} |
Payload includes slot date/time summary for email templates.
8. Cache Features
| Keyspace | Prefix |
|---|---|
| Customer slot list | consultation:customer:slots:list: |
- Keys are built with
CacheKeyUtil.build(...). - Slot-write and booking-write paths invalidate
consultation:customer:slots:list:*. - Cache failures degrade gracefully (warn + DB fallback).
9. Rate Limiting
Redis-backed request limits protect:
- customer slot listing
- customer booking creation
- customer booking history
- admin slot and booking operations
Limit/rate-window values are sourced from environment configuration and fail-open on Redis errors with warning logs.
10. Environment Variables
CONSULTATION_PUBLIC_BOOK_RATE_LIMIT(default10)CONSULTATION_PUBLIC_BOOK_RATE_WINDOW_SECONDS(default60)CONSULTATION_SLOTS_CACHE_TTL_SECONDS(default300)
11. Error UX Mapping
| Scenario | API behavior | Recommended UI |
|---|---|---|
| Slot not found | 404 CONSULTATION_SLOT_NOT_FOUND | Show "Slot not available" toast |
| Slot inactive | 400 CONSULTATION_SLOT_INACTIVE | Show "This slot is no longer available" |
| Slot in past | 400 CONSULTATION_SLOT_PAST_DATE | Show "Cannot book past dates" |
| Slot already booked | 400 CONSULTATION_SLOT_ALREADY_BOOKED | Show "This slot is already booked" |
| Delete slot with booking | 400 CONSULTATION_BOOKING_SLOT_RESTRICTED | Show "Cannot delete slot with bookings" |
| Rate limit exceeded | 429 RATE_LIMIT_EXCEEDED | Show "Please wait" with backoff |
| Booking not found | 404 CONSULTATION_BOOKING_NOT_FOUND | Show "Booking not found" toast |
| Duplicate slot | 409 CONSULTATION_SLOT_CONFLICT | Show "Slot already exists" error |
12. Release/QA Checklist
- Verify admin slot CRUD operations resolve permissions correctly
- Verify bulk slot generation creates correct slots
- Verify booking flow blocks inactive/past/booked slots
- Verify booking status update to contacted works
- Verify slot cache invalidates on writes
- Verify notification jobs are enqueued
- Verify mobile routes resolve correctly
- Verify rate limiting returns 429 on breach
- Verify guest booking works without JWT
13. Data Flow
14. Integration Flows
14.1 Booking Flow
A customer books a consultation slot as guest or authenticated user.
- Customer calls
GET /api/consultations/slots(orGET /api/mobile/consultations/slots) to browse available slots. - System filters slots by date range and returns only active, future, unbooked slots.
- Customer selects a slot and calls
POST /api/consultations/book(orPOST /api/mobile/consultations/book) with slot details. - System validates: slot exists, is active, is in the future, and is not already booked.
- If customer is authenticated (JWT), system links
customer_idto booking. - If guest, system stores guest contact fields (name, email, phone) without customer_id.
- System creates
consultation_bookingwith statuspending. - System enqueues email notification job to send booking confirmation.
- If customerId exists, system enqueues push notification job.
- System invalidates slot list cache
consultation:customer:slots:list:*. - Customer can view their bookings via
GET /api/consultations/bookings(authenticated only).
14.2 Admin Slot Management Flow
An admin creates and manages consultation slots for booking.
- Admin calls
POST /api/admin/consultations/slots/bulkwith date range, interval, and time constraints. - System parses weekday patterns and date range to generate slot time entries.
- System validates no duplicate slots exist for each
(date, start_time)pair. - System inserts multiple
consultation_slotrecords withisActive = true. - Admin can view all slots via
GET /api/admin/consultations/slots. - Admin can update a slot (e.g., deactivate) via
PATCH /api/admin/consultations/slots/:id. - If slot has an existing booking, system blocks deletion (returns error).
- Admin can view bookings via
GET /api/admin/consultations/bookings. - Admin updates booking status to
contactedviaPATCH /api/admin/consultations/bookings/:id.
Time fields in this module are stored as timezone-aware values and should be handled as ISO-8601 instants by API consumers.
See Also
- API Reference: See Consultation - API & Integration Guide Section 7 (Endpoint Reference + Payload Cheatsheet) for complete request/response DTOs.
- Backend Reference: See Consultation - Backend Documentation Section 3 (Data Model) for schema details.