Skip to content

Backend Realtime Chat Jobs

Ankit Upadhyay edited this page Jul 24, 2026 · 2 revisions

Backend: Realtime, Chat, Jobs

Chat, push notifications, and background automation. Architecture context: Realtime and Notifications. Part of Backend Overview.

Realtime here is Stream Chat + BullMQ, not Socket.IO. socket.io is an installed dependency but no Socket.IO server is wired; the Redis/Socket.IO event bus in docs/guide/realtime-backend.md is a design, not current code.

Chat (Stream Chat)

  • Router chat.router.ts (ChatController); webhook ChatWebhookController.handleStreamEvent at the raw-body route /v1/chat/webhooks/stream.
  • Services: chat.service.ts (StreamChat.getInstance, ChatServiceError, appointment chat windows), networkChat.service.ts (colleague/network chat), sharedChatEntity.service.ts.
  • Model chatSession.ts. Upload policy config/stream-upload-policy.ts pushes BLOCKED_UPLOAD_EXTENSIONS to Stream at boot.
  • The Support Chat plans add a SUPPORT session type on this same infrastructure.

Notifications

  • Routers: notification.router.ts (NotificationController), deviceToken.router.ts, marketing-unsubscribe.router.ts.
  • Services: notification.service.ts, deviceToken.service.ts, marketing-unsubscribe.service.ts, contact-us.service.ts; utils notificationTemplates.ts, org-usage-notifications.ts, email.ts, email-templates.ts.
  • Models: contect-us.ts (sic); notification and device-token entities are Prisma-only since PR #1819.
  • Delivery: mobile push via firebase-admin (FCM); email via AWS SES/Pinpoint. Setup: Notifications Setup.

Background jobs (BullMQ)

Config queues/bull.config.ts (redisConnection, defaultQueueOptions); orchestration queues/index.ts (initQueues()) and workers/index.ts.

Domain Queues / schedulers Workers
Appointments appointment.queue.ts (MARK_NO_SHOW), appointment.scheduler.ts appointment.worker.ts
Tasks task.queues.ts, task.schedulers.ts, task-schedule.queue.ts, task-schedule.scheduler.ts taskRecurrence/taskReminder/taskSchedule.worker.ts
Labs (IDEXX) idexx-reference.*, lab-status.*, lab-results.* idexx-reference/lab-status/lab-results.worker.ts

There is no central EventBus module; decoupling is via these BullMQ queues plus FinanceEventService for finance events.

Related

Product & Domain
Architecture
Applications
Design & Accessibility
Engineering Handbook
Decisions (ADRs)
Design Docs & Plans
Roadmap
Operations
Meta

Canonical code & docs: main repo · Auto-generated companion: DeepWiki

Clone this wiki locally