Carrier Integration and Rate Normalization Engine Blueprint
Build a robust, low-latency API integration and rate normalization framework across heterogeneous freight carrier protocols.
Use this template when standardizing heterogeneous logistics carrier APIs into a unified internal rate quoting and booking service. It delivers an extensible backend aggregation architecture.
Role: Staff API Platform Engineer specializing in logistics integrations, asynchronous distributed gateways, and schema normalization.
Context
- Target carrier protocol mix: {{carrier_protocols}}.
- Maximum allowable quotation timeout: {{quote_timeout_ms}}.
- Internal standard schema: {{canonical_schema_standard}}.
- Request deduplication and replay safety: {{idempotency_strategy}}.
- Cache invalidation interval: {{caching_ttl_seconds}}.
- Upstream failure tolerance budget: {{error_handling_budget}}.
Task
Architect a high-performance backend carrier integration framework that federates real-time rate shopping, normalizes disparate vendor payloads into {{canonical_schema_standard}}, and guarantees resilient transaction execution across unreliable carrier endpoints.
Method
- Define the API Gateway mediation layer, including request dispatch, scatter-gather concurrency patterns, and dynamic timeout handling.
- Design the translation and adapter pattern matrix converting vendor-specific payloads into {{canonical_schema_standard}}.
- Formulate the concurrency and fan-out orchestrator ensuring aggregate responses return within {{quote_timeout_ms}} even if specific carriers hang.
- Specify the caching and rate-invalidation framework enforcing {{caching_ttl_seconds}} while guarding against stale shipping tariffs.
- Design the transactional booking workflow implementing {{idempotency_strategy}} to eliminate double-booking across distributed systems.
- Structure the circuit breaker and fallback mechanisms aligned with {{error_handling_budget}} to handle degraded carrier APIs.
- Detail distributed tracing, logging, and audit schemas for every outgoing carrier payload and normalized response.
Constraints
- MUST enforce strict scatter-gather cancellation to return available rates before {{quote_timeout_ms}} expires.
- MUST NOT allow non-idempotent booking requests to reach upstream carrier endpoints.
- Adapter modules must be fully isolated to permit adding new carrier protocols without modifying core orchestration logic.
- Error responses from third-party carriers must map cleanly to standardized internal error codes.
Output format
- Gateway Architecture & Concurrency Model: Workflow diagram and detailed description of the scatter-gather engine.
- Canonical Schema Mapping Specification: Data dictionary and mapping table showing source-to-canonical translation.
- Idempotency & Transaction State Machine: Step-by-step state transition table for quote, hold, and book actions.
- Resilience & Fallback Matrix: Rules for handling timeouts, 4xx/5xx carrier responses, and circuit transitions.
- Implementation Code Template: Production-grade backend interface/trait definitions in TypeScript or Go.
Self-review
- Verify that the scatter-gather pattern explicitly handles slow or unresponsive carrier endpoints.
- Confirm that {{canonical_schema_standard}} supports all structural variants present in {{carrier_protocols}}.
- Check that the idempotency mechanism prevents duplicate charges during intermittent network partitions.
- Ensure the five required output sections are distinctly separated and labeled.
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.