Skip to content
HillaryIkhaisPublic

About

Real-time food safety engine that tracks recalls across supply chains and blocks contaminated products at cash registers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

FoodGuard

Autonomous Food Safety Incident Response — Powered by DataHub

"A food contamination alert shouldn't take hours to trace. FoodGuard turns a contamination signal into a verified supply-chain impact map, quarantine actions, and an auditable DataHub incident in seconds."

Core Concept: "A food batch becomes an asset. Its distribution becomes lineage. A contamination alert becomes an incident. The agent turns lineage into action."

Built for DataHub Agent Hackathon Apache 2.0 License Next.js TypeScript


The Problem

When a foodborne contamination event is discovered, the hardest question is finding out exactly where the food went.

A single contaminated harvest batch can move through processors, cold-storage facilities, distributors, retailers, and institutional buyers before an alert is issued.

Traditional incident response often depends on manually joining information across inventory systems, spreadsheets, logistics records, and databases.

That creates a dangerous gap between detecting contamination and knowing exactly what needs to be isolated.

FoodGuard closes that gap.


What FoodGuard Does

FoodGuard is an AI-driven food safety agent that uses DataHub's metadata graph and lineage as the context layer for supply-chain incident response.

When a contamination alert identifies a high-risk pathogen or affected batch, FoodGuard:

1. Detects the incident

Ingests a contamination alert and identifies the affected pathogen, product, and source batch.

2. Traverses supply-chain lineage

Starting from the affected batch, FoodGuard follows DataHub lineage across four downstream tiers:

Farm / Harvest Batch
        │
        ▼
Processing Facility
        │
        ▼
Cold Storage Hub
        │
        ▼
Retailers / School Districts

3. Quantifies the blast radius

The agent determines:

  • Affected downstream locations (32 Stores, 14 School Districts)
  • Affected inventory units (14,500 Units)
  • Exposed consumers (~184,000 Consumers)
  • Estimated financial exposure ($384,400 USD)
  • Affected supply-chain nodes

4. Generates mitigation actions

FoodGuard synthesizes store-level quarantine actions, including barcode freezes (SKU-9921) and inventory lockouts.

5. Writes the incident back to DataHub

The resulting safety incident is emitted back into DataHub's metadata layer with quarantine and recall metadata, creating an auditable record of what happened and what actions were taken.


Why DataHub?

FoodGuard isn't a chatbot sitting beside a data catalog. DataHub is the agent's source of truth.

The critical reasoning step is the lineage traversal:

FDA / USDA Alert
       │
       ▼
Affected Batch
       │
       ▼
DataHub Lineage Graph
       │
       ├── Processing Facility
       │       │
       │       └── Cold Storage
       │               │
       │               ├── Retailer A
       │               ├── Retailer B
       │               └── School District
       │
       ▼
Affected Downstream Assets
       │
       ▼
Quarantine Actions
       │
       ▼
SAFETY_RECALL Incident
       │
       ▼
DataHub Metadata

This makes DataHub more than a lookup layer. The graph becomes the operational context that allows the agent to reason about the incident.


DataHub Integration & Data Model

FoodGuard models the physical food supply chain as DataHub metadata.

Entities

Supply-chain objects are represented as DataHub datasets:

Entity DataHub Representation
Harvest Batch Dataset (urn:li:dataset:(...,valley_farms.batch_894,PROD))
Processing Lot Dataset (urn:li:dataset:(...,pacific_fresh.line_2,PROD))
Cold Storage Inventory Dataset (urn:li:dataset:(...,seattle_cold.bay_4,PROD))
Retail Inventory Dataset (urn:li:dataset:(...,safeway_wa.stores_18,PROD))
School District Inventory Dataset (urn:li:dataset:(...,seattle_schools.kitchens_14,PROD))

Lineage

FoodGuard uses explicit lineage relationships to represent movement and transformation:

  • TRANSFORMED_INTO
  • LOGISTICS_DISPATCH
  • FINAL_FULFILLMENT

This allows the agent to traverse the downstream impact of an affected batch instead of relying on static relationships.

Autonomous Agent Orchestration

Implemented an autonomous safety agent that parses USDA FSIS and FDA outbreak text alerts, extracts relevant product SKUs and batch URNs, and programmatically queries DataHub's metadata graph to map downstream blast radiuses and issue register lock directives without human intervention.

Tags

FoodGuard applies operational metadata tags such as:

  • RAW_INGREDIENT
  • HIGH_RISK_PERISHABLE
  • FDA_RECALL_TARGET
  • QUARANTINE_LOCKED
  • FDA_CLASS_I

Incident Write-Back

After the agent determines the affected downstream assets, it writes the incident back into DataHub's metadata layer via GraphQL:

SAFETY_RECALL
    │
    ├── affected batch
    ├── affected lineage
    ├── quarantine status
    ├── recall classification
    └── mitigation metadata

This creates an auditable connection between: the original contamination signal $\rightarrow$ the affected lineage $\rightarrow$ the response.


The 3-Second Incident Response

FoodGuard's central demo scenario starts with a Listeria monocytogenes contamination alert.

Before FoodGuard (Manual 7–14 Days)

Contamination Alert ──> Find batch ──> Search inventory ──> Contact processor ──> Trace distribution ──> Identify stores ──> Create orders ──> Record incident

Multiple systems. Multiple manual lookups. High risk of missing a downstream dependency.

With FoodGuard (1.4 Seconds)

CONTAMINATION ALERT ──> DATAHUB LINEAGE TRAVERSAL ──> DOWNSTREAM IMPACT MAP ──> QUARANTINE ACTIONS ──> DATAHUB INCIDENT

Architecture

┌─────────────────────────────┐
│      FDA / USDA Alert       │
│   Pathogen + Batch Signal   │
└──────────────┬──────────────┘
               │
               ▼
┌─────────────────────────────┐
│     FoodGuard Agent         │
│                             │
│ Alert Interpretation        │
│ Lineage Reasoning           │
│ Impact Quantification       │
│ Mitigation Generation       │
└──────────────┬──────────────┘
               │
               ▼
┌─────────────────────────────┐
│       DataHub Context       │
│                             │
│ Metadata Graph              │
│ Lineage                     │
│ Tags                        │
│ Assertions                  │
│ Incidents                   │
└──────────────┬──────────────┘
               │
               ▼
┌─────────────────────────────┐
│   4-Tier Supply Chain       │
│                             │
│ Harvest → Processing        │
│ → Cold Storage → Retail     │
│ / School Districts          │
└──────────────┬──────────────┘
               │
               ▼
┌─────────────────────────────┐
│       Risk Engine           │
│                             │
│ Affected Nodes              │
│ Inventory                   │
│ Consumers                   │
│ Financial Exposure          │
└──────────────┬──────────────┘
               │
               ▼
┌─────────────────────────────┐
│   Quarantine PR Generator   │
│                             │
│ Barcode Freezes             │
│ Inventory Lockouts          │
│ Store Actions               │
└──────────────┬──────────────┘
               │
               ▼
┌─────────────────────────────┐
│     DataHub Write-Back      │
│                             │
│ SAFETY_RECALL               │
│ QUARANTINE_LOCKED           │
│ FDA_CLASS_I                 │
└─────────────────────────────┘

Repository Structure

DATAHUB FOOD/
├── LICENSE                                    # Apache License 2.0
├── README.md                                  # Production design doc & rubric score mapping
├── package.json                               # Next.js 15, React 19, Lucide, Tailwind
├── tsconfig.json                              # TypeScript config with @/* path aliases
│
├── app/
│   ├── globals.css                            # Glassmorphic & utility styles
│   ├── layout.tsx                             # Metadata & Root Layout
│   └── page.tsx                               # FoodGuard Emergency Control Room UI
│
├── lib/
│   ├── food-data.ts                           # USDA FSIS Outbreak Datasets (Boar's Head EST. 12612)
│   └── datahub-engine.ts                      # Sub-second Lineage Traversal & GraphQL Mutation Builder
│
├── ingestion/
│   └── foodguard_lineage.dhub.yaml            # DataHub CLI Ingestion Recipe for GMS
│
└── examples/
    ├── foodguard_supply_chain_entities.json   # DataHub GMS Entity Aspect Payload
    ├── FDA_CLASS_I_RECALL_NOTICE_REC-2026-894.md
    ├── POS_BARCODE_FREEZE_MANIFEST_SKU9921.json
    └── DATAHUB_INCIDENT_WRITEBACK_PAYLOAD.json

Getting Started

Prerequisites

  • Node.js 18+
  • npm
  • DataHub GMS instance (optional for live GMS REST/GraphQL connection; pre-seeded demo mode included)

Installation & Run

# 1. Clone & enter repository
git clone https://github.com/HillaryIkhais/FoodGuard.git
cd FoodGuard

# 2. Install dependencies
npm install

# 3. Run locally
npm run dev

Then open http://localhost:3000 in your browser.


License

FoodGuard is open-source software licensed under the Apache License, Version 2.0. See LICENSE for details.

About

Real-time food safety engine that tracks recalls across supply chains and blocks contaminated products at cash registers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages