Skip to content

Helpdesk Service

@nx/helpdesk is the customer-support microservice for the BANA platform. It owns the ticket lifecycle, SLA tracking and auto-escalation, rule-based agent assignment, a knowledge base, satisfaction surveys, and templated multi-channel notifications. It is a VerifierApplication that depends only on @nx/core and processes background work via BullMQ workers and an in-process event bus.

1. Quick Reference

PropertyValue
Package@nx/helpdesk
CodeSVC-00120-HELPDESK
TypeMicroservice
RuntimeBun
Base ClassVerifierApplication
Locationpackages/helpdesk
Base Path/v1/api/helpdesk
Dev Port31130
Container Port3000 (external 31130)
Snowflake ID12
DB Schemahelpdesk (30 tables)
Rolesapi, worker (RUN_MODE=worker)
Binding Namespace@nx/helpdesk
Ownersupport-team

Identity source of truth: src/resources/app-info.json (returned by getAppInfo()). The values above come from there. .env.development now carries the matching APP_ENV_APPLICATION_CODE=SVC-00120-HELPDESK (the earlier SVC-00030-HELPDESK collision with sale is resolved). Remaining drift to reconcile: APP_ENV_SERVER_PORT=31032 and APP_ENV_SNOWFLAKE_WORKER_ID=0. See Configuration.

Known issue: this package's TypeScript build currently fails (dead assignTicketUseCase reference path). See Operations → Known Issues.

2. Purpose & Scope

IncludedExcluded
Ticket management (lifecycle, messages, attachments, events)Issuing JWTs / identity (handled by @nx/identity)
SLA tracking, warning, breach, auto-escalationOrder/payment processing (read-only context from @nx/core)
Rule-based auto-assignment (agents, agent groups)Inventory and pricing logic
Knowledge base (articles, categories, views, feedback)Cross-service event bus (no Kafka wiring; in-process only)
Satisfaction surveys + feature-request voting
Templated, batched notifications (email + WebSocket)

3. Tech Stack

External:

LibraryPurpose
@venizia/ignisIoC container, DI, base application/controller/service, components
@venizia/ignis-helpersRedis helper, TConstValue, TNullable, shared utilities
honoHTTP server framework (via IGNIS)
drizzle-ormDB access via PostgresCoreDataSource
pgPostgreSQL driver
bullmqBackground job queues + workers
ioredisRedis client (cache + BullMQ connection)
eventemitter3In-process event bus
xstateTicket-status state machine
nodemailerEmail delivery
slugifyArticle/category slug generation
zodRequest/response schema validation
lodashUtilities

@platformatic/kafka is declared in package.json but dead — there is no Kafka producer/consumer in src/. See API Events.

Internal:

PackagePurpose
@nx/coreOnly @nx/* dependency. Provides VerifierApplication, PostgresCoreDataSource, createAppConfig, bootstrapApplication, centralized Drizzle schemas/models, ProductRepository + SaleOrderRepository (for context enrichment), assertMerchantAccess, useRequestContext, ActorTypes, WebSocket/topic builders, ticket enums (TicketStatuses, TicketEventTypes, TicketPriorities).

4. Project Structure

packages/helpdesk/
├── src/
│   ├── application.ts            # HelpdeskApplication (VerifierApplication)
│   ├── index.ts                  # Entry → bootstrapApplication()
│   ├── migrate.ts                # Migration entry → bootstrapMigration()
│   ├── application/
│   │   ├── use-cases/            # Business logic (DI-registered services)
│   │   ├── services/             # Plain services (notification, compensation, …)
│   │   ├── events/               # In-process emitters + listeners
│   │   └── validators/           # AgentValidator
│   ├── components/
│   │   ├── event-bus/            # EventBusComponent (eventemitter3)
│   │   ├── queue.component.ts    # BullMQ queues + SLA cron scheduler
│   │   ├── workers/              # 6 BullMQ workers
│   │   ├── mail/                 # NodemailerComponent
│   │   └── websocket/            # ApplicationWebSocketComponent
│   ├── controllers/              # 11 REST controllers
│   ├── datasources/              # PostgresCoreDataSource binding
│   ├── models/requests/          # Zod request schemas
│   ├── repositories/             # Repository classes (schemas live in @nx/core)
│   ├── migrations/processes/     # Migration processes
│   ├── resources/                # app-info.json + email templates
│   └── shared/                   # common (keys, paths, constants), helpers, utils
├── package.json
└── tsconfig.json

5. Architecture

Detail: see Architecture.

6. Domain Snapshot

Full ERD + per-entity tables: see Domain Model.

7. Surface Summary

REST controllers (full reference rendered live from /v1/api/helpdesk/doc/openapi.json):

ControllerBase path (RestPaths)Notes
TicketController/ticketsFull ticket lifecycle, messages, assignment
AgentController/agentsSupport agent management
AgentGroupController/agent-groupsAgent groups + members
TicketCategoryController/ticket-categoriesTicket categories
TicketTagController/ticket-tagsTags + ticket-tag mappings
SlaController/sla-policiesSLA policies
ArticleController(articles)Knowledge base articles
ArticleCategoryController(article categories)Article categories
AssignmentRuleController/assignment-rulesAuto-assignment rules
FeatureRequestController(feature requests)Feature requests + voting
SurveyController(surveys)Satisfaction surveys

Live spec: /v1/api/helpdesk/doc/openapi.json. REST tables are intentionally not hand-maintained.

Async surface (full reference in API Events):

ChannelCount
Kafka in/out0 (dead dep)
In-process events (EventBus)ticket created / status-changed / assigned / message-created
BullMQ queues6 (SLA monitor, escalation, assignment, notification, context-enrichment, survey-trigger)
WebSocket emissionshelpdesk observation topic

8. Components

ComponentFilePurpose
Cache RedisuseCacheRedis()BindingKeys.APPLICATION_REDIS_CACHERedis for cache + BullMQ connection
QueueComponentsrc/components/queue.component.tsCreates 6 BullMQ queues; schedules SLA-monitor cron
EventBusComponentsrc/components/event-bus/component.tsIn-process eventemitter3 bus + handler registry
NodemailerComponentsrc/components/mail/component.tsSMTP email delivery
WorkerComponentsrc/components/workers/worker.component.tsRegisters and runs the 6 BullMQ workers
ApplicationWebSocketComponentsrc/components/websocket/component.tsReal-time WebSocket delivery

9. Services

Business logic lives in use-cases (src/application/use-cases/*, registered as DI services). Plain services below provide shared cross-cutting helpers.

ServiceFileOne-liner
FileStorageHelpersrc/shared/helpers/file-storage.helper.tsAttachment storage helper
PermissionServicesrc/application/services/permission.service.tsHelpdesk permission checks
CompensationCalculatorServicesrc/application/services/compensation-calculator.service.tsSLA-breach compensation matrix
EscalationJobManagerServicesrc/application/services/escalation-job-manager.service.tsSchedules/manages escalation jobs
ProcessNotificationServicesrc/application/services/notification/process-notification.service.tsResolves + dispatches notifications
NotificationBatchServicesrc/application/services/notification/notification-batch.service.tsBatches/digests notifications
AgentValidatorsrc/application/validators/agent.validator.tsAgent input validation

Use-cases are grouped by domain: Agent, Agent Group, Assignment, Assignment Rule, Article, Article Category, Feature Request, SLA, SLA Policy, Survey, Survey Question, Ticket, Ticket Category, Ticket Tag, plus HandleDeadLetterUseCase. See src/application.ts configureServices() for the registered set.

10. Repositories

All Drizzle schemas/models are centralized in @nx/core (packages/core/src/models/schemas/helpdesk/). This package declares repository classes only.

GroupRepositories
TicketTicketRepository, TicketMessageRepository, TicketEventRepository, TicketAssignmentRepository, TicketCategoryRepository, TicketTagRepository, TicketTagMappingRepository
AgentAgentRepository, AgentGroupRepository, AgentGroupMemberRepository
SLASlaPolicyRepository, SlaTrackerRepository, SlaEscalationRepository
Knowledge baseArticleRepository, ArticleCategoryRepository, ArticleViewRepository, ArticleFeedbackRepository
Survey & featureSurveyRepository, SurveyQuestionRepository, SurveyResponseRepository, FeatureRequestRepository, FeatureVoteRepository
NotificationNotificationRepository, NotificationTemplateRepository, NotificationPreferenceRepository, NotificationDeliveryLogRepository, NotificationBatchRepository
OtherAssignmentRuleRepository, CompensationRepository, MetaLinkRepository, JobExecutionLogRepository, UserRepository, OrganizerRepository
From @nx/coreProductRepository, SaleOrderRepository (read-only context enrichment)

11. Entry Points

FilePurpose
src/index.tsService entry → bootstrapApplication({ ApplicationClass: HelpdeskApplication })
src/migrate.tsMigration entry → bootstrapMigration()
src/application.tsHelpdeskApplication extending VerifierApplication

Run mode selected via RUN_MODE (startup API / worker / migrate).

12. Configuration

Env vars + feature flags + seeded data: see Configuration.

13. Operations

Deployment + observability + security + runbook + known issues: see Operations.

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