Process Path Bounded Context - Domain-Driven Design

Overview

The Process Path Bounded Context is a core fulfillment domain responsible for intelligent routing and orchestration of shipments through multiple processing pathways in the fulfillment center. It manages the assignment of orders to optimal paths, monitors capacity constraints, and dynamically rebalances workload to meet SLA requirements and maximize throughput.

Services

The bounded context is composed of 7 microservices:

Service Port Responsibility
process-path-commons - Shared domain interfaces, base events, outbox pattern
process-path-routing-service 8081 Intelligent path selection and assignment
process-path-orchestration-service 8082 Capacity management and workload balancing
singles-path-service 8083 Direct pick-to-pack workflow for single-item orders
afe-path-service 8084 AFE sorter-based consolidation workflows
batch-flow-path-service 8085 Batch picking and put-wall consolidation
slam-operations-service 8086 Final quality gate (Scan, Label, Apply, Manifest)

Domain Model

Aggregates

ProcessPath (Routing Service)

Root aggregate representing a physical or logical process path configuration.

1
2
3
4
5
6
7
8
9
10
11
public class ProcessPath {
    private String pathId;
    private String pathName;
    private PathType pathType;          // SINGLES, AFE, BATCH_FLOW, CUSTOM
    private PathStatus status;          // ACTIVE, INACTIVE, MAINTENANCE, RETIRED
    private String warehouseId;
    private List<String> capabilities;
    private PathConstraints constraints;
    private PathScoringCriteria scoringCriteria;
    private Long version;
}

Business Rules:


PathAssignment (Routing Service)

Tracks the lifecycle of a shipment’s assignment to a process path.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class PathAssignment {
    private String assignmentId;
    private String orderId;
    private String shipmentId;
    private String warehouseId;
    private ShipmentProfile shipmentProfile;
    private OrderComposition orderComposition;
    private boolean slaEmergency;
    private String assignedPathId;
    private PathType assignedPathType;
    private PathScore assignmentScore;
    private List<PathCandidate> evaluatedPaths;
    private AssignmentStatus status;    // PENDING, ASSIGNED, COMPLETED, CANCELLED
    private List<EvaluationRecord> evaluationHistory;
    private List<RerouteRecord> rerouteHistory;
    private LocalDateTime assignedAt;
}

State Machine:

1
2
3
PENDING β†’ ASSIGNED β†’ COMPLETED
              ↓
           CANCELLED

Business Rules:


PathCapacity (Orchestration Service)

Manages real-time capacity and utilization metrics for a process path.

1
2
3
4
5
6
7
8
9
10
11
12
public class PathCapacity {
    private String capacityId;
    private String pathId;
    private String warehouseId;
    private int maxThroughputUnitsPerHour;
    private int currentThroughputUnitsPerHour;
    private double utilizationPercent;
    private CapacityState capacityState;  // NORMAL, CONSTRAINED, CRITICAL
    private int activeStations;
    private int maxStations;
    private CapacityThresholds thresholds;
}

Capacity States: | State | Utilization | Action | |β€”β€”-|β€”β€”β€”β€”-|——–| | NORMAL | 0-79% | Accept all work | | CONSTRAINED | 80-94% | Begin load balancing, alert operations | | CRITICAL | 95-100% | Stop routing, activate all stations, escalate |


WorkloadDistribution (Orchestration Service)

Represents workload distribution across paths for a time period.

1
2
3
4
5
6
7
public class WorkloadDistribution {
    private String distributionId;
    private String warehouseId;
    private DistributionPeriod distributionPeriod;
    private Map<String, PathWorkload> pathWorkloads;
    private DistributionStatus status;  // ACTIVE, REBALANCING, COMPLETED
}

AFEBatch (AFE Path Service)

Batch of orders routed through AFE sorter-based processing.

1
2
3
4
5
6
7
8
9
10
11
public class AFEBatch {
    private String batchId;
    private String warehouseId;
    private String waveId;
    private List<String> orderIds;
    private int totalItems;
    private AFEBatchStatus status;
    private String assignedInductStation;
    private LocalDateTime inductStartedAt;
    private LocalDateTime inductCompletedAt;
}

State Machine:

1
2
3
CREATED β†’ READY_FOR_INDUCT β†’ INDUCTING β†’ SORTING β†’ COMPLETED
   ↓                                        ↓
CANCELLED                                CANCELLED

SinglesSession (Singles Path Service)

Single-item order through direct pick-to-pack workflow.

1
2
3
4
5
6
7
8
9
10
11
12
13
public class SinglesSession {
    private String sessionId;
    private String orderId;
    private String shipmentId;
    private String itemSku;
    private SinglesStatus status;
    private String workerId;
    private String stationId;
    private String assignedPickLocation;
    private String assignedPackStation;
    private LocalDateTime startedAt;
    private LocalDateTime completedAt;
}

State Machine:

1
2
3
INITIATED β†’ PICKING β†’ PACKING β†’ COMPLETED
  ↓                     ↓
FAILED               FAILED

PickBatch (Batch Flow Path Service)

Batch of orders picked together with put-wall consolidation.

1
2
3
4
5
6
7
8
9
10
11
12
public class PickBatch {
    private String batchId;
    private String warehouseId;
    private String waveId;
    private List<String> orderIds;
    private int totalItems;
    private int totalUnits;
    private PickBatchStatus status;
    private String assignedPicker;
    private LocalDateTime pickingStartedAt;
    private LocalDateTime pickingCompletedAt;
}

Value Objects

ShipmentProfile

Analyzed shipment characteristics for routing decisions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public record ShipmentProfile(
    Dimensions dimensions,
    Weight weight,
    String hazmatClass,
    FragilityLevel fragilityLevel,
    SortabilityClass sortabilityClass,
    TemperatureRequirement temperatureRequirement,
    boolean giftWrap
) {
    public boolean requiresSpecialHandling() {
        return hazmatClass != null ||
               fragilityLevel == ULTRA_FRAGILE ||
               temperatureRequirement != null ||
               giftWrap;
    }

    public boolean fitsStandardAFETray() {
        return dimensions.length() <= 18 && dimensions.width() <= 18;
    }
}

OrderComposition

Order structure and consolidation requirements.

1
2
3
4
5
6
7
8
9
10
11
12
public record OrderComposition(
    int itemCount,
    int uniqueSkuCount,
    boolean hasGiftWrap,
    String specialPackaging,
    ConsolidationRequirement consolidationRequirement,
    ShipmentType shipmentType
) {
    public boolean hasHighSkuDiversity() {
        return uniqueSkuCount > (itemCount * 0.8);
    }
}

PathScoringCriteria

Weighted factors for intelligent path selection.

1
2
3
4
5
6
7
8
9
10
11
public record PathScoringCriteria(
    double utilizationWeight,      // 0.4
    double bufferAvailabilityWeight,  // 0.3
    double laborAvailabilityWeight,   // 0.2
    double affinityWeight          // 0.1
) {
    // Total Score = (100 - utilization%) Γ— 0.4 +
    //               buffer_availability Γ— 0.3 +
    //               labor_availability Γ— 0.2 +
    //               path_affinity Γ— 0.1
}

PathConstraints

Physical and operational limits of a process path.

1
2
3
4
5
6
public record PathConstraints(
    Dimensions maxDimensions,
    Weight maxWeight,
    int maxItemsPerShipment,
    boolean hazmatRestricted
) {}

Domain Events

Events Published

Routing Service (process-path.routing.v1.events)

Event Type Description
ShipmentRoutedToPathEvent com.paklog.processpath.routing.shipment-routed.v1 Path assignment decision with scoring
ShipmentReroutedEvent com.paklog.processpath.routing.shipment-rerouted.v1 Path change due to bottleneck
PathAssignmentFailedEvent com.paklog.processpath.routing.path-assignment-failed.v1 No eligible paths available

Orchestration Service (process-path.orchestration.v1.events)

Event Type Description
PathCapacityChangedEvent com.paklog.processpath.orchestration.path-capacity-changed.v1 Capacity state transition
WorkloadRebalanceTriggeredEvent com.paklog.processpath.orchestration.workload-rebalance-triggered.v1 Rebalancing initiated
SurgeDetectedEvent com.paklog.processpath.orchestration.surge-detected.v1 Volume spike detection
SLAPriorityEscalatedEvent com.paklog.processpath.orchestration.sla-priority-escalated.v1 Priority override
SLABreachImminentEvent com.paklog.processpath.orchestration.sla-breach-imminent.v1 Breach risk escalation

AFE Path Service (process-path.afe.v1.events)

Event Type Description
WallCapacityChangedEvent com.paklog.processpath.afe.wall-capacity-changed.v1 Rebin wall capacity change
TrayCirculationImbalanceEvent com.paklog.processpath.afe.tray-circulation-imbalance.v1 Tray flow anomaly
DischargeJamDetectedEvent com.paklog.processpath.afe.discharge-jam-detected.v1 Sorter jam detected

SLAM Operations Service (wes.slam.v1.events)

Event Type Description
SLAMCompletedEvent com.paklog.wes.slam.completed.v1 Final quality gate completion

Events Consumed

Source Topic Events Consumer
Order Management fulfillment.order_management.v1.events OrderReleasedToWarehouseEvent, OrderCancelledEvent routing-service
Inventory fulfillment.inventory.v1.events InventoryAllocatedEvent, AllocationShortageEvent routing-service
WES Orchestration wes.orchestration.v1.events WorkReleaseAuthorizedEvent, CircuitBreakerStateChangedEvent routing-service
Wave Planning fulfillment.wave.v1.events WaveReleasedEvent, WaveCancelledEvent routing-service
Workload Planning workload.planning.v1.events CapacityForecastUpdatedEvent, LaborAvailabilityChangedEvent orchestration-service
Physical Tracking tracking.v1.events ShipmentLocationUpdatedEvent, DwellTimeExceededEvent, AnomalyDetectedEvent orchestration-service
Robotics Fleet robotics.fleet.v1.events RobotTaskCompletedEvent, PodDeliveredEvent, RobotCapacityEvent orchestration-service, afe-path-service
Pack & Ship wes.pack.v1.events PackingCompletedEvent singles-path-service, batch-flow-path-service

Domain Services

PathAssignmentService (Routing)

1
2
3
4
5
6
7
8
public interface PathAssignmentService {
    PathAssignment assignPath(String orderId, String shipmentId, String warehouseId,
                              ShipmentProfile profile, OrderComposition composition, boolean slaEmergency);
    PathAssignment reroutePath(String assignmentId, String newPathId, String reason);
    List<PathCandidate> evaluatePaths(ShipmentProfile profile, OrderComposition composition, String warehouseId);
    PathCandidate selectBestPath(List<PathCandidate> candidates);
    PathCandidate selectFastestPath(List<PathCandidate> candidates);  // SLA emergency
}

CapacityManagementService (Orchestration)

1
2
3
4
5
6
7
public interface CapacityManagementService {
    void monitorCapacity(String warehouseId);
    SurgeDetectedEvent detectSurge(String warehouseId);
    WorkloadRebalancedEvent rebalanceWorkload(String warehouseId);
    void escalateSLAPriority(String shipmentId);
    void trackSLABreach(String shipmentId);
}

Integration Patterns

Partnership

Customer-Supplier

Conformist

Event Streaming


Technology Stack

Component Technology
Language Java 21
Framework Spring Boot 3.3.3
Database MongoDB 7.0
Messaging Apache Kafka 7.5.0
Cache Redis 7.2
Event Format CloudEvents 2.5.0

References