Skip to main content

Domain Message Flow

Following ddd-crew Domain Message Flow Modelling. Participants are contexts and actors. Every arrow is a message from the yard design model, prefixed cmd:, qry: or evt:. Events are written entity.EventName; the full type is com.warehouse.wms.<producer>.<entity>.<EventName> (see Domain Events). Route parameters are written without braces. Events marked analytics only go to warehouse.dock-scheduling.analytics and have no named consumer; the diagrams show them as notes.

1. Booking, rescheduling and cancelling​

Source: internal/domain/dockappointment/appointment.go, internal/domain/dockappointment/commands.go, internal/domain/dockappointment/events.go, internal/adapters/inbound/kafka/yard_consumer.go, internal/adapters/inbound/kafka/facility_consumer.go, internal/adapters/inbound/kafka/asn_consumer.go, internal/adapters/inbound/kafka/cutoff_consumer.go, internal/adapters/outbound/kafka/encoder.go, apis/asyncapi.yaml.

Omitted: the three branches are shown in sequence for width; a real carrier reschedules or cancels one appointment, not all three in a row. A reschedule is allowed only from BOOKED, a cancel from BOOKED or CHECKED_IN (otherwise ErrIllegalTransition, 409). inbound-receiving also consumes DockAppointmentRescheduled in the code (its appointments copy, ADR 0019); outbound-shipping reads DockAppointmentBooked. A dock planner may also reschedule and cancel. The Err... to HTTP status mapping is decision D-10: 409 for conflicts, 422 for value rules.

2. From the gate to the released door​

Source: internal/application/usecases/facts.go, internal/application/usecases/yard.go, internal/application/usecases/change.go, internal/adapters/outbound/kafka/encoder.go, apis/asyncapi.yaml.

Omitted: the yard's own steps between the three events (moves, door work), which belong to yard-management. A yard fact for an unknown, terminal, CANCELLED or NO_SHOW appointment is ignored and counted; a late VisitCheckedIn for a COMPLETED appointment is ignored. One appointment covers exactly one trailer (decision X3). A release applied to a BOOKED appointment completes it without a DockAppointmentCheckedIn; the adherence report counts it as ON_TIME and the metric dock_scheduling_implicit_arrivals_total counts it (decision X6).

3. A late ETA and a no-show​

Source: internal/application/usecases/facts.go, internal/application/usecases/yard.go, internal/application/usecases/change.go, internal/adapters/inbound/kafka/yard_consumer.go, internal/adapters/inbound/kafka/facility_consumer.go, internal/adapters/inbound/kafka/asn_consumer.go, internal/adapters/inbound/kafka/cutoff_consumer.go, internal/adapters/outbound/kafka/encoder.go, apis/asyncapi.yaml.

Omitted: the sweep is idempotent, so a second run marks nothing new. The routing of the case inside exception-management is that context's and is not in the design model beyond "open problem cases ... and DockAppointmentNoShow". A carrier that missed its window books a new appointment: NO_SHOW is terminal (decision D-9).

4. A door closure and a cancelled ASN​

Source: internal/domain/dockcalendar/calendar.go, internal/domain/dockcalendar/events.go, internal/application/usecases/facts.go, internal/application/usecases/yard.go, internal/application/usecases/change.go, internal/adapters/inbound/kafka/yard_consumer.go, internal/adapters/inbound/kafka/facility_consumer.go, internal/adapters/inbound/kafka/asn_consumer.go, internal/adapters/inbound/kafka/cutoff_consumer.go, internal/adapters/outbound/kafka/encoder.go, apis/asyncapi.yaml.

Omitted: DoorOperatingHoursDeclared (analytics only) and DeclareOperatingHours, which is refused with ErrHoursConflictWithAppointments when it would leave an active appointment outside the hours (decision D-8); the phase-2 pickup policy (PickupFromCutoffs), which is described on Domain Events. The refusal that lists the appointment ids is the design model's only help for a planner closing a door; ListAppointments takes filters (for example atRisk), which are in the OpenAPI contract.