Dynamic Dispatch and Multi-Stop Route Optimization API Spec
Design high-performance asynchronous API endpoints for complex vehicle routing, capacity constraints, and dynamic dispatching.
Use this spec when building backend interfaces for algorithmic vehicle routing problem (VRP) engines in parcel, freight, or passenger transit. It generates schema definitions, polling contracts, and compute boundary specs.
Role: Lead Logistics Optimization Engineer and API Architect.
Context
- Operational Constraints Matrix: {{routing_constraints}}
- Maximum Concurrent Optimization Jobs: {{dispatch_concurrency_target}}
- API Architectural Style: {{api_style}}
- Third-Party Carrier Payload Format: {{carrier_integration_format}}
- Solver Execution Timeout: {{sla_timeout_ms}}
- Degraded Service Strategy: {{fallback_strategy}}
Task
Produce an API specification and execution lifecycle design for a multi-stop vehicle routing and dynamic dispatching backend service capable of evaluating complex load, time-window, and driver hours-of-service constraints.
Method
- Map {{routing_constraints}} into a normalized input schema supporting pickup/delivery time windows, vehicle cubing, and rest requirements.
- Design the interface boundaries conforming to {{api_style}} with explicit asynchronous job submission, progress polling, and webhook completion patterns.
- Model the solver lifecycle state machine (Submitted, Processing, FeasibleFound, OptimalFound, Failed, TimedOut).
- Specify deterministic error responses, partial solution handling, and fallback execution when processing hits {{sla_timeout_ms}} using {{fallback_strategy}}.
- Create conversion adapters for legacy transportation systems communicating via {{carrier_integration_format}}.
- Define rate limiting, queue isolation tiers, and worker pool resource allocation for {{dispatch_concurrency_target}} concurrent runs.
- Detail caching strategies for matrix distance/duration queries to minimize redundant routing engine computations.
Constraints
- MUST write all interface schemas in production-valid OpenAPI 3.1 or GraphQL SDL depending on {{api_style}}.
- MUST NOT allow synchronous blocking calls on routing jobs estimated to exceed 250ms computation time.
- Payload validation MUST reject mathematically impossible constraints prior to enqueuing the optimization solver.
- All timestamp fields MUST strictly follow ISO 8601 with explicit timezone offsets.
Output format
Deliver an API Specification containing:
- Interface Schema Definitions (OpenAPI 3.1 YAML or GraphQL SDL with full type declarations)
- Asynchronous Job Lifecycle State Machine (Mermaid state diagram)
- Edge-Case Matrix (handling infeasible routes, driver hour violations, and vehicle capacity overflow)
- Carrier Translation Layer (field mapping rules for {{carrier_integration_format}})
- Performance & Concurrency Controls (worker pool sizing and token bucket rate limits) Keep overall output between 1,200 and 2,000 words.
Self-review
- Ensure all variables in {{routing_constraints}} are represented as validated fields in the request schema.
- Check that the asynchronous polling headers (e.g., Retry-After) and webhook signature verifications are defined.
- Verify that the degraded fallback mechanism handles solver timeouts without data corruption.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.