Skip to main content

Slotting Optimization

slotting-optimization is the bounded context of the warehouse-systems fleet that decides which SKUs deserve a forward pick slot, and which slot each one gets. It computes a reviewable proposal (a slot plan), a human approves or rejects it, and an approved plan is published as a CloudEvent carrying the full forward assignment map and the physical moves it implies.

FactValueWhere it comes from
Subdomain classSupportingSubdomain classification, ADR 0001
TierWMS (CloudEvents subdomain segment wms)internal/adapters/kafka/cloudevents/cloudevents.go (Subdomain = "wms")
AggregateSlotPlan (package internal/domain/slotplan)ADR 0002
Policyabc-velocity-v1 (package internal/domain/planning)ADR 0002
Binariesfour, in one image: cmd/api (REST on HTTP_ADDR, default :8080, plus five Kafka consumers and the outbox relay as goroutines, all always on), cmd/mcp (read-only MCP server, :8090), cmd/slotting-projector (analytics writer, admin :8091) and cmd/slotting-reports (read-only reports, :8092)cmd/*/main.go, Architecture
Data storesthe OLTP Postgres database (DATABASE_URL, embedded migrations 0001-0002) and a separate analytical Postgres database (ANALYTICS_DATABASE_URL, embedded migration analytics/migrations/0001); there is no in-memory mode (ADR 0011)internal/adapters/outbound/postgres, internal/adapters/outbound/analyticsstore
Kafkapublishes warehouse.slotting-optimization.events (integration) and warehouse.slotting-optimization.analytics (analytics, ADR 0006); consumes warehouse.order-management.events, warehouse.product-master.events, warehouse.facility.events, warehouse.inventory.events (api) and warehouse.slotting-optimization.analytics (projector); the only runtime (ADR 0011)ADR 0003, ADR 0004, ADR 0006, ADR 0010
Authnone (fleet-wide decision; TestNoAuthMiddlewareReintroduced keeps it out)internal/adapters/inbound/http/server.go
MCPcmd/mcp: four read-only tools (get_slot_plan, list_slot_plans, get_forward_slots, get_sku_velocity), Streamable HTTP, unauthenticatedADR 0005, internal/adapters/inbound/mcp/tools.go
Webweb/: the slotting_mfe Module Federation remote (plan list and approval workbench, forward slots, SKU velocity)web/src/App.tsx

What it owns​

  • The SlotPlan. A proposal for one site and one demand window ([windowFrom, windowTo), default 28 days back from now): the assignments {sku, slot, abcClass, picks, units}, the moves against the site's currently Approved plan (Assign, Relocate, Vacate) and the SKUs it could not place with a reason (NoPhysicalProfile, NoEligibleSlot, NoCapacityFit).
  • The decision on it. Draft -> Approved or Rejected. Approving a plan supersedes the site's previous Approved plan in the same transaction, so a site has at most one Approved plan (Superseded is the fourth state).
  • The published forward-slot map. SlotPlanApproved carries every {sku, slot} of the plan and the moves, so a consumer needs no lookup.

It does not own demand, product facts or the slot layout. It keeps three event-fed local copies of them (demand from order-management, product classification and unit size from product-master, zones and slots from facility-layout) and never calls a sibling at request time. It moves no stock itself: wes-work-planning plans the moves of an Approved plan as RELOCATE work, fulfillment-execution executes them and inventory-storage records them; this context reads the resulting StockRelocated back as the plan's execution progress (ADR 0010).

Main capabilities​

CapabilityInterfaceUse case
Generate a Draft plan for a sitePOST /slot-plans (requires Idempotency-Key)GeneratePlan
Approve a Draft (supersedes the previous Approved plan)POST /slot-plans/{planId}/approvalsApprovePlan
Reject a Draft with an optional reasonPOST /slot-plans/{planId}/rejectionsRejectPlan
Read plansGET /slot-plans, GET /slot-plans/{planId}ListPlans, GetPlan
Read the current forward-slot map of a siteGET /forward-slotsListForwardSlots
Read SKU velocity (the planner's demand input)GET /sku-velocityListSkuVelocity
Keep the demand, product and layout copies currentKafka consumers (always on; DEMAND_MODE, PRODUCT_MODE, LAYOUT_MODE are kafka, the only value)ApplyDemandChanged, ApplyProductClassified, ApplyPhysicalProfile, ApplyZoneRegistered, ApplyLocationSlotRegistered, ApplyLocationSlotDecommissioned
Record the execution progress of an Approved planKafka consumer of StockRelocated (always on, RELOCATION_MODE=kafka)RecordRelocation
Publish plan decisionstransactional outbox + relay (always on, EVENT_PUBLISHER=kafka): each event goes to the integration topic and, under the same CloudEvents id, to the analytics topicevery write use case
Read plans and velocity from an agentMCP tools over the same databaseGetPlan, ListPlans, ListForwardSlots, ListSkuVelocity
Report the slot-plan funnel (generated, approved, rejected, approval latency, supersessions per day)GET /reports/slot-plan-funnel, GET /reports/freshness on cmd/slotting-reportsinternal/analytics/report (not an OLTP use case)

Where to go next​

You want toRead
See the binaries, layers and storesArchitecture
Run it on your machine and call itQuickstart
Configure itConfiguration
Deploy and operate itRunbook, Observability, Troubleshooting
Run and extend the testsTesting
Know who it talks toIntegration
Learn the modelUse cases, Ubiquitous language, DDD artifacts, Subdomain classification
Read the contractsAPI overview, Event catalogue
Read the decisionsADR index
Study project

Like the rest of the warehouse-systems fleet this repository is a personal study project (DDD, hexagonal architecture, AI-agent harness engineering). It is not production software.

Disclaimer

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic.