# Memgraph in supply chain

> **Info**
>
> Before diving into this guide, we recommend starting with the [Deployment best practices](https://memgraph.com/docs/deployment/best-practices)
> page. It provides foundational, use-case-agnostic advice for deploying Memgraph in production.
>
> This guide builds on that foundation, offering additional recommendations tailored to supply chain workloads.
> In cases where guidance overlaps, consider the information here as complementary or overriding, depending on the
> unique needs of your use case.

## Is this guide for you?

This guide is for you if you're operating a supply chain network where visibility and optimization of your supply chain topology is crucial.
You'll benefit from this content if:

- You need to perform **root-cause analysis** across your supply chain to identify **bottlenecks and delays**
  (e.g., why an order is late, which supplier/route/warehouse is the cause).
- You want to run **impact analysis (what‑if scenarios)** to evaluate downstream effects of investing in your topology,
  or changing the configuration and behaviour of your assets, without compromising the original graph structure.
- You need **multi-hop pathfinding** with complex business logic routing capabilities.
- You want to maintain a **digital twin** of your supply chain to track and monitor changes in real-time with an observability system.
- You ingest events from **ERP/IoT** systems and need consistent read performance while updates are continuously applied.

## Why choose Memgraph for supply chain use cases?

- **In-memory architecture**: Delivers fast, consistent, and predictable response times for interactive planning, diagnostics, and operational dashboards.
- **Path traversals with advanced filtering**: Memgraph’s deep path traversal capabilities provide superior, flexible pathfinding with
  rich filtering, hop limits, and custom cost functions—ideal for complex business constraints like capacity management, predictive analytics,
  finding shortest paths inside your network, and others. Learn more in the
  [Deep path traversal algorithms](https://memgraph.com/docs/advanced-algorithms/deep-path-traversal).
- **Non-blocking reads and writes (MVCC)**: Ensure planners and operators get fast insights while real-time updates flow from upstream systems.
- **Snapshot isolation by default**: Guarantees consistent views of the network for reproducible analysis and decision-making.
- [Fine-grained access control](https://memgraph.com/docs/database-management/authentication-and-authorization/role-based-access-control#fine-grained-access-control):
  Enforce privilege access for planners, partners, and vendors so users and team members only see what they should.
- [Graph visualization (Memgraph Lab)](https://memgraph.com/docs/memgraph-lab): Make your supply chain team members get the observability of the whole supply chain at
  one glance of an eye. Visualizations with Memgraph Lab are definitely a more powerful view than clunky row table data with no insights
  into what's several levels deep in the chain.

## What is covered?

The suggestions for supply chain workloads complement several key sections in the
[general suggestions guide](https://memgraph.com/docs/deployment/best-practices). These sections offer important context and
additional best practices tailored for performance, stability, and scalability in production:

- [Choosing the right Memgraph flag set](https://memgraph.com/docs/deployment/best-practices#choosing-the-right-memgraph-flag-set)  
  Optimize runtime behavior for streaming updates and long-running analytics.

- [Choosing the right Memgraph storage mode](https://memgraph.com/docs/deployment/best-practices#choosing-the-right-memgraph-storage-mode)  
  Select between transactional durability and multithreaded ingestion for your workload.

- [Importing mechanisms](#importing-mechanisms)  
  Plan ingestion from streams and batch sources (ERP/WMS/TMS/IoT).

- [Optimizing supply chain analysis](#optimizing-supply-chain-analysis)
  Set of skills every graph expert needs to have in their pocket, in order to receive instant insights from the supply chain.

- [Enterprise features you might require](#enterprise-features-you-might-require)  
  Secure multi-user environments and ensure governance.

- [Interact with your supply chain using GraphRAG](#interact-with-your-supply-chain-using-graphrag)
  If you want to faciliate AI in your business initiatives, it's important to ground the truth in your data and eliminate
  LLM hallucinations.

## Choosing the right Memgraph flag set

Supply chain updates often arrive as standardized messages where not every property changes.
To reduce write overhead during high-throughput ingestion, consider:

```bash
--storage-delta-on-identical-property-update=false
```

With this setting, Memgraph creates delta records only for properties that actually changed, improving throughput when many updates repeat existing values.
All available flags are listed in the [Configuration](https://memgraph.com/docs/database-management/configuration) section. This flag is commonly useful when you're using batch
imports in bulk, or streaming imports where a subset of the properties changes while the rest remain standardized.

If you plan to power natural-language interfaces for operators and planners ([see GraphRAG below](#interact-with-your-supply-chain-using-graphrag)), enable constant-time schema retrieval:

```bash
--schema-info-enabled=true
```

This drastically reduces time to provide schema to an LLM, improving responsiveness.

## Choosing the right Memgraph storage mode

Supply chain systems vary between operational (durable) and analytical (what‑if, simulations) needs.
Use the mode that best aligns with your requirements:

- Use `IN_MEMORY_TRANSACTIONAL` if you require **ACID guarantees**, **replication**, or **high availability**.
- Use `IN_MEMORY_ANALYTICAL` if you prioritize **multithreaded ingestion**, **simulations**, or **read-only analytics** where you don’t need transactional rollback.

Learn more about storage modes in the [Storage memory usage](https://memgraph.com/docs/fundamentals/storage-memory-usage#storage-modes) documentation.

## Importing mechanisms

Memgraph natively integrates with **data streams** (e.g., Kafka) and supports **batch imports**. For multi-source supply chain data (ERP/IoT):

- Use drivers or native stream integrations for near-real-time updates.
- If you have multiple concurrent writers, use drivers with **retryable (managed) transactions** to handle transient conflicts during bursts.
- Keep ingestion **idempotent** to allow safe replays.

See [Data streams](https://memgraph.com/docs/data-streams) and the high-throughput guide’s advice on
[conflicting transactions](https://memgraph.com/docs/help-center/errors/transactions#conflicting-transactions).

## Optimizing supply chain analysis

### Deep path traversals for routing and what‑if analysis
Use deep path traversals to compute feasible routes under complex business rules (capacity, cost, time windows, risk exposure):

```cypher
// Example: cost-aware pathfinding from a supplier to a store with custom weight
MATCH path=(s:Supplier {id: $supplierId})-[:ROUTES_TO|SUPPLIES*WSHORTEST (r, n | coalesce(r.cost, 1)) total_cost]->(t:Store {id: $storeId})
RETURN path, total_cost;
```

You can filter expansions by properties (e.g., allowed carriers, max lead time, geo restrictions), upper-bound hops,
or composite weights. See
[Deep path traversal algorithms](https://memgraph.com/docs/advanced-algorithms/deep-path-traversal).

### Map properties and nested indices
Supply chains often carry rich, semi-structured payloads (e.g., shipment/ASN details, customs data). Store JSON-like maps and index nested fields:

```cypher
CREATE INDEX ON :Shipment(details.status);
```

Nested indices speed up filters like `WHERE shipment.details.status = 'IN_TRANSIT'` without over-normalizing your model.
Learn more about indices in [Indexes](https://memgraph.com/docs/fundamentals/indexes#label-property-index).

## Enterprise features you might require

- **Role-based access control (RBAC) and label-based access control (LBAC)**  
  Ensure users only access data they are permitted to see—e.g., region-specific planners, vendor portals, or carrier-limited views. Learn more in
  [Role-based access control](https://memgraph.com/docs/database-management/authentication-and-authorization/role-based-access-control).

- **Replication and high availability**  
  Keep planning and operational systems online with leader–replica setups and automatic failover. See
  [High availability](https://memgraph.com/docs/clustering/high-availability) and [Replication](https://memgraph.com/docs/clustering/replication).

- **Multi-tenancy**  
  Isolate per business unit, brand, or customer. See [Multi-tenancy](https://memgraph.com/docs/database-management/multi-tenancy).

## Interact with your supply chain using GraphRAG

Out of the box, you can enable natural-language interaction over your supply chain graph using GraphRAG tools and GraphChat in Memgraph Lab.
This is especially useful for non-technical users who want quick answers like “Why is order 12345 late?” or “What’s the cheapest route if port X is congested?”

- See the dedicated guide: [Memgraph in GraphRAG use cases](https://memgraph.com/docs/deployment/workloads/memgraph-in-graphrag)
- When integrating with open-source frameworks, include constant-time schema retrieval in your pipeline:

```cypher
SHOW SCHEMA INFO;
```

This helps LLMs construct valid Cypher quickly.
