Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

55 Commits

Folders and files

Repository files navigation

Warehouse Control System

A portfolio demo of a warehouse control system (WCS): a simulated robot fleet picks inventory against incoming orders on a grid floor, dispatched by a greedy nearest-robot algorithm and shown live in a React control-room UI.

Place an order, watch the nearest idle robot get dispatched, cross the floor, complete the pick, and return home — all live, all in the browser, no page reload. No database: the whole backend's state lives in memory and resets on restart.

See docs/design/2026-09-12-warehouse-control-system-design.md for the full design spec and CHANGELOG.md for what each pull request added.

Contents

Architecture

Two independent processes. The backend owns all state and runs the simulation; the frontend is a pure client that polls it over HTTP and holds no state of its own beyond the last successful poll.

Backend — backend/WarehouseControl.Api (ASP.NET Core minimal API, .NET 10). The domain and dispatch logic still have no external NuGet dependencies; the only packages in the project are OpenTelemetry's hosting, OTLP exporter, and ASP.NET Core/HTTP/runtime instrumentation libraries (see Platform).

  • WarehouseState — an in-memory, ConcurrentDictionary-backed singleton holding every robot, inventory location, pick task, and order. Seeded at startup with 4 robots (one at each corner of a 10×10 grid) and 8 SKUs at fixed interior positions.
  • DispatchService — validates and explodes orders into pick tasks, then assigns pending tasks to the nearest idle, sufficiently-charged robot (Manhattan distance, deterministic tie-breaks, thread-safe against concurrent callers).
  • FleetSimulationService — a BackgroundService ticking once per second: reruns dispatch, steps every in-flight robot one grid cell toward its target, drains/recharges battery, completes tasks and decrements inventory on arrival, and rolls orders to Fulfilled once every task completes.
  • A REST API (backend/WarehouseControl.Api/Endpoints/) exposes all of the above — see REST API below, or WarehouseControl.Api.http for ready-to-run example requests.

Frontend — frontend/ (Vite + React, plain CSS, no UI framework).

  • App.jsx polls /api/robots, /api/orders, and /api/kpis every 1.5s (/api/inventory once, on mount) and renders WarehouseGrid (an animated SVG floor view), RobotFleet, OrderQueue (which hosts the place-order form), and KpiBar.
  • A connection-status badge in the header flips to "Disconnected" on any poll failure — without clearing the last-known view, so the screen freezes in place rather than going blank.
  • Design tokens (dark control-room palette; Space Grotesk for UI text, IBM Plex Mono for data/IDs) live in frontend/src/tokens.css.

Data model

Entity Fields Notes
GridPosition X, Y Value type; Manhattan distance + one-cell step-toward helpers
Robot id, name, home station, position, status, battery %, current task id Status: Idle / MovingToPick / ReturningToStation / Charging
InventoryLocation SKU, description, position, quantity Quantity decrements on task completion
PickTask id, order id, SKU, target location, status, assigned robot id, timestamps Status: Pending / Assigned / Completed
Order id, customer reference (optional), line-item SKUs, status, timestamps Status: Pending / InProgress / Fulfilled

All status enums serialize as strings in JSON ("Idle", not 0).

REST API

Method Route Purpose
GET /api/robots List all robots
GET /api/inventory List all inventory locations
GET /api/orders List all orders
POST /api/orders Create an order — { customerReference?, skus[] } → 201 + the order, or 400 + { error }
GET /api/orders/{id} Get one order — 200 or 404
GET /api/tasks List all pick tasks
POST /api/dispatch/run Force an off-cycle dispatch pass — { assignedCount }
GET /api/kpis Active/idle/charging robot counts, order counts by status, average pick time

Running it

Two terminals — the backend must be running for the frontend to show live data.

Backend

Requires the .NET 10 SDK. If dotnet --list-sdks only shows .NET 8 or earlier, install .NET 10 per-user (no admin rights needed — the machine-wide installer can hang on a UAC prompt in a non-interactive shell):

Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "$env:TEMP\dotnet-install.ps1"
& "$env:TEMP\dotnet-install.ps1" -Channel 10.0 -InstallDir "$env:LOCALAPPDATA\Microsoft\dotnet" -NoPath

That install path isn't on PATH by default in a fresh shell, so prefix commands with it:

$env:PATH = "$env:LOCALAPPDATA\Microsoft\dotnet;$env:PATH"
cd backend
dotnet build
dotnet test
dotnet run --project WarehouseControl.Api

The API listens on http://localhost:5035 by default (dotnet run ... --urls "http://localhost:5035" if you need to pin it explicitly).

Frontend

cd frontend
npm install
npm run dev

Open http://localhost:5173. The dev server is pinned to that port for convenience (vite.config.js) and matches the backend's default CORS allow-list; pointing the frontend at a different port just means telling the backend via Cors__AllowedOrigins__0.

Using it

Select one or more SKU chips in the order queue, optionally add a customer reference, and click "Place order." The nearest idle robot picks it up automatically within a second or two — watch it move across the floor view, complete the task, and return home (or head to charge, if its battery dropped below 20% along the way). The order card and KPI bar update live as it happens.

If the backend goes down mid-session, the header badge flips to "Disconnected" and the screen holds its last-known state; it recovers automatically once the backend is back.

Testing

Backend: backend/WarehouseControl.Tests (xUnit), 77 tests covering the domain model, dispatch logic, the simulation tick (including scripted multi-tick full cycles), every REST endpoint via WebApplicationFactory, the KPI aggregation, liveness/readiness/CORS behavior, the simulation heartbeat's staleness boundary, and every OpenTelemetry instrument — run with dotnet test from backend/.

Frontend: no automated test suite yet (a deliberate, documented scope decision — see CHANGELOG.md); verified through manual and browser-automated UAT passes instead.

Platform

The app above is wrapped in a platform layer: containers, a CI/CD pipeline that builds, tests, scans and publishes images to GHCR, a Helm chart that really installs against those images in an ephemeral kind cluster on every push, and Terraform for the Azure substrate the chart would run on in production (written and statically validated — never applied, since this repo has no subscription to apply it against).

See docs/operations.md for the runbook (bringing the stack up, every port, verifying each telemetry signal end to end) and infra/README.md for a tour of infra/observability/, infra/helm/, infra/terraform/, and infra/kind/.

Project layout

backend/
  WarehouseControl.Api/        # minimal API — Domain/, State/, Services/, Endpoints/,
                                # Observability/ (OpenTelemetry instruments)
  WarehouseControl.Tests/      # xUnit
frontend/
  src/
    components/                # WarehouseGrid, RobotFleet, OrderQueue, KpiBar
    lib/statusColor.js         # shared status → color mapping
    api.js                     # backend fetch client
    config.js                  # runtime/build-time/dev API base URL resolution
    tokens.css                 # design tokens
  public/config.js             # dev default for the runtime config above
infra/
  observability/                # otel-collector, Prometheus, Loki, Tempo, Grafana configs
  helm/warehouse-control/       # the Kubernetes chart
  terraform/                     # the Azure substrate (never applied here — see its README)
  kind/                          # the ephemeral cluster CI installs the chart into
  README.md                      # orientation across the four directories above
.github/workflows/
  ci.yml                         # build, test, lint, image build + scan + publish, deploy gate
  infra.yml                      # terraform validate + scan; helm install + smoke test on kind
compose.yaml                     # docker compose up — the whole stack, locally
docs/design/                     # design spec
docs/operations.md               # runbook
CHANGELOG.md                     # what each pull request changed

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages