Customers need to look up an order using an authenticated account or a secure tracking link and see its current status, estimated delivery window, and relevant milestones. The system should track the lifecycle from placement and payment through fulfillment, shipment, delivery, cancellation, and return where applicable. Customers should be able to receive status notifications and view a history of changes.
Businesses and support agents need to search orders, inspect the same timeline, and publish or correct operational updates with appropriate permissions and audit history. The system should ingest updates from internal order and fulfillment systems, carriers, and delivery partners, while deduplicating repeated events and handling events that arrive late or out of order.
Prioritize correctness, availability, and clear freshness guarantees: a newly accepted update should normally appear within seconds, while the authoritative order and payment systems remain the source of truth for their respective data. Provide secure access control, privacy-preserving tracking links, encryption, auditability, and retention policies. Scale reads substantially above writes, support regional growth, and degrade gracefully when a carrier or notification provider is unavailable.
Assume 10 million orders per day, with an average of 10 lifecycle events per order. That is about 100 million events per day, or roughly 1,160 events per second on average. If peak traffic is 5–10 times the average, plan for approximately 6,000–12,000 event writes per second, with capacity to scale consumers independently.
Assume 50 million daily tracking views, averaging about 580 reads per second and peaking around 3,000–6,000 reads per second. If a materialized tracking record and its indexes consume roughly 2 KB per order, 10 million new orders per day add about 20 GB of primary order-tracking data daily before indexes, replicas, and retention controls. A 1 KB event payload at 100 million events per day adds about 100 GB daily in raw event storage.
These estimates favor a horizontally scalable event log and partitioned databases, plus caching for frequently viewed orders. Retain a compact current-state record for fast reads and keep the full event history in a store designed for append-heavy access. Actual sizing should be validated with payload sizes, retention requirements, regional distribution, and measured peak-to-average ratios.
GET /v1/orders/{orderId}/tracking returns the current status, latest update time, delivery estimate, and an ordered milestone list. Require customer authentication or a high-entropy, revocable tracking token; do not treat an order ID alone as authorization. Support If-None-Match or a version cursor for efficient polling, and optionally expose a WebSocket or server-sent-events subscription for live updates.
GET /v1/orders/{orderId}/events?cursor={cursor} returns paginated history for clients that need incremental refresh. POST /v1/orders/{orderId}/subscriptions can set notification preferences. Responses should include a stable status code, event time, ingestion time, and a freshness indicator so clients can distinguish a delayed carrier feed from a current update.
Internal systems can publish events through an authenticated endpoint or, preferably at high volume, a durable message bus. An example event includes eventId, orderId, source, eventType, occurredAt, receivedAt, and validated details. Make writes idempotent using eventId; return an accepted response only after durable acceptance. Business search and correction endpoints require role-based authorization, input validation, rate limits, and audit logging.
Use a relational or distributed SQL store for order-tracking projections where transactional updates, constraints, and support queries are important. The main entities are OrderTracking (order ID, customer ID, current status, ETA, version, updated time), TrackingEvent (event ID, order ID, type, source, occurred and received times, payload), and OrderItem where item-level tracking is needed. Index the current record by order ID and customer ID; partition events by order ID or a time-aware key to support ordered history retrieval.
Keep operational order details in the existing order service rather than duplicating sensitive or mutable fields unnecessarily. Store event history as append-only data, with a materialized current-state projection for low-latency reads. Use object storage or a suitable long-retention event store for archived history if required. Redis or another distributed cache can hold hot tracking projections, keyed by order ID and invalidated or refreshed on projection updates.
The event log is the durable record of tracking updates; projections and caches are derived and can be rebuilt. Consumers should apply events idempotently and use a per-order version or deterministic precedence rules to avoid regressing status when events arrive out of order. Preserve both event occurrence time and ingestion time. Define retention, deletion, and anonymization policies to meet privacy and regulatory requirements, and audit privileged corrections.
Web and mobile clients access the system through a load balancer and API gateway. The gateway authenticates users, enforces rate limits, and routes tracking reads to a Tracking API. That API reads a cached current-state projection when possible and falls back to the tracking database. A separate history endpoint retrieves paginated events without forcing every request to scan the full timeline.
Order, warehouse, carrier, and delivery systems publish updates to an ingestion service or directly to a durable event bus. The ingestion layer validates and deduplicates events, then publishes canonical events to the bus. Projection workers update the tracking database and cache, while notification workers send email, SMS, or push updates according to customer preferences. A dead-letter queue and operational dashboards support investigation and replay.
The tracking platform owns the customer-facing status timeline and its derived current-state view; upstream order, payment, inventory, and carrier systems own their underlying business facts. This separation reduces coupling and makes it possible to add a carrier or notification vendor without changing customer APIs. Metrics, traces, structured logs, and audit records span the ingestion and read paths.
An upstream order or carrier system emits a status event with a stable event ID and source timestamp. The ingestion service authenticates the producer, validates the schema and order reference, and checks idempotency. It then durably publishes the canonical event to the event bus; if publication fails, the producer retries with the same ID or uses an outbox pattern to avoid losing an update between its own database commit and event publication.
A projection worker consumes the event, applies ordering and transition rules, appends it to history, and updates the current-state projection using a version check. It refreshes or invalidates the cache and emits a notification task when policy says a customer should be informed. Failed processing is retried with backoff and eventually placed on a dead-letter queue for review.
A customer requests tracking through the gateway. After authentication or tracking-token validation, the Tracking API checks the cache and returns the current status and ETA when available. On a cache miss, it reads the projection store, repopulates the cache, and returns a stable response with its update timestamp and version. The client may poll with a cursor or subscribe to a live channel; either way, authorization is checked for each order.
API gateway and identity: terminate TLS, authenticate customers and business integrations, apply authorization, quotas, and abuse controls. Tracking API: serve current state and paginated history, enforce access policy, and provide cache-aware reads. Event ingestion: validate source-specific payloads, normalize status vocabulary, deduplicate event IDs, and reject or quarantine malformed messages.
Event bus: buffer bursts, preserve partition ordering for a given order where configured, and decouple producers from consumers. Projection workers: update append-only history and the current-state projection idempotently. Notification service: apply user preferences and templates, then call external email, SMS, or push providers with retry and delivery tracking.
Tracking database and cache: support durable projections and low-latency reads. Dead-letter and replay tooling: isolate poison events and allow safe reprocessing. Observability and audit: measure event lag, API latency, error rates, notification outcomes, and privileged changes. These components should expose health checks and be deployable and scalable independently.
A strongly consistent read from the primary database provides the freshest projection but can add latency and reduce availability during a regional or database incident. Serving a cached projection improves speed and resilience but may briefly show stale status. For tracking, a sensible default is eventual consistency with a visible last-updated time and a bounded freshness target; use a primary read for sensitive support workflows or when a client explicitly requests freshness.
An event-driven design isolates upstream systems and absorbs spikes, but introduces operational complexity: duplicate delivery, delayed events, reordering, replay, and eventual consistency. A synchronous call from every carrier or order system to the tracking database is simpler initially, but couples availability and throughput to those producers and makes burst handling harder.
Keeping complete history in the primary relational database simplifies queries and transactions, while an append-oriented event store plus a compact projection can scale retention and write volume more effectively. The latter requires projection rebuilding and schema evolution discipline. Push updates improve perceived real-time behavior but add connection and delivery complexity; polling is simpler and often sufficient, so support polling first and add server-sent events or WebSockets where product needs justify them.
Duplicate or out-of-order events: deduplicate by event ID and apply per-order versioning or explicit transition precedence. Keep occurrence and ingestion timestamps, and do not blindly replace a newer state with a late-arriving older event. Malformed or unknown events: validate schemas, quarantine them, alert owners, and place repeatedly failing messages in a dead-letter queue rather than blocking a partition indefinitely.
Event bus or producer outage: use producer-side outboxes or durable retry buffers, monitor consumer lag, and replay safely after recovery. Database outage: continue durable bus ingestion where possible, pause or back off projection consumers, serve cached data with a freshness warning, and prevent clients from interpreting stale state as current. Rebuild projections from the event log after data corruption, with controlled replay rate.
Carrier or notification provider outage: retry with exponential backoff and jitter, use circuit breakers, and fail over to another provider where supported. Do not block status visibility on notification delivery. Bad ETA: label estimates as estimates, record their source and update time, and suppress implausible values pending validation. Unauthorized access or enumeration: use high-entropy tracking tokens, short-lived or revocable links, rate limits, monitoring, and minimal response data; audit staff access and corrections.
Add live server-sent events or WebSockets for customers who need updates without polling, richer delivery windows, map-based location sharing with explicit consent, and proactive notifications for exceptions such as delays or failed delivery attempts. Allow customers to configure channels and notification frequency while avoiding duplicate messages across providers.
Improve estimates using historical route, carrier, weather, and fulfillment data, but communicate confidence and avoid presenting predictions as guarantees. Add a unified timeline for split shipments, partial fulfillment, returns, exchanges, and pickup orders. Provide accessible, localized status descriptions rather than exposing raw internal event codes.
Expand multi-region read serving and disaster recovery based on measured availability needs; partition data by tenant or geography if workload growth warrants it. Add automated event replay and projection rebuild tooling, schema compatibility checks, and anomaly detection for stalled or contradictory order timelines. Use privacy-aware analytics to identify fulfillment bottlenecks while enforcing retention and deletion requirements.
Reading a solution is not the same as producing one under interview pressure. Design it on the whiteboard and get scored feedback.