Skip to main content

Architecture: hbf-client-integrations

C4 Component Diagram

Key Flows

Bot action dispatched to a distributor

  1. A caller sends POST /<client>/:orgId/<action> with a Bearer JWT.
  2. HBFGuard validates the JWT against hbf-core.
  3. OrgMemberGuard confirms the token's org matches the :orgId path param.
  4. The distributor controller delegates to its service, which calls one or more ClientModule services.
  5. The service calls the relevant external API (REST, SOAP, SDK) and returns a structured response to the caller.

Dynamic module registration at startup

  1. AppModule.register() runs during bootstrap.
  2. ConfigService reads env vars to determine which databases are enabled (AIA, Novibet-Viber, Sixt).
  3. For each enabled database, a TypeOrmModule.forRootAsync connection and the corresponding feature module (AirportModule, NovibetViberModule, SixtModule) are added to the imports array.
  4. ClientModule.register(dbFeatures) conditionally adds AIA flight services and SITA AMS SOAP client when AIA is enabled.

Sixt driver greeting cron

  1. SixtGreetDriversCronService runs on a configurable cron schedule.
  2. It reads pending checkout records from the external Azure SQL view via WheelsysClientService.
  3. For each driver, it calls SixtGreetDriversService.processCheckoutGreeting(), which selects the highest-priority available channel (Viber BM, WhatsApp, or SMS) and dispatches the message via InfobipClientService.
  4. Infobip delivery and click webhooks arrive at POST /sixt/infobip/delivery-reports and POST /sixt/infobip/clicked-reports and update the greeting record status in the internal MySQL database.

AIA flight data sync cron

  1. FlightSyncService (scheduled via @nestjs/schedule) polls SITA AMS SOAP for upcoming and recent flights.
  2. FlightBuilderService transforms SOAP responses into TypeORM entities stored in the AIA MySQL database.
  3. A separate image-sync cron downloads flight-related images and uploads them to AWS S3.
  4. AirportsController serves flight data queries from the bot; FacebookMessageService sends proactive Messenger messages for flight notifications.