How santin0-dev/kalqueue works
KalQueue is a staged clinic-visit and records system. Its principal workflow runs from patient intake and booking through queue tracking, doctor call-in and consultation, then to a saved record and patient history. Patients, doctors, and admins have distinct operational views; admins also manage announcements, reports, and backups. The queue engine is the central internal layer, coordinating ticket state, position estimates, notifications, and realtime updates. Relationships not visible in sampled code are included only where the README documents them; unsampled page behavior is not independently verified.
Main entry points: prisma.ts Clinic database · page.tsx Operations dashboard · queue-engine.ts Queue engine · server.py Local AI charting
Components 27
Patient journey
- Patient dashboard
src/app/patient/dashboard/page.tsx - Booking and intake
src/app/patient/book/page.tsx - Intake submission
src/app/api/intake/route.ts - Queue tracking
src/app/patient/queue/page.tsx - Checkup history
src/app/patient/history/page.tsx - Patient notifications
src/app/patient/notifications/page.tsx
Clinic operations
- Doctor queue
src/app/doctor/queue/page.tsx - Consultation records
src/app/doctor/dashboard/page.tsx - Doctor availability
src/app/api/doctors/availability/route.ts - Queue API
src/app/api/queue/route.ts - Queue engine
src/lib/queue-engine.ts
Administration
- Operations dashboard
src/app/admin/dashboard/page.tsx - Records management
src/app/api/admin/records/route.ts - Reports and downloads
src/app/api/admin/reports/download/route.ts - Backup downloads
src/app/api/admin/backups/route.ts
Shared services
- Role-based auth
src/lib/auth.ts - Clinic database
src/lib/prisma.ts - Notification service
src/lib/notifications.ts - Realtime updates
src/lib/pusher.ts
AI charting
- Local AI charting
local-ai-service/server.py
Other components
- Patient
- Doctor
- Admin
- Pusher
- Twilio SMS
- Whisper transcription
- Ollama chart formatting
Connections 31
- Patient → Booking and intake: books visit
- Booking and intake → Intake submission: submits intake
- Intake submission → Clinic database: writes intake
src/app/api/intake/route.ts - Patient → Queue tracking: tracks position
- Queue tracking → Queue API: requests queue
- Queue API → Queue engine: gets or creates
src/app/api/queue/route.ts - Queue engine → Clinic database: reads and writes
src/lib/queue-engine.ts - Queue engine → Realtime updates: broadcasts updates
src/lib/queue-engine.ts - Realtime updates → Pusher: publishes events
- Queue engine → Notification service: sends updates
src/lib/queue-engine.ts - Notification service → Twilio SMS: sends SMS
- Patient → Patient dashboard: views visit
- Patient dashboard → Checkup history: views history
- Patient dashboard → Patient notifications: views alerts
- Doctor → Doctor queue: monitors queue
- Doctor queue → Queue API: loads queue
- Doctor → Consultation records: completes consultation
- Consultation records → Clinic database: saves record
- Doctor → Doctor availability: sets availability
- Admin → Operations dashboard: monitors clinic
- Operations dashboard → Records management: manages records
- Operations dashboard → Reports and downloads: downloads reports
- Operations dashboard → Backup downloads: downloads backups
- Records management → Clinic database: reads and writes
src/app/api/admin/records/route.ts - Reports and downloads → Clinic database: reads records
src/app/api/admin/reports/download/route.ts - Backup downloads → Clinic database: reads data
src/app/api/admin/backups/route.ts - Operations dashboard → Role-based auth: uses role access
- Consultation records → Local AI charting: requests charting
- Local AI charting → Whisper transcription: transcribes audio
- Local AI charting → Ollama chart formatting: formats transcript
- Local AI charting → Consultation records: returns draft