Skip to content

API Events

No Kafka. @platformatic/kafka is declared in package.json but there is no producer/consumer wiring in src/. All eventing is in-process (eventemitter3 EventBus) fanning out to BullMQ queues, with real-time fan-out over WebSocket. See ADR-0001.

1. Inbound — Kafka

None. The service consumes no Kafka topics.

2. Outbound — Kafka

None. The service produces no Kafka topics.

3. In-process Events (EventBus)

EventBus (eventemitter3) — emitted by TicketEmitter, handled by listeners in src/application/events/listeners/. Event types are TicketEventTypes (dotted strings) from @nx/core. Synchronous within the API process; listener failures are caught and logged (never crash the emitter).

Event typeEmitter methodListener(s)Side effects
ticket.createdTicketEmitter.ticketCreatedTicketCreatedListenerIncrement category/tag counts; enqueue context-enrichment + assignment jobs
ticket.status_changedTicketEmitter.ticketChangedStatusTicketStatusChangedListenerStatus side effects (notifications, survey trigger)
ticket.assignedTicketEmitter.ticketAssignedTicketAssignedListenerAssignment notifications
ticket.message.createdTicketEmitter.ticketMessageCreatedTicketMessageCreatedListenerReply notifications, SLA first-response marking

4. Inbound — BullMQ

Queues created by QueueComponent; consumed by workers in src/components/workers/ (worker process, RUN_MODE=worker). Concurrency from WORKER_CONFIG.

QueueJob name(s)ProducerWorker → Use-caseConcurrencyRetries
helpdesk.sla-monitorsla-monitorCron (repeatable) + manual triggersla-monitor.workerRunSlaMonitorUseCase12, fixed 60s
helpdesk.escalationescalation, escalation-batchsla-monitor / escalation managerescalation.workerProcessEscalationUseCase53, exp 5s (priority 1)
helpdesk.assignmentassignTicketCreatedListenerassignment.workerAutoAssignTicketUseCase53, exp 5s
helpdesk.notificationnotification, notification-batch, notification-digestmanynotification.workerProcessNotificationService105, exp 5s (priority 10)
helpdesk.context-enrichmentenrichTicketCreatedListenercontext-enrichment.workerEnrichTicketContextUseCase303, exp 5s
helpdesk.survey-triggersurvey-triggerstatus-changed flowsurvey-trigger.workerTriggerSurveyUseCase33, exp 10s

A helpdesk.analytics-update queue name (ANALYTICS_UPDATE) exists in QUEUE_NAME, but no worker/queue is wired for it. Failed jobs route to HandleDeadLetterUseCase via dlq.helper.ts.

5. Outbound — BullMQ

Jobs are enqueued via JobDispatcherHelper (publish / publishAll) and the typed job builders in src/shared/helpers/jobs/.

Job builderQueueTrigger
ContextEnrichmentJob.enrichcontext-enrichmentTicket created with context
AssignmentJob.assignassignmentTicket created (strategy LOAD_BALANCED)
NotificationJob.*notificationSLA warnings/breaches, assignment, replies, escalation
EscalationJob.*escalationSLA breach by sla-monitor
SurveyTriggerJob.*survey-triggerTicket resolved/closed
SLA monitor cronsla-monitorQueueComponent.scheduleSlaMonitoring() (jobId sla-monitor-cron)

6. WebSocket Emissions

Delivered by ApplicationWebSocketComponent + socket-event.service.ts. Topics/rooms built from @nx/core helpers.

TopicRoomTrigger
HelpdeskWebSocketTopics.HELP_DESK (observation/helpdesk)HelpdeskWebSocketRooms.getHelpdeskRooms({ ticketId, messageId }) (helpdesk/:ticketId/:messageId)New message / status change / assignment / SLA event

7. Payload Schemas

In-process event payloads are TS interfaces in src/shared/common/interfaces/ (not centralized message contracts, since there is no Kafka). Representative shapes:

ts
// ticket.created — ITicketCreatedEventData
interface ITicketCreatedEventData {
  ticketId: string;
  merchantId: string;
  categoryId: string;
  priority: TTicketPriorities;
  context?: Record<string, unknown>;
  categoryRouting?: unknown;
  metadata: { tagIds: string[]; [k: string]: unknown };
}

8. Idempotency & Ordering

ChannelGuaranteeOrderingRecovery
EventBusin-process, at-most-onceemit order, synchronousnone — listener errors logged, not retried
BullMQ jobsat-least-once (retries per queue)per-queue, no global orderretry w/ backoff → DLQ via HandleDeadLetterUseCase; worker idempotency helpers de-dupe
SLA cronexactly-one schedulen/afixed jobId: 'sla-monitor-cron' prevents duplicate repeatables

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.