Busflow Docs

Internal documentation portal

Skip to content

Domain Events Catalog ​

Canonical registry of all cross-context domain events in the Busflow modular monolith. For architectural principles governing event communication, see domain-driven-design.md Β§4.


Event Registry ​

EventEmitterConsumerTrigger
PriceMatrixPublishedBackofficeCommerceprice_matrices.status β†’ PUBLISHED
SeasonPricingFinalizedBackofficeCommerceBatch completion β€” all PriceMatrices in a season published
TripPublishedBackofficeCommerceTourDeparture.status β†’ PUBLISHED
TripAssignedBackofficeOperationsLegAssignment created for a ServiceLeg
CrewScheduleUpdatedBackofficeOperationsLegAssignment modified
CrewMemberStatusChangedBackofficeOperationscrew_members.status mutated
CrewAbsenceApprovedBackofficeOperationscrew_absences.status β†’ APPROVED
VehicleStatusChangedBackofficeOperationsvehicles.status mutated
VehicleSwappedOperationsCommunicationsleg_assignments.vehicle_id updated via SwapVehicle action
BookingConfirmedCommerceBackoffice, Communicationsbookings.status β†’ DEPOSIT_PAID (ADR-009). Communications sends deposit confirmation (EMAIL + WHATSAPP).
BookingFullyPaidCommerceCommunicationsbookings.status β†’ FULLY_PAID (Mollie payment.paid for FINAL_PAYMENT). Note: InvoiceService.generateInvoice() + issueInvoice() are co-located in the same webhook handler (see invoice-service-protocol.md Β§Invoice Trigger), not a separate async consumer.
BookingCancelledCommerceCommunicationsbookings.status β†’ CANCELLED (dispatcher or passenger cancels). Operations manifest updates flow via PassengerCancelled events (fired per-passenger by the cancellation handler).
BookingRefundedCommerceCommunicationsbookings.status β†’ REFUNDED (Mollie refund.settled webhook)
BookingCompletedCommerceCommunicationsbookings.status β†’ COMPLETED (Hasura Scheduled Trigger: end_date + 24h)
BookingNoShowCommerceCommunicationsbookings.status β†’ NO_SHOW (Hasura Scheduled Trigger: end_date + 48h, no BoardingEvent)
CheckoutAbandonedCommerceCommunicationscheckout_sessions.status β†’ EXPIRED (Hasura Scheduled Trigger: checkout_abandoned_sweep)
FinalPaymentDueCommerce (Scheduled)Communicationsdeparture_date - reminder_days_before_start for bookings in DEPOSIT_PAID (operator-configurable)
FinalPaymentOverdueCommerce (Scheduled)Communications, Backoffice (dispatcher notification)departure_date - flag_days_before_start ≀ now() for DEPOSIT_PAID bookings with no FINAL_PAYMENT
SeatHoldExpiredCommerce (Scheduled)Commerce (self)hold_expires_at < now() for HELD reservations (seat_hold_cleanup trigger)
PassengerCancelledCommerceCommerce (seat release, ticket void, refund), CommunicationsPassenger removed from active booking
AncillaryCancelledCommerceCommunicationsAncillary removed from active booking
PassengerAddedCommerceCommerce (supplementary payment), Communications, Operations (manifest)New passenger added to active booking
PassengerUpdatedCommerceOperations (manifest)Passenger details changed on active booking
PaymentReceivedCommerceCommerce (FinancialLedger), BackofficeMollie webhook β†’ payment captured
InvoiceIssuedCommerce (InvoiceService)DATEV Export Service, Communicationsinvoices.status β†’ ISSUED (see invoice-service-protocol.md Β§issueInvoice)
FinancialLedgerClosedCommerceDATEV Export Service, Communicationsfinancial_ledgers.status β†’ CLOSED
VehicleMaintenanceRequiredOperationsBackofficeissue_reports.maintenance_urgency = IMMEDIATE
IncidentCreatedOperationsCommunications, Backoffice (dispatch board)incidents row INSERT. Payload includes severity and type. Communications consumer routes uniformly: CRITICAL (any type: DELAY, BREAKDOWN, PASSENGER_ISSUE) β†’ WhatsApp broadcast (with dispatcher approval); LOW/MEDIUM β†’ dispatch board alert only. DELAY incidents are auto-created by the system when ServiceLegDelayed fires and no driver-reported Incident exists. See event-contracts-operations.md Β§Incident.
IncidentResolvedOperationsCommunicationsincidents.status β†’ RESOLVED
IssueReportCreatedOperationsBackoffice (dispatch board feed)issue_reports row INSERT
BoardingConflictDetectedOperations (sync handler)Communications (dispatcher notification)Server-side validation overrides client-side check_in_status on sync (stale ticket, cancelled booking, duplicate QR across legs). See schema-operations.md Β§Server-Side Boarding Sync Handler.
VehicleInspectionScheduledBackofficeOperationsvehicle_inspections row INSERT in response to VehicleMaintenanceRequired. Operations consumer sets linked IssueReport.status β†’ IN_PROGRESS.
VehicleInspectionCompletedBackofficeOperationsvehicle_inspections.status β†’ COMPLETED. Operations consumer sets linked IssueReport.status β†’ RESOLVED.
ServiceLegStartedOperationsCommunications, Backoffice (dispatch board)service_legs.status β†’ ACTIVE
ServiceLegCompletedOperationsCommerce (NoShow window), Communications, Backofficeservice_legs.status β†’ COMPLETED
ServiceLegDelayedOperationsBackoffice (dispatch board)service_legs.status β†’ DELAYED. Auto-creates a system DELAY Incident if no driver-reported one exists β†’ IncidentCreated fires β†’ Communications broadcasts.
ServiceLegDelayResolvedOperationsBackoffice (dispatch board)service_legs.status DELAYED β†’ ACTIVE (ETA recovery). Auto-resolves linked system-created DELAY Incident β†’ IncidentResolved fires β†’ Communications sends all-clear.
ServiceLegCancelledOperationsCommerce (seat release), Communications (passenger notification), Backofficeservice_legs.status β†’ CANCELLED
OnboardSaleRecordedOperationsCommerce (FinancialLedger)onboard_sales INSERT/UPDATE with sale_status = ACTIVE AND payment_status = PAID
OnboardSaleVoidedOperationsCommerce (FinancialLedger)onboard_sales UPDATE where sale_status β†’ VOIDED. Carries original amount as negative so FinancialLedger subtracts from realized_expense.
OnboardSaleRefundedOperationsCommerce (FinancialLedger)onboard_sales UPDATE where sale_status β†’ REFUNDED. For PAYMENT_LINK/CARD_READER sales, Commerce initiates Mollie refund API. For CASH, bookkeeping correction only.
ExpenseSubmittedOperationsCommerce (FinancialLedger)expense_receipts.ocr_status β†’ VERIFIED
OnboardPaymentCompletedCommerceOperationsMollie webhook payment.paid for a CheckoutSession linked to an OnboardSale (checkout_session_id)
OnboardPaymentExpiredCommerceOperationscheckout_abandoned_sweep expires an OnboardSale-linked CheckoutSession (status β†’ EXPIRED where metadata.payment_type = 'ONBOARD_SALE'). Operations sets payment_status β†’ FAILED, notifies driver.
OnboardPaymentOrphanedOperationsBackoffice (dispatch board)OnboardPaymentCompleted received for a VOIDED OnboardSale. Payload: { onboard_sale_id, checkout_session_id, amount_paid, auto_refund_initiated: boolean }. Dispatcher alert β€” money received for voided sale.
QualificationExpiringBackoffice (Scheduled)Communicationscrew_qualifications.expiry_date within threshold
VehicleInspectionOverdueBackoffice (Scheduled)Communicationsvehicle_inspections.due_date < now() AND completed_date IS NULL
TenantProvisionedBackofficeBackoffice (async workers)operators row inserted with status = ONBOARDING (ADR-003)
TenantActivatedBackofficeβ€” (logging only, MVP)operators.status β†’ ACTIVE (first login, via Nhost last_seen)
TenantSuspendedBackofficeCommerceoperators.status β†’ SUSPENDED. Payload: { operator_id, reason }
TenantReactivatedBackofficeCommerceoperators.status SUSPENDED β†’ ACTIVE. Payload: { operator_id }
TenantChurnedBackofficeCommerceoperators.status β†’ CHURNED. Payload: { operator_id, reason }

Payload Contracts ​

Dedicated protocol documents specify the formal payload schemas, delivery mechanisms, and idempotency contracts:

EventsContract Document
PriceMatrixPublished, SeasonPricingFinalized, BookingConfirmedevent-contracts-pricing.md
BookingConfirmedΒΉ, BookingFullyPaid, BookingCancelled, BookingRefunded, BookingCompleted, BookingNoShow, PaymentReceived, CheckoutAbandoned, FinalPaymentDue, FinalPaymentOverdue, SeatHoldExpired, PassengerCancelled, AncillaryCancelled, PassengerAdded, PassengerUpdated, FinancialLedgerClosed, InvoiceIssuedevent-contracts-commerce.md
VehicleSwappedvehicle-swap-protocol.md
ServiceLegStarted, ServiceLegCompleted, ServiceLegDelayed, ServiceLegDelayResolved, ServiceLegCancelled, IncidentCreated, IncidentResolvedevent-contracts-operations.md
VehicleMaintenanceRequired, IssueReportCreated, VehicleInspectionScheduled, VehicleInspectionCompletedevent-contracts-operations.md Β§IssueReport Lifecycle Events
QualificationExpiringcrew-qualification-protocol.md
OnboardSaleRecorded, OnboardSaleVoided, OnboardSaleRefunded, ExpenseSubmitted, OnboardPaymentCompleted, OnboardPaymentExpiredStandard Hasura Event Trigger pattern (see note below)
OnboardPaymentOrphanedHandler-emitted (see note below)

NOTE

Events without a dedicated contract document use the standard Hasura Event Trigger delivery pattern defined in domain-driven-design.md Β§4. All consumers implement at-least-once processing with event_id-based deduplication.

NOTE

Handler-emitted events fire programmatically from within a NestJS event handler, not from a Hasura Event Trigger on a table mutation. OnboardPaymentOrphaned fires inside the OnboardPaymentCompleted handler (Operations consumer) when the handler detects sale_status = VOIDED. The system dispatches the event via the NestJS EventEmitter (or equivalent async bus), not via a database trigger. Same at-least-once / event_id deduplication contract applies.

ΒΉ Both event-contracts-pricing.md and event-contracts-commerce.md document the BookingConfirmed payload.

Internal documentation β€” Busflow