Skip to content

Business Process Management Specification (BPM_SPEC)

Project: PTX Channel Manager (ptx-cm)
Version: 1.0.0
Date: 2026-03-02
Standard: ISO 19510:2013 (BPMN 2.0) — Practical Modeling
Related: SRD.md | UI_SPEC.md | system-architecture.md


1. Scope & ISO 19510 Reference

1.1 Purpose

This document models all PTX-CM operational processes using Business Process Model and Notation (BPMN 2.0) concepts as defined in ISO 19510:2013. Processes are visualized as Mermaid diagrams for inline rendering.

1.2 Compliance Level

Practical modeling — not strict XML compliance. We use BPMN concepts (tasks, gateways, events, lanes) for documentation and visualization. The runtime engine is a custom TypeScript state machine (NestJS), not a BPMN XML executor.

1.3 Diagram Notation Convention

ShapeMermaid SyntaxBPMN ElementDescription
Rounded rect([text])User TaskManual action requiring human input
Rectangle[text]Service TaskAutomated system action
Diamond{text}Exclusive Gateway (XOR)Decision point, one path taken
Circle((text))Start/End EventProcess boundary
Subgraphsubgraph NamePool/LaneActor or system grouping
Dashed arrow-.->Message/SignalCross-process trigger
Bold arrow==>Critical pathPrimary happy path

2. ISO 19510 Concept Mapping

BPMN ElementISO 19510 TypePTX-CM ImplementationComponent
PoolParticipantSystem boundary (PTX-CM)NestJS application
LaneParticipantActor role (U-01–U-07)RBAC PermissionsGuard
User TaskActivityUI action: button click, form submitReact component + API call
Service TaskActivityBullMQ job or hook executionBookingHooksService, SyncEngine
Script TaskActivityInternal computationAvailabilityCalc, DeduplicationLogic
Exclusive GatewayGatewayTransition validation + role checkBookingStatusTransition.allowedRoles
Parallel GatewayGatewayConcurrent hook executionPromise.all(hooks) in BookingHooksService
Timer Start EventEventBullMQ repeatable job schedulePollingScheduler (every 2-3 min)
Error Boundary EventEventTry/catch → Alert creationSyncJob.status=failed → E-11 Alert
Message Intermediate EventEventNotification dispatchsend_notification hook (email/LINE)
Signal EventEventSystem-wide broadcastOverbooking detection → Alert + Dashboard
Start EventEventProcess triggerAPI request, BullMQ job trigger, user action
End Event (terminate)EventTerminal statusBookingStatusDef.isTerminal=true
Data ObjectDataEntity (E-xx)Prisma model
Data StoreDataPostgreSQL table / Redis cacheDatabase layer

3. Process Catalog

IDProcessComplexityTriggerActorsRelated FR
P-01Booking LifecycleHighOTA sync / manual actionSystem, U-04, U-05, U-01/02FR-03, FR-25–FR-30, FR-41
P-02OTA Sync PipelineMediumTimer (BullMQ)SystemFR-03, FR-04
P-03Alert ResolutionLowSystem alert creationU-04, U-05, U-01/02FR-07
P-04Customer ManagementLowCS manual actionU-05, U-01/02FR-36–FR-38
P-05OTA OnboardingMediumAdmin actionU-01/02FR-01, FR-02
P-06Property SetupMediumAdmin/import actionU-01/02, U-04FR-05, FR-31–FR-32

4. Process Definitions

P-01: Booking Lifecycle

Trigger: New booking detected via OTA sync OR manual status change
Entities: E-08 (Booking), E-07 (Availability), E-12 (AuditLog), E-15 (Transition), E-20 (OtaStatusDef)

Steps:

#BPMN TypeActorStepComponent
1Start EventSystemOTA sync detects new/updated bookingSyncEngine.pullBookings
2Service TaskSystemUpsert booking with dedup (ota_booking_id)BookingsService.upsertFromOta
3Service TaskSystemStore raw OTA status string (view-only)Booking.otaStatus field
4User TaskU-04/05Request status transition via UIPATCH /bookings/:id/status
5XOR GatewaySystemValidate transition exists + role allowedBookingStatusTransition check
6Parallel GatewaySystemExecute hooks concurrentlyPromise.all([audit, avail, notify])
7End EventTerminal status reachedBookingStatusDef.isTerminal

Exceptions: Invalid transition → 400. Role denied → 403. Hook failure → logged, doesn't block transition.


P-02: OTA Sync Pipeline

Trigger: BullMQ timer every 2-3 minutes
Entities: E-04 (OtaAccount), E-05 (OtaConnection), E-08 (Booking), E-07 (Availability), E-09 (SyncJob)

Steps:

#BPMN TypeActorStepComponent
1Timer StartSystemBullMQ repeatable job firesPollingScheduler
2Service TaskSystemCreate SyncJob record (pending)SyncJobsService
3Service TaskSystemFetch active OtaConnectionsOtaConnectionsService
4XOR GatewaySystemCheck OtaAccount session validityOtaAccount.status check
5Service TaskSystemPull bookings via OTA adapterOtaAdapter.fetchBookings
6Service TaskSystemUpsert + dedup bookingsBookingsService.upsertFromOta
7Script TaskSystemRecalculate room availabilityAvailabilityCalc
8XOR GatewaySystemCheck if booked > totalOverbooking detection
9Service TaskSystemPush availability to other OTAsOtaAdapter.pushAvailability
10End EventSystemMark SyncJob completed/failedSyncJob.status update

Exceptions: Session expired → Alert + skip. Fetch error → SyncJob failed + retry (3x backoff). Push error → partial sync logged.


P-03: Alert Resolution

Trigger: System creates alert (overbooking, sync failure, session expired)
Entities: E-11 (Alert)

Steps:

#BPMN TypeActorStep
1Signal StartSystemAlert created (E-11) by sync engine or availability check
2Service TaskSystemDispatch notification (email/LINE)
3User TaskU-04/05Review alert on dashboard
4XOR GatewayU-04/05Decide: resolve or escalate
5User TaskU-04/05Add resolution notes
6End EventAlert marked resolved

P-04: Customer Management

Trigger: CS creates customer profile or links booking
Entities: E-19 (Customer), E-08 (Booking)

Steps:

#BPMN TypeActorStep
1User TaskU-05Create customer profile
2User TaskU-05Search/select unlinked bookings
3Service TaskSystemSuggestion engine (fuzzy name/email match)
4User TaskU-05Link selected bookings
5XOR GatewayU-05Detect duplicate customer
6User TaskU-05Confirm merge
7Service TaskSystemAtomic merge transaction

P-05: OTA Onboarding

Trigger: Admin connects new OTA account
Entities: E-04 (OtaAccount), E-02 (Property), E-03 (RoomType), E-05 (OtaConnection), E-06 (OtaRoomMapping)

Steps:

#BPMN TypeActorStep
1User TaskU-01/02Select OTA, enter credentials
2XOR GatewayU-01/02Choose 2FA method
3Service TaskSystemTest connection via Playwright
4XOR GatewaySystemConnection success/fail
5Service TaskSystemDiscover properties from OTA
6Script TaskSystemCross-OTA property matching
7User TaskU-01/02Select properties to import
8Service TaskSystemBatch create entities

P-06: Property Setup

Trigger: Admin creates property manually or imports from OTA
Entities: E-02 (Property), E-03 (RoomType), E-05 (OtaConnection), E-17 (SupplierRoomAllocation)

Steps:

#BPMN TypeActorStep
1User TaskU-01/02Enter property details
2User TaskU-01/02Add room types
3XOR GatewayU-01/02Connect to OTA?
4User TaskU-04Map room types to OTA
5XOR GatewayU-01/02Assign suppliers?
6User TaskU-01/02Set supplier allocations
7XOR GatewaySystemValidate allocation totals (soft)

5. Process Interaction Matrix

SourceTargetTrigger MechanismData Flow
P-05 → P-06OTA Onboarding → Property SetupProperty import creates entitiesE-02, E-03, E-05, E-06
P-05 → P-02OTA Onboarding → OTA SyncNew OtaConnection activates pollingE-05 isActive=true
P-02 → P-01OTA Sync → Booking LifecycleBooking upsert creates/updates E-08E-08 with status=confirmed
P-02 → P-03OTA Sync → Alert ResolutionSync failure or overbooking detectedE-11 Alert created
P-01 → P-04Booking Lifecycle → Customer MgmtCS links booking to customer profileE-08.customerId set

6. Process Maturity & Automation Level

ProcessCurrent StateAutomation LevelEngine
P-01 Booking Lifecycle✅ ImplementedState machine + hooksBookingStatusTransition table
P-02 OTA Sync Pipeline⚠️ Partial (adapters stubbed)BullMQ job queuePollingScheduler + SyncEngine
P-03 Alert Resolution✅ ImplementedManual (UI-driven)AlertsService.resolve
P-04 Customer Management✅ ImplementedManual (UI-driven)CustomersService CRUD
P-05 OTA Onboarding⚠️ Partial (connection stubbed)Wizard-guidedOtaAccountsService + S-06
P-06 Property Setup✅ ImplementedManual (UI-driven)PropertiesService CRUD

7. Phase B: Generalized Workflow Engine — IMPLEMENTED

Phase B generalized the booking state machine to support multiple process types:

7.1 Entities Added (Phase B)

EntityCodePurpose
ProcessTypeE-21Registry of process definitions (6 seeded types: booking, ota_sync, alert_resolution, customer_mgmt, ota_onboarding, property_setup)
ProcessInstanceE-22Execution tracking per process (polymorphic: any entity_type)

7.2 Existing Entities Enhanced (Phase B)

  • BookingStatusDef — added processTypeKey FK, default='booking' for backward compatibility
  • BookingStatusTransition — added processTypeKey FK, default='booking' for backward compatibility

7.3 Phase B Completion Status

ComponentStatus
Database schema (E-21, E-22)✅ Implemented
API endpoints (/process-types, /process-status, /process-transitions, /process-instances)✅ Implemented
Workflow tab in Settings (S-16)✅ Implemented
Process Management tab (S-28)✅ Implemented
Process Instances page (S-29)✅ Implemented
NestJS modules registration✅ Implemented
BookingHooksService generalized with entityType support✅ Implemented

7.4 Backward Compatibility

Existing booking workflow preserved via processTypeKey = 'booking' default on all status/transition records. No breaking changes to P-01 Booking Lifecycle process.

See SRD.md FR-44 to FR-47 for detailed requirements.

PTX Channel Manager — Internal Documentation