Design a Freight Trip Capacity Matching Platform
Design a marketplace where truck owners publish trips and shippers find and reserve compatible capacity by origin, destination, time, and weight.
Problem statement
For this exercise, assume truck owners publish planned trips with an origin, destination, departure window, route corridor, vehicle capacity, available weight, and booking policy.
Shippers search with source, destination, time window, weight, and optional service constraints, inspect compatible trips, and request a reservation. Owners may accept automatically or manually.
Design authoritative trip and capacity state, geospatial candidate retrieval, ranking, reservation concurrency, APIs, event propagation, cancellation, and failure recovery. Payments, pricing optimization, identity verification, and live vehicle dispatch are out of scope.
What to build
- A truck owner can create, update, pause, or cancel a versioned trip and expose its route, time window, and reservable capacity.
- A shipper can search by origin, destination, time, weight, and service constraints and receive a stable page of eligible trips with match reasons.
- A shipper can idempotently request capacity without oversubscribing the trip, and manual or automatic acceptance reaches one durable outcome.
- Authorized cancellation or expiry releases capacity exactly once and keeps trip, request, and reservation history auditable.
At scale
- For this exercise, assume 5 million active truck owners, 20 million future trips, and peaks of 50,000 trip updates and 100,000 searches per second.
- Return the first stable search page within 500 milliseconds at p95 and make ordinary trip changes searchable within one minute.
- Held plus confirmed reserved weight must never exceed a trip's published capacity, even under retries, concurrent requests, and owner edits. A capacity reduction below that live allocation is rejected; releasing or revoking holds requires an explicit atomic policy before the lower capacity can commit.
- A paused, canceled, or capacity-exhausted trip must reject new reservation commits immediately even if search indexes and cached pages remain stale.