Skip to main content

Bounded Context Canvas

Following the ddd-crew Bounded Context Canvas v5. Every message row comes from contexts[yard-management] → inbound, rest, publishes, consumes and sync_calls (empty).

Canvas at a glance​

Two pictures of the sections below: first the collaborators that command, query or feed this context (with its purpose, roles and the decisions it enforces), then the collaborators it notifies. Arrows follow the message type: solid blue commands (cmd), dotted green queries (qry), thick orange events (evt). Box shapes mark the collaborator kind: rounded = people or any client; blue = sibling bounded context; grey = this context's own scheduler; dashed = published only on the analytics topic. Channel names are abbreviated; the tables carry the exact route, topic and CloudEvents type.

Inbound​

Source: apis/openapi.yaml, internal/adapters/inbound/http/server.go, internal/adapters/inbound/kafka/*_consumer.go.

Outbound​

Source: internal/domain/trailer/events.go, internal/adapters/outbound/kafka/encoder.go, internal/adapters/inbound/kafka/consumer.go, apis/openapi.yaml, internal/adapters/inbound/http/server.go.

Omitted: assumptions, metrics, open questions and the glossary (sections below); the relationship pattern per message (see the tables); full CloudEvents types and routes (see the tables). There are no outbound commands or queries: sync_calls is empty, so this context calls no other context synchronously. DockAppointment x4 is DockAppointmentBooked, Rescheduled, Cancelled and NoShow; DoorClosure x2 is DoorClosureScheduled and DoorClosureLifted.

Name​

Yard Management (yard-management, code YM, CloudEvents tier wms).

Purpose​

Own everything physically on site outside the four walls: who passed the gate (visits), which trailer is where (spot, door or an open move), its load, seal and hold state, the moves hostlers and visiting drivers make, door work at the door, and yard checks. The source of dwell, door occupancy and yard truck productivity facts. dock-scheduling owns the future of a door; this context owns the present of the yard.

Strategic Classification​

AxisVerdict
DomainSupporting (see Core Domain Chart).
Business ModelCost reducer (detention, demurrage, lost trailers, idle dock labour) and throughput enabler.
EvolutionCustom-built.

Domain Roles​

RoleEvidence in the model
Execution (gate, moves, docking)Runs the visit lifecycle (CheckInVisit … CheckOutVisit), the move lifecycle (RequestMove … CompleteMove) and docking (ArriveAt, StartDoorWork, CompleteDoorWork, Depart); policies DirectOnCheckIn, CallToDoor, ClearDoorAfterWork.
Analysis (dwell, door utilisation)Publishes dwell, door-work and move facts on the analytics topic; read model the analytics reports (dwell by kind, door utilisation, moves per hostler hour, driver wait); routes GET /reports/yard-dwell, /door-utilisation, /hostler-productivity.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
Gate clerk or kioskCheckInVisitCommandREST POST /visitsUI
Gate clerk or kioskRejectAtGateCommandREST POST /visit-rejectionsUI
Gate clerk or kioskCheckOutVisitCommandREST POST /visits/{visitId}/check-outsUI
Hostler (floor client)ClaimNextMoveCommandREST POST /moves/claimsUI
Hostler (floor client)CompleteMoveCommandREST POST /moves/{moveId}/completionsUI
Dock operator (floor client)StartDoorWorkCommandREST POST /trailers/{trailerId}/door-work-startsUI
Dock operator (floor client)CompleteDoorWorkCommandREST POST /trailers/{trailerId}/door-work-completionsUI
Yard supervisorRequestMoveCommandREST POST /movesUI
Yard supervisorCancelMoveCommandREST POST /moves/{moveId}/cancellationsUI
Yard supervisorPlaceHoldCommandREST POST /trailers/{trailerId}/holdsUI
Yard supervisorReleaseHoldCommandREST POST /trailers/{trailerId}/hold-releasesUI
Yard supervisorRecordSealCommandREST POST /trailers/{trailerId}/sealsUI
Yard supervisorDeclareYardPolicyCommandREST PUT /sites/{siteId}/yard-policyUI
Yard supervisorOpenYardCheckCommandREST POST /yard-checksUI
Yard supervisorRecordObservationCommandREST POST /yard-checks/{yardCheckId}/observationsUI
Yard supervisorCloseYardCheckCommandREST POST /yard-checks/{yardCheckId}/closuresUI
Any contextListVisitsQueryREST GET /visitsOHS
Any contextGetVisitQueryREST GET /visits/{visitId}OHS
Any contextListTrailersQueryREST GET /trailersOHS
Any contextGetTrailerQueryREST GET /trailers/{trailerId}OHS
Any contextListMovesQueryREST GET /movesOHS
Any contextGetYardBoardQueryREST GET /sites/{siteId}/yard-boardOHS
Any contextGetYardPolicyQueryREST GET /sites/{siteId}/yard-policyOHS
Scheduler (cron)DwellSweepCommandREST POST /dwell-sweepsUI
Scheduler (cron)ExpireLeaseCommandREST POST /move-lease-sweepsUI
dock-schedulingDockAppointmentBookedEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentBookedCustomer/Supplier
dock-schedulingDockAppointmentRescheduledEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentRescheduledCustomer/Supplier
dock-schedulingDockAppointmentCancelledEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentCancelledCustomer/Supplier
dock-schedulingDockAppointmentNoShowEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentNoShowCustomer/Supplier
dock-schedulingDoorClosureScheduledEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureScheduledCustomer/Supplier
dock-schedulingDoorClosureLiftedEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.dockcalendar.DoorClosureLiftedCustomer/Supplier
dock-schedulingCarrierRegisteredEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.carrier.CarrierRegistered (ADR 0016)Customer/Supplier
dock-schedulingCarrierSuspendedEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.carrier.CarrierSuspended (ADR 0016)Customer/Supplier
dock-schedulingCarrierReinstatedEventKafka warehouse.dock-scheduling.events, com.warehouse.wms.dock-scheduling.carrier.CarrierReinstated (ADR 0016)Customer/Supplier
facility-layoutLocationSlotRegistered (optional spotKind, ADR 0014)EventKafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredConformist
facility-layoutLocationSlotDecommissionedEventKafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissionedConformist
facility-layoutZoneRegisteredEventKafka warehouse.facility.events, com.warehouse.wms.facility-layout.zone.ZoneRegisteredConformist
inbound-receivingASNRegisteredEventKafka warehouse.inbound-receiving.events, com.warehouse.wms.inbound-receiving.asn.ASNRegisteredConformist
inbound-receivingASNCancelledEventKafka warehouse.inbound-receiving.events, com.warehouse.wms.inbound-receiving.asn.ASNCancelledConformist
inbound-receivingReceiptOpenedEventKafka warehouse.inbound-receiving.events, com.warehouse.wms.inbound-receiving.receipt.ReceiptOpenedConformist
inbound-receivingReceiptClosedEventKafka warehouse.inbound-receiving.events, com.warehouse.wms.inbound-receiving.receipt.ReceiptClosedConformist

The CloudEvents type strings of the consumed events are the ones in each producer's AsyncAPI: apis/ for facility-layout and inbound-receiving, yard/apis/dock-scheduling/ for dock-scheduling (merged on develop).

Outbound Communication​

CollaboratorMessageTypeChannelRelationship
dock-schedulingVisitCheckedInEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.yardvisit.VisitCheckedInCustomer/Supplier (dock-scheduling is the Customer)
inbound-receivingVisitCheckedInEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.yardvisit.VisitCheckedInNo pattern named (its ADR 0021 names none)
dock-scheduling, outbound-shippingTrailerDockedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.trailer.TrailerDockedCustomer/Supplier
dock-schedulingTrailerUndockedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.trailer.TrailerUndockedCustomer/Supplier
dock-scheduling, exception-managementVisitRejectedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.yardvisit.VisitRejectedCustomer/Supplier
exception-managementSealExceptionRaisedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.trailer.SealExceptionRaisedCustomer/Supplier
exception-managementTrailerDwellExceededEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.trailer.TrailerDwellExceededCustomer/Supplier
exception-managementYardCheckClosedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.yardcheck.YardCheckClosedCustomer/Supplier
analytics onlyVisitCheckedOutEventKafka warehouse.yard-management.analytics, com.warehouse.wms.yard-management.yardvisit.VisitCheckedOutPL, no named consumer
outbound-shippingDoorWorkCompleted, TrailerDepartedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.trailer.<Event>Customer/Supplier (integration since 2026-11-09)
exception-management (planned)InspectionFailedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.inspection.InspectionFailedCustomer/Supplier (ADR 0015)
none yet (integration topic)InspectionCompletedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.inspection.InspectionCompletedPL, no named consumer (ADR 0015)
none yet (integration topic)TrailerSecured, TrailerSecuringReleasedEventKafka warehouse.yard-management.events, com.warehouse.wms.yard-management.trailer.<Event>PL, no named consumer (ADR 0013)
analytics onlyTrailerParked, DoorWorkStarted, TrailerHeld, TrailerHoldReleasedEventKafka warehouse.yard-management.analytics, com.warehouse.wms.yard-management.trailer.<Event>PL, no named consumer
analytics onlyYardMoveRequested, YardMoveClaimed, YardMoveLeaseExpired, YardMoveCompleted, YardMoveCancelledEventKafka warehouse.yard-management.analytics, com.warehouse.wms.yard-management.yardmove.<Event>PL, no named consumer
—(no synchronous calls)—sync_calls: []—

The relationship for exception-management and outbound-shipping is this pack's reading: the model lists them as consumers of the events and as fleet_changes, and the strategic context map marks both edges Customer/Supplier. Both consumers are merged on develop. inbound-receiving is not a consumer of TrailerDocked: the optional consumer in the model was not built; it consumes VisitCheckedIn only (its ADR 0021). Neither context's own inbound rows are in this model.

Full message details: Domain Events. Relationship evidence: Context Map.

Ubiquitous Language​

Full glossary: Ubiquitous Language. Top terms: Yard, Yard Visit (purposes DROP, LIVE_UNLOAD, LIVE_LOAD, PICKUP, BOBTAIL), Trailer, Spot, Dock Door, Hostler, Yard Move, Door Work, Dwell, Seal.

Business Decisions​

  1. One place per trailer. A trailer on site is at exactly one yard spot, one door, or one open move.
  2. One trailer per spot or door (ErrLocationOccupied, under a per-location advisory lock and a partial unique index).
  3. One open move per trailer (ErrTrailerHasOpenMove), and its destination is reserved when requested (ErrDestinationReserved).
  4. Moves are pulled. A hostler claims the next move with a lease and holds at most one (ErrHostlerBusy); only the lease holder completes it (ErrNotLeaseHolder).
  5. Check-out only when released and sealed. ErrTrailerNotReleased, ErrSealRequired.
  6. Walk-ins go to a holding spot unless the site's policy requires an appointment (ErrAppointmentRequired).
  7. Seal mismatch raises an exception; REJECT policy also rejects the visit.
  8. A trailer on hold is not docked (ErrTrailerOnHold); a docked trailer departs only when its door work is done (ErrDoorWorkOpen).
  9. A door under a closure takes no trailer (ErrDoorClosed); a loaded trailer docks only at a door whose flow allows its direction (ErrDoorFlowMismatch).
  10. At most one open yard check per site (ErrYardCheckOpen).

Assumptions​

  • facility-layout publishes every Yard and Dock slot with zoneId, role and dockFlow, and every zone with its siteCode; a door or spot is mapped to its site only through that join, never by parsing a location code.
  • dock-scheduling publishes an appointment's door_code, window and expected_seal_number, and its closures, before the carrier arrives.
  • inbound-receiving opens a receipt on the appointment with appointment_id and door_code (ReceiptOpened), and closes it (ReceiptClosed).
  • Yard events are keyed by visit or trailer id, so dock-scheduling may see them in any order across partitions (its policy OutOfOrderYardFacts).
  • Consumers rebuild their copies from events only; there is no synchronous call into or out of this context on a decision path.

Verification Metrics​

Neither the model nor the service states targets; the targets below are this page's proposal. The measures are the ones the analytics reports names or the invariants imply.

MetricTargetSource
Trailers on site in more than one place0trailers check
Spots or doors holding more than one trailer0partial unique index, trailers check
Dwell by trailer kindreport weeklyTrailerDeparted.dwell_minutes on the analytics topic
Door utilisationreport weeklyTrailerDocked, TrailerUndocked, DoorWorkStarted, DoorWorkCompleted
Moves per hostler hourreport weeklyYardMoveCompleted.duration_seconds
Driver wait (arrival to door work started)report weeklyVisitCheckedIn.arrived_at, DoorWorkStarted.started_at
Expired leases per daytrend to 0POST /move-lease-sweeps result
ErrLocationOccupied or ErrDestinationReserved refusalstrend to 0use-case error counter
Late or unknown appointment facts ignored by dock-schedulingtrend to 0dock-scheduling ignored-and-counted metric
Lag from TrailerUndocked to the next YardMoveRequested for that doorp95 under one minuteevent timestamps

Closed questions​

The gaps this page used to list were decided before the build (decisions Y-1 to Y-14, X1 to X7; the register is Model Gap Register) and are in the service; how each was settled is in the hotspot table on EventStorming. In short: a lease expiry or a cancelled claimed move returns the trailer where it was (ReturnToOrigin, YM-G1); the gate creates the trailer IN_MOVE with a visiting-driver move that the gate clerk or dock operator completes (YM-G2, YM-G3); the arrival tolerance travels on the dock-scheduling booking events and the appointment copy marks itself CHECKED_IN and USED (YM-G5, YM-G6); a refused check-in creates nothing while RejectAtGate records a rejected visit (YM-G7); ArriveAt and the departure commands raise the location events (YM-G8); a live visit leaves from the door (YM-G28); the report routes have an inbound row of their own (YM-G26).