Build real-time order tracking and delivery driver systems with PubNub
Does it follow best practices?
Evaluation — 94%
↑ 1.84xAgent success when using this tile
Validation for skill structure
A logistics company is migrating their delivery order tracking from a REST-polling architecture to real-time updates using PubNub. Their current system has a recurring bug where orders sometimes jump from "placed" directly to "en-route" due to race conditions in their backend, confusing customers and breaking their analytics pipeline. They need a robust order status management system that enforces valid transitions and keeps all stakeholders (customers, drivers, dispatchers) synchronized.
The team needs a JavaScript implementation of the order lifecycle manager that handles publishing status changes, validates that each transition is legal, and ensures the dispatch team's dashboard receives all updates. They also want a PubNub Function that acts as a server-side gatekeeper to block invalid transitions even if a buggy client tries to push them. The system must handle the full delivery lifecycle from order placement through completion, including failure and reassignment scenarios.
Produce the following files:
order-status-manager.js -- The client-side status publisher class that validates transitions and publishes updates to the appropriate channels.status-validation-function.js -- A PubNub Function that validates order status transitions server-side, preventing invalid state changes even from buggy clients.order-status-manager.test.js -- Tests that verify the state machine allows valid transitions, rejects invalid ones, and handles failure/reassignment paths correctly.