Building a Real-Time Supply Chain Graph

Building a Real-Time Supply Chain Graph

●2 ●40 ●92
calendar_today • schedule13 min read

Building a Real-Time Supply Chain Graph

There is a strange thing about modern supply chains.

A product can be sitting in a warehouse in one country, waiting for a truck in another, while its raw materials are still somewhere else. A purchase order can exist in a database even though the physical goods have not moved. A truck can be halfway between two cities while the inventory system still thinks the shipment is “in transit.” A supplier can report that everything is fine while a single delayed component is quietly becoming the bottleneck for hundreds of downstream products.

The difficult part is not necessarily storing all this information.

The difficult part is understanding how everything is connected while it is changing.

That is where a real-time supply chain graph becomes interesting.

Instead of representing a supply chain as a collection of tables, dashboards, spreadsheets, and isolated applications, we can represent it as a continuously changing graph.

Suppliers become nodes.

Factories become nodes.

Warehouses become nodes.

Vehicles become nodes.

Products become nodes.

Orders become nodes.

Routes become relationships.

Inventory becomes state.

Shipments become moving state.

Dependencies become edges.

Events become changes to the graph.

Suddenly, the supply chain stops looking like a collection of transactions and starts looking like a living system.

And that is the system I want to explore.


The Problem With Traditional Supply Chain Software

Most business applications are designed around transactions.

You create a purchase order.

You receive inventory.

You create a shipment.

You update its status.

You create an invoice.

You record a delivery.

This works.

But supply chains are not fundamentally transactional systems.

They are dependency systems.

Imagine a company producing a laptop.

The final laptop might depend on:

  • a processor,
  • memory,
  • storage,
  • display,
  • battery,
  • keyboard,
  • motherboard,
  • chassis,
  • packaging,
  • logistics providers,
  • warehouses,
  • manufacturing facilities,
  • and dozens of upstream suppliers.

Now imagine the battery supplier experiences a delay.

The interesting question is not:

“Which shipment is delayed?”

The interesting question is:

“What does this delay affect?”

That question requires traversing relationships.

The battery affects the laptop.

The laptop affects an order.

The order affects a customer.

The customer affects a delivery commitment.

The delivery commitment affects an entire operational plan.

A conventional relational database can represent these relationships.

But a graph makes them first-class concepts.


The Supply Chain as a Graph

At its simplest, we can model a supply chain as:

Supplier
   |
   | supplies
   v
Component
   |
   | used by
   v
Factory
   |
   | produces
   v
Product
   |
   | stored at
   v
Warehouse
   |
   | shipped through
   v
Transport Route
   |
   | delivers to
   v
Customer

But a real system is considerably more complicated.

Consider:

Supplier A
    |
    v
Component X ----\
                 \
Supplier B ---> Component Y ---> Factory A ---> Product P
                                      |
                                      v
                                  Warehouse A
                                      |
                            +---------+---------+
                            |                   |
                            v                   v
                       Customer A          Customer B

Now add time.

A supplier might normally deliver Component X in three days.

Today it might take six.

That changes the graph.

Add inventory.

The factory might have enough Component X for only 18 hours.

The graph changes again.

Add transportation.

A shipment might be delayed at a distribution hub.

The graph changes again.

A real-time supply chain graph therefore isn't simply a graph of what exists.

It is a graph of what exists, where it is, what it depends on, and what is happening right now.


Designing the Core Data Model

The first architectural decision is identifying the entities.

A useful starting model might contain:

Supplier
Factory
Warehouse
Store
Customer
Product
Component
Shipment
Vehicle
PurchaseOrder
SalesOrder
Route
Location
Inventory
Event

Each entity becomes a node.

Relationships become edges.

For example:

Supplier --SUPPLIES--> Component
Component --USED_BY--> Product
Factory --PRODUCES--> Product
Product --STORED_AT--> Warehouse
Warehouse --FULFILLS--> Order
Shipment --CARRIES--> Product
Vehicle --FOLLOWS--> Route
Route --CONNECTS--> Location

But there is an important distinction.

Not every piece of information should become a node.

Some information belongs as properties.

For example:

{
  "id": "component-938",
  "name": "Battery Module",
  "quantity": 1200,
  "unit": "pieces"
}

Relationships can also carry properties.

For example:

Supplier A
    |
    | SUPPLIES
    | lead_time = 5 days
    | capacity = 20,000/month
    v
Component X

This is where graph modeling becomes powerful.

The relationship itself contains information.


Adding Time to the Graph

A static graph is useful.

A temporal graph is much more interesting.

Consider:

Warehouse A
    |
    | shipment
    v
Warehouse B

That tells us almost nothing about the actual movement.

Instead, we want:

Shipment #4812

Origin:
Warehouse A

Destination:
Warehouse B

Departure:
10:30

Expected arrival:
18:00

Current location:
Route Segment 17

Status:
In transit

Now the shipment has temporal state.

The system can continuously update:

10:30 → Departed
12:00 → Highway Segment 4
14:00 → Highway Segment 9
16:30 → Distribution Hub
18:00 → Warehouse B

The graph is changing over time.

This means we need an event-driven architecture.


Events Become the Pulse of the System

Instead of constantly asking every service:

“What is your current state?”

we can allow systems to publish events.

For example:

{
  "event": "shipment.location.updated",
  "shipment_id": "4812",
  "location": "hub-17",
  "timestamp": "2026-09-22T15:42:00Z"
}

Another event:

{
  "event": "inventory.updated",
  "warehouse_id": "WH-12",
  "product_id": "P-100",
  "quantity": 842,
  "timestamp": "2026-09-22T15:43:12Z"
}

Another:

{
  "event": "supplier.delay.reported",
  "supplier_id": "SUP-91",
  "component_id": "COMP-22",
  "expected_delay_hours": 18
}

These events become the mechanism through which the graph evolves.

A simplified architecture could look like:

                    +----------------+
                    | ERP / WMS / OMS|
                    +-------+--------+
                            |
                            v
                    +---------------+
                    | Event Gateway |
                    +-------+-------+
                            |
                            v
                    +---------------+
                    | Event Stream  |
                    +-------+-------+
                            |
             +--------------+--------------+
             |              |              |
             v              v              v
       Graph Builder   Analytics       Alerts
             |
             v
       Supply Chain Graph
             |
             v
        Graph API
             |
      +------+------+
      |             |
      v             v
   Dashboard      Applications

The graph becomes a continuously updated representation of the physical and operational world.


Why Event Sourcing Fits Naturally

A particularly interesting design is to treat events as historical truth.

Instead of simply storing:

shipment.status = delivered

we preserve the sequence:

ShipmentCreated
ShipmentDispatched
ShipmentDeparted
ShipmentLocationUpdated
ShipmentDelayed
ShipmentArrived
ShipmentDelivered

This gives us something incredibly valuable:

history.

We can ask:

Where was the shipment two hours ago?

Or:

When did the delay actually begin?

Or:

How many times did the expected delivery time change?

Or:

Which suppliers repeatedly caused downstream schedule changes?

The graph becomes more than a current-state database.

It becomes a temporal model of the supply chain.


The Real-Time Graph Engine

The graph engine is responsible for converting events into graph mutations.

Suppose this arrives:

{
  "event": "shipment.departed",
  "shipment": "SHIP-8821",
  "warehouse": "WH-1"
}

The graph engine could perform something conceptually like:

Shipment SHIP-8821
    |
    | DEPARTED_FROM
    v
Warehouse WH-1

Then a location update arrives:

{
  "event": "shipment.location.updated",
  "shipment": "SHIP-8821",
  "location": "LOC-22"
}

The graph changes:

Shipment SHIP-8821
    |
    | CURRENTLY_AT
    v
Location LOC-22

The important thing is that the graph is not manually rebuilt.

It is continuously transformed by events.


Choosing the Storage Layer

There are several ways to implement the graph.

A dedicated graph database can represent relationships naturally.

Examples include:

  • Neo4j
  • Amazon Neptune
  • JanusGraph
  • ArangoDB

A relational database can also represent graph structures through relationship tables.

For example:

nodes
-----
id
type
properties

and:

edges
-----
source_id
target_id
relationship
properties

This can work surprisingly well.

For larger architectures, however, we might separate responsibilities.

For example:

PostgreSQL
     |
     | transactional state
     v
Kafka
     |
     | events
     v
Graph Database
     |
     | relationships
     v
Redis
     |
     | hot state
     v
API

The key architectural principle is not:

“Use a graph database because graphs are cool.”

The principle is:

Store data according to the access patterns the system actually needs.


Real-Time Location Tracking

Transportation is one of the most dynamic parts of the graph.

Vehicles can emit location updates:

{
  "vehicle_id": "TRUCK-44",
  "latitude": -12.97,
  "longitude": 28.64,
  "speed": 61,
  "timestamp": "2026-09-22T16:20:00Z"
}

The system can associate that vehicle with:

Vehicle
   |
   | TRANSPORTS
   v
Shipment
   |
   | CONTAINS
   v
Product

Now the location of the vehicle can indirectly become information about the shipment.

This creates a useful concept:

state propagation.

A change in one node can affect the interpretation of other nodes.


Dependency Traversal

Suppose a factory is waiting for a component.

We can traverse:

Factory
  ↓
Product
  ↓
Component
  ↓
Supplier

Or the opposite direction:

Supplier
  ↓
Component
  ↓
Factory
  ↓
Product
  ↓
Orders
  ↓
Customers

This is where a supply chain graph becomes particularly powerful.

We can ask questions such as:

What products depend on this component?

Which factories depend on this supplier?

Which orders depend on this shipment?

Which warehouses are downstream from this distribution center?

Which customers are connected to inventory currently in transit?

These are graph queries rather than simple database lookups.


Detecting Bottlenecks

One of the most interesting applications is bottleneck detection.

Imagine:

Supplier A
   |
   v
Component X
   |
   +------> Factory A
   |
   +------> Factory B
   |
   +------> Factory C

Component X has three downstream factories.

If the supplier suddenly reduces available capacity, the graph can identify the dependency fan-out.

A node with many downstream dependencies deserves attention.

This doesn't automatically mean it is a bottleneck.

The system still needs contextual information:

inventory available
+
consumption rate
+
incoming shipments
+
supplier capacity
+
lead time
+
alternative suppliers
=
dependency risk context

The graph provides the relationships.

Analytics provides interpretation.


Inventory as a Dynamic Property

Inventory is not just a number.

It is a number changing over time.

For example:

Warehouse A
Product P
Quantity = 2,400

Then:

Sale:
-100

Receipt:
+500

Transfer:
-300

Adjustment:
-20

Current inventory:

2,480

But the graph can also represent inventory in motion:

Warehouse A
   |
   | 1,000 units
   v
Shipment 8821
   |
   v
Warehouse B

This gives us the idea of network inventory.

Instead of asking:

“How much inventory do we have?”

we can ask:

“How much inventory exists across the entire network, where is it, and how is it moving?”

That is a much richer question.


Building a Supply Chain Timeline

A graph can also generate a timeline.

Imagine a product order:

Order Created
      ↓
Inventory Reserved
      ↓
Shipment Created
      ↓
Shipment Dispatched
      ↓
Transit
      ↓
Distribution Hub
      ↓
Final Delivery

Every event gets a timestamp.

We can reconstruct the lifecycle of the order.

This makes debugging easier.

Suppose a customer asks why an order arrived late.

Instead of checking five different systems manually, the system can reconstruct:

Order #5001

08:10 — Order created
08:11 — Inventory reserved
09:00 — Shipment created
10:20 — Shipment dispatched
14:40 — Vehicle delayed
18:15 — Shipment arrived at hub
20:30 — Final delivery

The graph becomes a story.


Real-Time Alerts

The graph can feed an alerting engine.

For example:

IF

supplier delay
AND
inventory below threshold
AND
no alternative supplier
AND
downstream demand exists

THEN

create supply chain alert

Another rule:

IF

shipment delayed
AND
delivery deadline approaching

THEN

recalculate expected arrival

Another:

IF

warehouse capacity > threshold

THEN

flag capacity constraint

These aren't necessarily machine-learning problems.

Many are rules.

And that is an important engineering principle:

not every intelligent system needs artificial intelligence.

Sometimes a carefully designed graph plus deterministic rules is enough.


Adding Machine Learning

Once the graph exists, machine learning becomes more interesting.

Instead of training a model on isolated records, we can derive features from the network.

For example:

supplier reliability
route volatility
average delay
inventory velocity
dependency depth
supplier concentration
warehouse congestion
historical delivery deviation

These features can feed prediction models.

A model could estimate:

expected delivery time

or:

probability of delay

or:

expected inventory depletion

The graph supplies the context.

Machine learning supplies probabilistic inference.

This combination can become much more useful than treating every shipment as an independent record.


The Graph API

Applications need a clean interface.

We might expose:

GET /graph/products/{id}

Returning:

{
  "product": "Laptop X",
  "components": [],
  "suppliers": [],
  "factories": [],
  "warehouses": [],
  "shipments": [],
  "orders": []
}

We could also expose relationship traversal:

GET /suppliers/{id}/dependencies

Or:

GET /shipments/{id}/network-impact

Or:

GET /warehouses/{id}/incoming

Or even:

GET /graph/paths?from=supplier-1&to=customer-42

The API turns the graph into a reusable platform.


Building the Visualization

The graph becomes even more interesting visually.

Imagine a dashboard:

        Supplier A
             |
             v
       Component X
          /     \
         /       \
        v         v
   Factory A   Factory B
       |           |
       v           v
 Warehouse A   Warehouse B
       |           |
       +-----+-----+
             |
             v
         Customers

Nodes can represent entities.

Edges can represent relationships.

Node size could represent throughput.

Edge thickness could represent volume.

Animations could represent movement.

Status indicators could represent operational conditions.

A user could select a supplier and immediately see its downstream network.

Select a warehouse and see:

incoming shipments
outgoing shipments
inventory
suppliers
customers
routes
capacity

The interface becomes a map of the organization.


Handling Millions of Events

Real-time systems eventually encounter scale.

Imagine:

10,000 vehicles
500,000 shipments
millions of inventory updates
millions of orders
thousands of suppliers

The architecture needs to avoid processing everything synchronously.

Event streaming becomes important.

A possible design:

                    Producers
                       |
        +--------------+--------------+
        |              |              |
       ERP            GPS            WMS
        |              |              |
        +--------------+--------------+
                       |
                       v
                 Event Broker
                       |
          +------------+------------+
          |            |            |
          v            v            v
      Graph Writer  Analytics    Alerting
          |
          v
     Graph Storage
          |
          v
        API

Partitioning can distribute event processing.

Caching can handle frequently accessed information.

Materialized views can accelerate common queries.

Historical events can be archived.

The graph does not need to answer every query from raw events.


Consistency Becomes an Engineering Problem

Real-time systems rarely update everything simultaneously.

Suppose:

GPS says:
Vehicle is at Location A

while:

ERP says:
Shipment is still at Warehouse B

Which one is correct?

The answer may be:

both are correct within their own data domains.

The vehicle can be physically moving while the business transaction remains open.

This is why the graph should preserve:

  • source,
  • timestamp,
  • confidence,
  • event type,
  • update time.

For example:

{
  "location": "A",
  "source": "GPS",
  "observed_at": "...",
  "received_at": "..."
}

Now the system knows not only the value, but where that value came from.


The Importance of Provenance

A sophisticated graph should answer:

Why does the system believe this?

Suppose the dashboard says:

Expected delivery: 18:40

The user should be able to inspect the reasoning chain.

Perhaps:

GPS position
+
historical route time
+
current traffic estimate
+
vehicle speed
+
remaining distance
=
estimated arrival

This makes the system more understandable.

Instead of creating a mysterious black box, we create a system whose information can be traced back to events and relationships.


Security

A supply chain graph contains sensitive operational information.

Different users should see different parts of the graph.

A supplier might see:

their shipments
their orders
their delivery schedules

A warehouse manager might see:

warehouse inventory
incoming shipments
outgoing shipments

An executive might see:

network-level metrics

This requires authorization at the graph level.

Not every user should be able to traverse every edge.

Graph permissions can therefore become an important architectural layer.


Building the System Incrementally

A project like this can become enormous very quickly.

I would not start by trying to model the entire global supply chain.

Start with one flow.

For example:

Supplier
   ↓
Warehouse
   ↓
Shipment
   ↓
Customer

Implement:

  1. entities,
  2. relationships,
  3. event ingestion,
  4. graph updates,
  5. real-time queries,
  6. visualization.

Then add:

Factory

Then:

Inventory

Then:

Vehicles

Then:

Routes

Then:

Forecasting

Architecture becomes easier to evolve when the first version solves a narrow problem extremely well.


A Possible Technology Stack

A practical implementation could use:

Backend

Python / Django
or
Node.js / TypeScript

Event streaming

Kafka
Redpanda
RabbitMQ

Graph

Neo4j
Amazon Neptune
ArangoDB
JanusGraph

Relational data

PostgreSQL

Cache

Redis

Frontend

React
TypeScript
WebSockets

Visualization

Cytoscape.js
D3.js
React Flow

Infrastructure

Docker
Kubernetes
Cloud infrastructure

The specific technology is less important than the architecture.

The architecture should preserve the core idea:

Events → State → Relationships → Insights

The Interesting Part: Graph Intelligence

Once the graph becomes sufficiently rich, we can start asking deeper questions.

For example:

What happens if this supplier becomes unavailable?

The system can traverse downstream dependencies.

Supplier
 ↓
Component
 ↓
Factories
 ↓
Products
 ↓
Orders
 ↓
Customers

Another:

What inventory is currently moving toward this warehouse?

The graph can traverse incoming shipment relationships.

Another:

Which products depend on components from multiple suppliers?

That becomes a dependency query.

Another:

Which routes connect the largest number of operational nodes?

That becomes a network analysis problem.

The graph transforms supply chain software from a collection of screens into an environment for asking questions.


From Dashboard to Digital Twin

There is a larger idea hiding inside this architecture.

A sufficiently detailed real-time supply chain graph begins to resemble a digital twin of the supply network.

Not a perfect copy.

A continuously updated operational representation.

Physical world:

supplier
factory
truck
warehouse
product
customer

Digital world:

nodes
relationships
events
state
history
predictions

The physical network changes.

Events describe those changes.

The graph reflects them.

Analytics interprets them.

Applications act on them.

That creates a feedback loop:

Physical World
      ↓
Sensors / Systems
      ↓
Events
      ↓
Supply Chain Graph
      ↓
Analytics
      ↓
Decisions
      ↓
Operational Actions
      ↓
Physical World

This is where the architecture becomes genuinely interesting.


The Supply Chain Is a Living System

I think the most important shift is conceptual.

A supply chain should not be thought of only as:

orders + inventory + transportation

It can be understood as:

entities
+
relationships
+
time
+
movement
+
dependencies
+
events

That is a graph.

And because those relationships continuously change, it is a living graph.

A supplier connects to components.

Components connect to factories.

Factories connect to products.

Products connect to warehouses.

Warehouses connect to shipments.

Shipments connect to routes.

Routes connect to customers.

Every event changes something.

Every change can propagate through the network.

That is why a real-time supply chain graph is such an interesting engineering project.

The hardest part is not drawing circles and lines on a dashboard.

The hard part is creating a reliable digital model of a constantly moving system.

It requires event-driven architecture, temporal data, graph modeling, distributed systems, APIs, visualization, security, analytics, and eventually predictive intelligence.

And perhaps the most interesting outcome is not the dashboard.

It is the ability to ask the supply chain questions that traditional software makes difficult to ask:

What is connected?

What is moving?

What depends on what?

What changed?

What could this change affect?

Where is the network becoming constrained?

What happened before this event?

What is likely to happen next?

When those questions can be answered in real time, the supply chain stops being a collection of disconnected systems.

It becomes something we can observe as a whole.

A network.

A system.

A living graph.

And that is the real project: not building another logistics dashboard, but building a continuously evolving map of how products, people, infrastructure, information, and decisions move through an interconnected world.

Want more #programming & #softwareengineering deep dives?

Join 6,145+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

Merancang Backend Bisnis ISP: API Pelanggan, Paket Internet, Invoice, dan Tiket Support

Masbadar - Mar 13

The Zero-Net-Loss Fleet & The Mercenary Squad: A Live AI Economy

DEVPlank - Aug 4

How AI Is Changing Web Development, and What Developers Still Need to Understand

Daniel Decker - Nov 10

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

Stop Turning Every REST Endpoint into an MCP Tool: A Better Approach to AI Tool Design

zeekwrites - Nov 30
chevron_left
2.6k Points • 134 Badges
Kapiri Mposhi, Zambia. • zambianmillenial.com
58Posts
11Comments
411Connections
Derek Mwale — Where Code Meets Creativity.

Related Jobs

View all jobs →

Commenters (This Week)

5 comments
3 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!