Logistics & Supply Chain

Order Fulfillment Orchestration

End-to-end automation of the delivery cycle: from "Checkout" to "Doorstep". Syncing OMS (Orders), WMS (Warehouse), and TMS (Transport) via Event-Driven Architecture.

15 min
Avg. Processing
Saga
Pattern
Kafka
Messaging

01 The Challenge

Business Problems

The company scaled rapidly, and the monolithic shop couldn't handle logistics complexity. Orders were getting lost between the website and the warehouse.

  • Overselling (Stock Race Condition) Users bought the last item simultaneously because stock updates were delayed by 5-10 minutes.
  • "Spaghetti" Integrations Direct HTTP calls between services created a dependency hell. If the Courier API was down, the Checkout failed.

02 Solution & Artifacts

1. Orchestration Flow (Sequence)

Order Lifecycle SVG
BPMN Diagram showing Order Flow

Solution: We introduced an Event-Driven approach. The Order System (OMS) acts as an Orchestrator, publishing events (`OrderCreated`) that the Warehouse (WMS) and Delivery (TMS) listen to asynchronously.

2. Database Schema (ERD)

ER Diagram for Inventory

Key Design Choice: Separating `Product` (Catalog) from `Inventory` (Stock). This allows one product to be stored in multiple warehouses with real-time stock reservation logic.

3. Logistics API (Snippet)

logistics-v1.yaml
paths:
  /v1/shipments/{id}/status:
    post:
      summary: Update delivery status (Webhook)
      description: Called by external Courier Service
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required: [status, timestamp]
              properties:
                status:
                  type: string
                  enum: [IN_TRANSIT, DELIVERED, FAILED]
                location:
                  type: object
                  properties:
                    lat: { type: number }
                    lng: { type: number }
      responses:
        '200':
          description: Status Updated & Notification Sent

Tech Stack

Kafka / RabbitMQ PostgreSQL Elasticsearch Camunda (BPMN)