Back to guides
3
8-9 min

Supply Chain & Cold Chain

Post-Harvest Loss Modeling, Cold Chain IoT, and Farm-to-Fork Traceability in India

The 30-40% Problem

India loses 30-40% of its fruit and vegetable production post-harvest. ICAR estimates this at ₹92,000 crore annually — more than the combined capex of all Mega Food Parks sanctioned under PM Kisan SAMPADA. The loss is not uniformly distributed: it spikes at three nodes where temperature, time, and handling quality break down simultaneously — at the farm gate (lack of precooling), at mandi loading/unloading (mechanical damage + delays), and at the retail last mile (inadequate cold storage).

AI supply chain models attack all three nodes, but the highest ROI is at mandi and retail, where data infrastructure already exists (eNAM transaction records, APEDA cold store registrations, 3PL GPS tracking) and where small interventions produce large loss reductions.

Open data/post-harvest-loss-model.csv — it contains loss-rate observations across 18 commodities (tomato, onion, banana, mango, potato, leafy greens, grapes, pomegranate) for 200+ supply chain legs, linked to temperature excursion frequency, transit time, handling score (assessed by field agents), and mandi origin. The target: predict loss rate (% weight loss + quality downgrade rate) for a given shipment configuration before dispatch.

Cold Chain IoT: Sensor Architecture and Anomaly Detection

A modern Indian cold chain instrumentation stack for a Ninjacart or DeHaat refrigerated truck:

SensorMeasurementPlacementAlert Threshold
Wireless temperature loggerAmbient air temp (±0.5°C)4 corners of cargo area>4°C for fresh produce, >-18°C for frozen
Product-contact probePulp temperatureRepresentative cartons2°C above ambient setpoint
Door open sensorBinary + durationCargo door>2 min at temperatures >25°C ambient
Humidity sensorRH%Evaporator coil exit<85% RH for leafy greens
GPS + accelerometerLocation + G-force eventsOBD portG > 2.5g = rough handling event
Fuel/compressor currentRefrigeration system healthPower lineAnomalous current draw → compressor fault

Open data/cold-chain-iot.json — it contains temperature logger data from 500 reefer truck trips across India's major produce corridors: Nashik → Mumbai (onions, grapes), Kolar → Bengaluru (tomatoes), Shimla → Delhi (apples), and Coimbatore → Chennai (bananas). Temperature excursions, door open events, and GPS deviations are labeled. The modeling task: predict delivery quality score (Brix, firmness, color grade) from the IoT trajectory.

Cold chain anomaly detection uses two complementary approaches:

# 1. Rule-based CCP alerts (immediate, interpretable)
def check_temperature_excursion(readings: list[float], ccp_limit: float,
                                 duration_threshold_min: int = 30) -> dict:
    consecutive_violations = 0
    max_consecutive = 0
    for temp in readings:  # 5-min interval readings
        if temp > ccp_limit:
            consecutive_violations += 1
            max_consecutive = max(max_consecutive, consecutive_violations)
        else:
            consecutive_violations = 0
    excursion_duration_min = max_consecutive * 5
    return {
        "excursion": excursion_duration_min > duration_threshold_min,
        "max_excursion_min": excursion_duration_min,
        "estimated_shelf_life_reduction": excursion_duration_min * 0.8  # hours lost per min excursion
    }

# 2. ML-based predictive quality degradation
# XGBoost model trained on historical IoT + quality lab data
# Features: mean_temp, temp_std, max_excursion_min, n_door_opens,
#           total_transit_hours, g_force_events, origin_precool_temp
# Target: delivery_quality_score (0-100)

Perishable Demand Forecasting

The core challenge in Indian fresh produce forecasting is the interaction between weather-driven supply shocks and elastic urban demand. Onion price in Mumbai has swung from ₹8/kg to ₹120/kg within a single season — a 15x swing that destroys retailer margins and triggers political crises. The forecasting problem has two layers:

Supply forecasting (what will arrive at mandi):

  • Satellite NDVI to estimate standing crop in Nashik, Pune, and Madhya Pradesh
  • District-level crop calendar alignment with eNAM daily arrival data (historical)
  • Weather alert integration (cyclone, drought) for supply shock signal
  • Demand forecasting (what will the terminal market absorb):

  • Time-series decomposition: weekly rhythm (Mondays high, Sunday low) + seasonal (festival peaks) + trend
  • Price elasticity calibration: high-income urban demand is inelastic, bulk processor demand is elastic
  • External signals: school calendar (institutional demand), hotel occupancy (hospitality demand), export order volumes (competitive demand)
  • Prompt: "Using the attached eNAM arrival and price data [enam-arrivals-2023-24.csv] for onion at
    Lasalgaon, Pimpalgaon, and Pune APMCs, and NDVI trend data from Nashik district for the Nov-Jan
    Rabi onion season, forecast: (1) weekly arrivals for the next 8 weeks, (2) price range (modal,
    low, high) with 80% confidence interval, (3) probability of price spike >₹80/kg, (4) optimal
    procurement quantity for a retailer wanting to minimize stockout probability while limiting
    cold store inventory to 200 tonnes. Assume current cold store utilization 65%, holding cost
    ₹2.50/kg/day, and stockout penalty equivalent to 3× margin loss."

    Farm-to-Fork Traceability: eNAM Integration and Blockchain

    FSSAI's Food Safety Mitra scheme and APEDA's TraceNet require batch-level traceability for exports. The technical infrastructure for Indian farm-to-fork traceability is maturing rapidly, anchored on three government systems:

    SystemCoverageData AvailableAPI Access
    eNAM (National Agriculture Market)1,100+ mandis, 22 statesArrival quantity, grade, price, buyer-seller IDsOpen REST API
    APEDA's TraceNetExport-oriented horticultureFarm registration, FPO details, packing house recordsRegistered user API
    Horticultural Produce Grading and MarkingGraded produceGrade, packing date, packing house registrationInspection records
    PM Kisan SAMPADA MIDHProcessing unitsPlant registration, production capacityPortal integration

    AI adds value at the data reconciliation layer: matching eNAM lot IDs with cold store inward records (often manual and inconsistent), reconciling weight discrepancies between farm gate and mandi arrival, and flagging lots where origin claims cannot be verified (adulteration risk for GI-tagged products like Alphonso mango or Darjeeling tea).

    # Traceability record structure
    lot_record = {
        "lot_id": "MH_NASHIK_20240315_0042",
        "commodity": "onion",
        "variety": "N-2-4-1",
        "farm_origin": {"village": "Niphad", "tehsil": "Niphad", "district": "Nashik",
                         "farmer_id": "PM_KISAN_MH_4421982"},
        "harvest_date": "2024-03-12",
        "enam_transaction": {"mandi_code": "MH001", "arrival_date": "2024-03-14",
                              "modal_price": 1850, "quantity_kg": 2200, "grade": "A"},
        "cold_store_entry": {"store_id": "APEDA_CS_MH_0084", "entry_time": "2024-03-14T16:30:00",
                              "entry_temp": 2.1, "entry_quality_score": 88},
        "iot_telemetry_hash": "sha256:a4f9c2...",  # Immutable hash of sensor log
        "dispatch": {"destination": "DEL_INA_MARKET", "vehicle": "MH04CG4521",
                      "dispatch_date": "2024-03-16"}
    }

    Mandi Price Prediction

    Mandi price prediction is a high-stakes forecasting problem: FPOs, processors, and large retailers use it for procurement planning; small farmers use it to decide whether to sell immediately or store. The data infrastructure is now sufficient for reliable models:

    Features that dominate mandi price prediction (in order of importance from eNAM historical analysis):

  • Arrivals vs. 30-day moving average — supply surplus/deficit signal, highest importance
  • Rainfall in origin districts (7-14 days prior) — harvesting signal; rains delay harvest, reduce arrivals
  • Festival calendar — Diwali, Navratri, Id create demand spikes 5-10 days prior
  • Wholesale to retail price spread — indicates margin stress in the chain; high spread predicts correction
  • Cold store stock estimates — published monthly by NAFED for onion, potato; critical for carryover supply
  • Export demand signal — APEDA weekly export statistics for processed/fresh produce
  • Prompt: "I have eNAM transaction data for tomato at Kolar APMC for the past 36 months [attached].
    Build a price forecasting model that predicts: (1) next week's modal price with 70/90% PI,
    (2) next month's average price, (3) the key drivers of price movement for this week's forecast
    (SHAP-based explanation in plain terms for FPO committee members who are not data scientists).
    Highlight any model uncertainty flags — periods where the model should not be trusted due to
    out-of-distribution conditions like COVID-era lockdowns or floods."

    Key Takeaways

  • Post-harvest loss is concentrated at three nodes — farm gate (precooling gap), mandi (handling + delay), and retail last mile. IoT on reefer trucks with ML quality prediction addresses the highest-volume loss node first.
  • eNAM data is underutilized for supply chain AI — 1,100+ mandis generate daily arrival, price, and buyer data accessible via open API. This is the richest free signal for perishable demand forecasting in India.
  • Traceability requires data reconciliation AI, not just blockchain — the bottleneck is not the ledger but matching inconsistent lot IDs, weight discrepancies, and origin claims across manually-maintained records at farm gate, mandi, and cold store.
  • Mandi price prediction works best as a relative signal — rather than predicting absolute price (hard), predict whether next week's price will be 10%+ above or below the seasonal norm (easier, more actionable for FPO procurement decisions).
  • This is chapter 3 of AI for Food Processing & Agri.

    Get the full hands-on course — free during early access. Build the complete system. Your projects become your portfolio.

    View course details