Skip to content

Repository files navigation

🚛 Cold Chain Wise

AI-Powered Decision Intelligence Platform for Cold Chain Logistics

GAT-RL Engine · Real-Time Risk Diagnostics · Gemini-Native Reasoning

Live Demo React TypeScript Vite Gemini Cognee Flask License

Live Prototype · Features · Architecture · Memory Layer · Tech Stack · Getting Started · Roadmap


Cold Chain Wise Dashboard


📌 Overview

Cold Chain Wise (engine name: GAT-RL) is an AI-driven logistics decision-intelligence platform built to eliminate vaccine and food spoilage across cold chain networks through real-time autonomous diagnostics, predictive risk modeling, and Gemini-powered reasoning.

Cold chains are one of the most fragile parts of global logistics — a single compressor failure, a two-hour delay, or an unmonitored temperature drift can spoil a shipment worth tens of thousands of dollars, or worse, compromise vaccine efficacy. Cold Chain Wise treats this as a decision problem, not just a monitoring problem: instead of only reporting that a shipment is at risk, it reasons about why, quantifies how much, and recommends what to do next — in natural language, in real time.

This is not a static monitoring dashboard. It is a decision-support system where an AI agent actively watches every shipment in the simulation, triggers itself when risk crosses a threshold, and produces human-readable diagnostic reasoning grounded in the underlying telemetry.

Why this matters: A mid-sized cold chain fleet operating without predictive intelligence loses an estimated 5% of shipment value annually to spoilage. Cold Chain Wise's modeling shows this can be cut dramatically through earlier detection and automated rerouting — see Business Impact below.



✨ Key Features

🧠 Autonomous AI Diagnostic Agent

Real-time reasoning engine powered by Google Gemini 1.5 Flash. Continuously evaluates shipment risk and auto-triggers full diagnostics the moment risk exceeds 85%, without requiring a human to ask.

🎛️ What-If Simulator (Digital Twin)

Interactive sliders let operators simulate hypothetical transit conditions — delay duration, temperature deviation, distance remaining — and receive an instant, model-backed risk score before committing to a routing decision.

🌡️ Live Telemetry Simulation

Real-time tracking of temperature, humidity, and transit progress across simulated global shipment routes, rendered on an interactive map layer.

🔀 Dynamic Rerouting Recommendations

When a shipment is flagged as high-risk, the agent identifies the nearest Tier-1 cold storage hub and produces an emergency reroute recommendation with an estimated time of arrival.

🩺 Deep Equipment Diagnostics

Goes beyond ambient temperature — evaluates compressor efficiency, backup power status, and cargo integrity signals to build a fuller picture of shipment health.

🔐 Secure Authentication

Firebase-backed email/password authentication with session handling, plus a developer bypass mode for fast local testing and demos.

📊 Predictive Spoilage Modeling

A risk-scoring engine that estimates spoilage probability from live and simulated telemetry inputs, forming the basis for every alert and recommendation the platform surfaces.

🖥️ Premium Streaming UI

Sequentially animated diagnostic steps (built with Framer Motion) that make the AI's reasoning process visible as it happens, instead of dumping a result all at once.

🧬 Persistent Memory via Cognee

Every shipment that passes through the diagnostic agent is written into a Cognee-backed memory store (coldchain_shipments dataset), so the system accumulates a durable history of shipments over time instead of forgetting each one immediately after scoring it.

🧩 Memory-Ready Recall API

recall_similar_shipments(), improve_memory(), and forget_all() are already implemented in the memory service — the groundwork for pulling past shipment history directly into Gemini's reasoning.



🧠 The AI Agent: How Reasoning Actually Happens

At the core of Cold Chain Wise is an autonomous diagnostic agent — not a chatbot bolted onto a dashboard, but a background process that watches every active shipment.

How it behaves:

  1. Continuous evaluation — every simulated shipment is scored against a spoilage-risk model on an ongoing basis.
  2. Auto-triggering — if a shipment's computed risk exceeds the 85% threshold, the agent activates without a human prompting it.
  3. Multi-signal diagnosis — it pulls together temperature/humidity telemetry, compressor health, backup power state, and cargo integrity signals into a single diagnostic pass.
  4. Gemini-generated reasoning — the diagnostic output is passed to Google Gemini 1.5 Flash, which converts the raw signal into a natural-language explanation an operator can act on immediately, rather than a wall of numbers.
  5. Actionable recommendation — the response includes a concrete next step: reroute to the nearest Tier-1 cold hub, flag for manual inspection, or continue monitoring.

This is what separates a decision intelligence platform from a dashboard: the system doesn't stop at "temperature is high" — it explains the likely cause, quantifies the risk, and tells you what to do about it.



🧬 Persistent Memory with Cognee

Cold Chain Wise uses Cognee as its memory layer — an open-source memory framework for AI agents — via a dedicated MemoryService (backend/ai/memory_service.py).

What's live right now:

Every time the diagnostic agent processes a shipment through /run-agent, MemoryService.remember_shipment() calls cognee.remember() and writes that shipment's full payload into a Cognee dataset named coldchain_shipments. This happens on every single diagnostic run — the system is continuously building a persistent record of shipment history instead of discarding each reading once it's scored.

def remember_shipment(self, shipment):
    asyncio.run(
        cognee.remember(
            data=json.dumps(shipment),
            dataset_name="coldchain_shipments"
        )
    )

Built into MemoryService, ready to extend:

The service also implements recall_similar_shipments() (via cognee.recall()), improve_memory() (via cognee.improve()), and forget_all() (via cognee.forget()) — the full read/refine/reset side of Cognee's memory API. These are implemented and functional, but not yet called from an active route: today, Gemini's diagnostic reasoning doesn't pull recalled shipment history into its prompt. That query-time recall loop — asking "have we seen a shipment like this before, and what happened?" — is the natural next step for this integration.

Cognee Operation Method Status
cognee.remember() remember_shipment() ✅ Live — called on every /run-agent diagnostic
cognee.recall() recall_similar_shipments() 🟡 Implemented, not yet wired into a route
cognee.improve() improve_memory() 🟡 Implemented, not yet wired into a route
cognee.forget() forget_all() 🟡 Implemented, not yet wired into a route


🏗️ System Architecture

flowchart TD
    A[Frontend — React + TypeScript + Vite] -->|REST calls| B[Flask API Layer]
    B --> C[Diagnostic Engine — services/logic.py]
    C --> M[Cognee Memory — remember_shipment]
    C --> D[Risk Scoring Model]
    C --> E[Telemetry Aggregator]
    D --> F[Google Gemini 1.5 Flash]
    E --> F
    F --> G[Natural-Language Reasoning + Recommendation]
    G --> B
    B -->|JSON response| A
    A --> H[Firebase Auth]
    A --> I[Interactive Map + Charts]
Loading

Authentication Flow

sequenceDiagram
    participant U as User
    participant F as Frontend (React)
    participant Auth as Firebase Auth
    participant API as Flask Backend

    U->>F: Enter credentials
    F->>Auth: signInWithEmailAndPassword()
    Auth-->>F: ID Token
    F->>API: Authenticated request (token)
    API-->>F: Authorized response
    F-->>U: Render dashboard
Loading

Diagnostic Request Flow

flowchart LR
    T[Live/Simulated Telemetry] --> C[cognee.remember - shipment persisted]
    T --> R[Risk Analysis Engine]
    R -->|risk >= 85%| G[Auto-Trigger Diagnostic Agent]
    R -->|risk < 85%| N[Continue Monitoring]
    G --> D[Deep Diagnostics: Compressor, Power, Cargo]
    D --> AI[Gemini 1.5 Flash Reasoning]
    AI --> REC[Recommendation Engine]
    REC --> UI[Dashboard Alert + Reroute Suggestion]
Loading

Note: cognee.remember() fires on every diagnostic run regardless of risk outcome — memory persistence and risk scoring happen in parallel, not conditionally.



🛠️ Technology Stack

Frontend

Technology Purpose
React 18 Component architecture and UI state management
TypeScript Type safety across the entire frontend codebase
Vite Fast dev server and optimized production build
Tailwind CSS Utility-first styling system
Shadcn UI Accessible, composable component primitives
Framer Motion Diagnostic step animation and micro-interactions

Backend

Technology Purpose
Python 3.12 Core backend runtime
Flask + Flask-CORS REST API layer serving the frontend
Gunicorn Production WSGI server
google-generativeai Gemini 1.5 Flash SDK integration
cognee Persistent memory layer — shipment history storage via cognee.remember()

AI & Google Technologies

Technology Purpose
Google Gemini 1.5 Flash Natural-language diagnostic reasoning and recommendations
Google AI Studio API key provisioning and prompt iteration/testing
Prompt Engineering Structured prompts that ground Gemini's output in real telemetry values rather than free-form guessing

Auth, Deployment & Infra

Technology Purpose
Firebase Authentication Email/password login and session management
Firebase Realtime Database Shipment/session state where applicable
Render Hosting for both the static frontend and the Flask backend
Google Cloud Run Alternate containerized deployment target for the backend


🔍 Google Technologies Powering Cold Chain Wise

Google Gemini 1.5 Flash — chosen for its low-latency inference, which matters directly here: the diagnostic agent needs to reason and respond fast enough to feel real-time inside an operator-facing dashboard, not after a multi-second delay that breaks the "AI-at-work" experience the UI is built around.

Google AI Studio — used for provisioning the Gemini API key and iterating on the diagnostic prompt structure before wiring it into the Flask backend.

Prompt Engineering — the diagnostic prompts are deliberately structured to inject the actual telemetry values (temperature deltas, compressor status, distance-to-hub) directly into context, so Gemini's output is grounded in the specific shipment rather than generic advice.

Firebase Authentication — chosen for fast, reliable email/password auth with minimal backend overhead, letting the project focus engineering effort on the diagnostic engine rather than reinventing session management.

Cognee — chosen as the memory layer because cold chain risk isn't really a single-shipment problem: a route that failed once is a data point, a route that fails repeatedly is a pattern. Persisting every diagnostic through cognee.remember() means the platform is accumulating exactly the kind of longitudinal shipment data that a future recall-augmented reasoning step would need — see Memory Layer.



📈 Quantified Business Impact

Modeled against a mid-sized fleet of 100 trucks and $1.5B in annual throughput value:

Metric Annual Estimate Core Logic
Operational Efficiency 8,320 hours saved 80% automation of manual shipment monitoring labor
Direct Cost Reduction $45,000,000 60% reduction against a 5% baseline spoilage rate
Revenue Recovery $60,000,000 40% improvement in critical-event survival (shipments saved via early intervention)
Total Financial Gain $105M+ / year Combined savings from waste reduction and recovery

Assumptions: $1.5B annual throughput value, $50K average shipment value, 5 FTE monitoring staff baseline. These are illustrative model outputs based on the platform's assumptions, not audited financial figures.



📂 Project Structure

cold-chain-wise/
├── backend/
│   ├── app.py                     # Flask entrypoint — /gemini-explain, /health, / routes
│   ├── config.py                  # Env var loading (GOOGLE_API_KEY, Flask config)
│   ├── gemini_service.py          # Gemini 1.5 Flash prompt + structured JSON parsing
│   ├── requirements.txt           # Python dependencies
│   ├── Dockerfile                 # Cloud Run container build
│   ├── ai/
│   │   └── memory_service.py      # Cognee integration: remember / recall / improve / forget
│   ├── routes/
│   │   └── agent.py                # /run-agent blueprint
│   └── services/
│       └── logic.py                # Diagnostic logic — calls memory_service + risk scoring
│
├── src/                            # React + TypeScript frontend
│   ├── components/                 # AIAgent, WhatIfSimulator, InteractiveMap, RiskAnalysis, etc.
│   ├── components/ui/              # Shadcn UI primitives
│   ├── assets/                     # Images used in-app
│   └── App.tsx
│
├── aws/lambda/                     # riskPrediction.js — auxiliary Lambda function
├── data/
│   └── sampleShipments.json        # Demo/seed shipment data
├── public/                         # Static assets, favicon, robots.txt
│
├── .env.example                    # Environment variable template
├── package.json                    # Frontend dependencies + scripts
├── vite.config.ts                  # Vite build configuration
├── tailwind.config.ts              # Tailwind theme configuration
└── README.md


🚀 Getting Started

Prerequisites

  1. Firebase — create a project at the Firebase Console, enable Email/Password Auth and Realtime Database.
  2. Gemini API Key — get a free key from Google AI Studio.
  3. Node.js and Python 3.12 installed locally.

Environment Variables

Frontend .env (project root):

VITE_BACKEND_URL=http://localhost:5000

Backend .env (backend/ directory):

GOOGLE_API_KEY=your_gemini_api_key_here

Run Locally

# Install frontend dependencies
npm install

# Runs frontend + Python backend concurrently
npm run dev

npm run dev spins up the Flask backend on port 5000 alongside the Vite dev server via concurrently, as configured in package.json.



☁️ Deployment

Backend (Render or Google Cloud Run)
  1. Push the repository to GitHub.
  2. On Render (or Google Cloud Run), create a new Web Service.
  3. Set Root Directory to backend.
  4. Set Environment to Python 3.
  5. Build Command: pip install -r requirements.txt
  6. Start Command: gunicorn app:app
  7. Add GOOGLE_API_KEY to the environment variables.
Frontend (Render Static Site / GitHub Pages)
  1. Create a new Static Site on Render.
  2. Leave Root Directory blank.
  3. Build Command: npm install && npm run build
  4. Publish Directory: dist
  5. Add VITE_BACKEND_URL pointing at your deployed backend URL.


🗺️ Roadmap / Future Architecture

The following are planned, not yet implemented — documented here to be transparent about the platform's direction rather than presented as shipped functionality.

Planned Capability Description
Recall-Augmented Reasoning Wire recall_similar_shipments() into gemini_service.py so Gemini's diagnostic prompt is grounded in similar past shipments pulled from Cognee, not just the current reading in isolation.
Memory Maintenance Loop Schedule improve_memory() to periodically refine the coldchain_shipments dataset, and expose forget_all() behind an admin control for dataset resets during demos/testing.
Conversational AI Assistant A natural-language interface layered on top of the diagnostic agent, letting operators ask direct questions about a route, shipment, or risk score and get an answer grounded in Cognee-recalled history.
Explainability Layer Structured, auditable reasoning traces behind each Gemini-generated recommendation, beyond the current natural-language output.
Multi-stop Route Optimization Extending the current single-leg risk model to full multi-stop route planning.

⚠️ Known gap: cognee is not currently listed in backend/requirements.txt. A clean install (e.g. on Render) would fail to import it, and because app.py silently swallows that import error, /run-agent — the only Cognee-powered route — would be unavailable in that deployment. Add cognee to requirements.txt before relying on a fresh deploy to demonstrate this feature.



👤 Author

Anushka Jadhav Built as an AI-powered logistics decision-intelligence solution for modern cold chain challenges.



📄 License

Released under the MIT License.