Skip to content
utkarsh4964-stackPublic

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

75 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฒ SurplusAI

AI Workforce for Food Rescue & Institutional Food Waste Management

Every meal deserves a second chance.

SurplusAI is an autonomous multi-agent platform that rescues surplus food from restaurants, hotels, bakeries, and events, intelligently matches it with NGOs, plans deliveries, coordinates volunteers, and measures real-world impact โ€” all with minimal human intervention.

It now also extends into institutional kitchens and food processing units: forecasting demand before surplus happens, monitoring storage/machine health from IoT sensor data, and generating ESG-ready sustainability reports โ€” aligned with SIH Problem Statement 26234 (AI-Powered Smart Food Waste Reduction and Sustainable Redistribution Ecosystem for Institutional Kitchens and Food Processing Units).

Instead of relying on phone calls, WhatsApp groups, or manual coordination, SurplusAI uses a team of specialized AI agents that collaborate to complete the entire rescue and waste-prevention workflow.


๐Ÿšจ The Problem

Every day:

  • ๐Ÿฝ Restaurants discard perfectly edible meals.
  • ๐Ÿจ Hotels throw away buffet leftovers.
  • ๐Ÿฅ– Bakeries dispose of unsold bread.
  • ๐ŸŽ‰ Events generate large amounts of food waste.
  • ๐Ÿญ Institutional kitchens and food processing units overproduce, lose raw material, and run inefficient storage โ€” often without knowing it until the waste is already generated.

Meanwhile:

  • NGOs
  • Orphanages
  • Homeless shelters
  • Community kitchens

struggle to provide meals because they don't know where surplus food is available.

The challenge isn't food production.

It's coordination โ€” and the lack of foresight to prevent the waste before it happens.


๐Ÿ’ก Our Solution

SurplusAI transforms food rescue into an autonomous AI workflow, and extends it upstream into prevention.

A restaurant or institution only needs to submit a donation once, or simply stay connected โ€” everything else is handled automatically.

Institution / Restaurant
      โ”‚
      โ–ผ
๐Ÿค– AI Workforce
      โ”‚
      โ–ผ
NGO receives food  +  Institution gets forecast, sensor alerts & ESG report

The AI system:

  • Forecasts demand and expected surplus before it's generated
  • Monitors storage and machine conditions via IoT sensor data
  • Understands the donation
  • Verifies food quality
  • Predicts urgency
  • Finds the best NGO
  • Plans the fastest route
  • Assigns a volunteer
  • Notifies everyone
  • Tracks sustainability and ESG impact

๐Ÿค– AI Workforce

SurplusAI is powered by ten specialized AI agents โ€” the original seven-agent rescue pipeline, plus three new agents for institutional kitchens and food processing units.

๐Ÿ“ˆ Demand Forecasting Agent (new)

Predicts near-term demand and expected surplus for an institution using historical consumption/production records (exponential smoothing).

Responsibilities:

  • Forecast predicted demand and surplus (kg)
  • Report forecast confidence and trend (rising / falling / stable)
  • Feed downstream agents so actuals can be compared against prediction

๐Ÿ“ก Processing Monitor Agent (new)

Ingests IoT/sensor telemetry from storage and machinery and flags operational inefficiencies.

Responsibilities:

  • Detect storage temperature/humidity excursions
  • Detect machine downtime events
  • Detect excessive energy draw
  • Compute overproduction relative to the forecast
  • Compute a processing efficiency score
  • Flag spoilage risk upstream to the Quality Agent on a storage breach

๐Ÿฅ˜ Donation Agent

Converts restaurant/institution submissions into structured donation records.

Responsibilities:

  • Extract food information
  • Generate donation ID
  • Normalize quantities
  • Prepare shared state

๐Ÿ‘ Food Quality Agent

Evaluates whether the donation is safe.

Current implementation:

  • Freshness heuristic
  • Food category risk
  • Photo availability

Future:

  • Vision LLM integration
  • Food detection
  • Spoilage classification

โณ Expiry Prediction Agent

Predicts remaining safe consumption time using:

  • Food category
  • Pickup deadline
  • Shelf-life rules

๐ŸŽฏ Matching Agent

Ranks every NGO using an explainable weighted scoring algorithm.

Current scoring:

Final Score =
0.35 ร— Need Match
+ 0.30 ร— Proximity
+ 0.20 ร— Capacity Fit
+ 0.15 ร— Urgency

The highest scoring NGO is selected.

Every decision is explainable.


๐Ÿš— Route Planning Agent

Assigns the most suitable volunteer.

Calculates:

  • Estimated travel time
  • Distance
  • Traffic multiplier
  • Route information

๐Ÿ“ข Notification Agent

Generates personalized notifications for:

  • Restaurant / Institution
  • NGO
  • Volunteer

Current implementation logs payloads.

Can later integrate:

  • WhatsApp
  • SMS
  • Email
  • Push notifications

๐Ÿ“Š Impact Agent

Measures real-world impact for the donation-ticket pipeline.

Tracks:

  • Meals rescued
  • People fed
  • Food waste prevented
  • COโ‚‚ emissions avoided

๐ŸŒ Sustainability / ESG Agent (new)

Aggregates rescue outcomes and processing efficiency into ESG-ready sustainability analytics for an institution.

Tracks:

  • Meals rescued & food waste prevented (kg)
  • COโ‚‚ avoided
  • Waste-prevention percentage vs. forecasted surplus
  • Resource-efficiency index
  • An ESG summary (Environmental / Social / Governance) exportable per institution

โš™ System Architecture

Institution / Restaurant Portal
        โ”‚
        โ–ผ
FastAPI Backend
        โ”‚
        โ–ผ
Orchestrator
        โ”‚
   โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ–ผ                                    โ”‚
Demand Forecast Agent โ”€โ”€โ”€โ–บ Donation Agent
   โ”‚                                    โ”‚
   โ–ผ                                    โ–ผ
Processing Monitor Agent โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Quality Agent
   โ”‚                                    โ”‚
   โ”‚                                    โ–ผ
   โ”‚                              Expiry Agent
   โ”‚                                    โ”‚
   โ”‚                                    โ–ผ
   โ”‚                             Matching Agent
   โ”‚                                    โ”‚
   โ”‚                                    โ–ผ
   โ”‚                              Routing Agent
   โ”‚                                    โ”‚
   โ”‚                                    โ–ผ
   โ”‚                          Notification Agent
   โ”‚                                    โ”‚
   โ”‚                                    โ–ผ
   โ”‚                              Impact Agent
   โ”‚                                    โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Sustainability / ESG Agent
                                        โ”‚
                                        โ–ผ
                          Response + Live Dashboard

Every agent operates on a shared state object, making the architecture easy to extend with LangGraph. The Demand Forecast, Processing Monitor and Sustainability agents run on an institution-scoped state (used by /forecast, /processing/status, /sustainability/report), separate from the donation-ticket state used by /donate โ€” they share the same design pattern but different inputs, since a single donation ticket has no attached institution history or live sensor feed.


๐Ÿ— Tech Stack

Frontend

  • HTML
  • CSS
  • JavaScript

Backend

  • FastAPI
  • Pydantic
  • Python

AI

  • Modular Agent Architecture
  • Shared Agent State
  • Explainable Decision Logic
  • Exponential-smoothing demand forecasting (swappable for Prophet/LSTM)
  • Rule-based IoT anomaly detection (swappable for a trained anomaly model)

Data

  • JSON datasets
  • In-memory session state
  • Mock IoT sensor stream (sensor_stream.json) for demo purposes

Future upgrades:

  • PostgreSQL
  • LangGraph
  • Vision Models
  • LLM-powered extraction
  • Real IoT sensor integration (MQTT/HTTP ingestion)
  • Time-series forecasting models (Prophet, LSTM)

๐Ÿ“ Project Structure

surplusai/

โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ main.py
โ”‚   โ”œโ”€โ”€ orchestrator.py
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ demand_forecast_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ donation_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ processing_monitor_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ quality_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ expiry_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ matching_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ routing_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ notification_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ impact_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ sustainability_agent.py
โ”‚   โ”‚   โ””โ”€โ”€ state.py
โ”‚   โ””โ”€โ”€ data/
โ”‚       โ”œโ”€โ”€ ngos.json
โ”‚       โ”œโ”€โ”€ volunteers.json
โ”‚       โ”œโ”€โ”€ institutions.json
โ”‚       โ””โ”€โ”€ sensor_stream.json
โ”‚
โ””โ”€โ”€ frontend/
    โ”œโ”€โ”€ index.html
    โ”œโ”€โ”€ app.js
    โ””โ”€โ”€ style.css

๐ŸŒ REST API

POST /donate

Creates a new donation and executes the complete 7-agent rescue pipeline.

Example:

{
  "food_type": "Veg Thali",
  "quantity": 40,
  "pickup_time": "22:00"
}

Returns:

  • Donation result
  • Agent trace
  • Selected NGO
  • Volunteer assignment
  • ETA
  • Impact metrics

GET /impact

Returns platform impact statistics.


GET /ngos

Returns registered NGOs.


GET /institutions

Returns registered institutions (kitchens and food processing units).


GET /forecast/{institution_id}

Returns the demand/surplus forecast for one institution.

Example response:

{
  "predicted_demand_kg": 279.27,
  "predicted_surplus_kg": 42.39,
  "confidence": 0.98,
  "trend": "rising",
  "method": "exp_smoothing"
}

GET /processing/status/{institution_id}

Returns IoT/sensor anomaly flags and processing efficiency for one institution.

Example response:

{
  "storage_excursions": 1,
  "machine_downtime_events": 1,
  "energy_alerts": 0,
  "overproduction_kg": 45.73,
  "total_energy_kwh": 36.5,
  "efficiency_score": 0.82
}

GET /sustainability/report/{institution_id}?donation_kg=

Returns an ESG-style sustainability report for one institution.

Example response:

{
  "meals_rescued": 100,
  "food_waste_prevented_kg": 40,
  "co2_avoided_kg": 100.0,
  "waste_prevention_pct": 94.4,
  "resource_efficiency_index": 0.71,
  "esg_summary": {
    "environmental": "...",
    "social": "...",
    "governance": "..."
  }
}

GET /health

Health check endpoint.


๐Ÿš€ Running the Project

Backend

cd backend

pip install -r requirements.txt

uvicorn main:app --reload

Backend:

http://localhost:8000

Swagger Docs:

http://localhost:8000/docs

Frontend

Open:

frontend/index.html

No build step required. Includes an "๐Ÿญ Institutions" tab alongside Donor / NGO Partner / Volunteer / Impact Center.


๐ŸŽฌ Demo Flow

Rescue pipeline:

  1. Restaurant/institution submits surplus food.
  2. Donation enters the AI workflow.
  3. Seven AI agents execute sequentially.
  4. NGO is selected using weighted scoring.
  5. Volunteer receives assignment.
  6. Dashboard updates in real time.
  7. Impact metrics increase.

Institution dashboard:

  1. Select an institution (kitchen or processing unit).
  2. Demand Forecasting Agent predicts upcoming surplus.
  3. Processing Monitor Agent reports live sensor status and efficiency.
  4. Sustainability Agent generates an ESG report for the cycle.

Total demo time:

~90 seconds (rescue pipeline) + ~30 seconds (institution dashboard)


๐Ÿ“Š Explainable AI

Unlike traditional matching systems, every decision made by SurplusAI is transparent.

Example:

Need Match        0.91
Proximity         0.82
Capacity Fit      0.75
Urgency Bonus     0.93

Final Score       0.87

The selected NGO isn't simply the closestโ€”it is the best overall match. Forecasts, processing flags, and ESG scores are similarly broken down into their component metrics rather than returned as opaque numbers.


โœ… Alignment with PS 26234

PS 26234 requirement SurplusAI component
Predict food demand and surplus in real time Demand Forecasting Agent
Identify items nearing expiry/quality deterioration Quality Agent + Expiry Prediction Agent
Connect surplus food with NGOs/food banks/shelters Matching Agent
Optimize transportation and delivery routes Route Planning Agent
Monitor processing efficiency, storage, operational performance Processing Monitor Agent
Detect overproduction, raw material loss, downtime, energy usage Processing Monitor Agent
Generate sustainability/ESG analytics Sustainability / ESG Agent
Support data-driven production planning Demand Forecasting Agent + institution dashboard

๐Ÿ”ฎ Future Roadmap

  • LangGraph orchestration
  • Vision AI for food inspection
  • LLM-based donation extraction
  • Google Maps routing
  • WhatsApp notifications
  • PostgreSQL persistence
  • Real-time volunteer tracking
  • Real IoT sensor integration (current version uses a mock stream)
  • Time-series forecasting models (Prophet, LSTM) in place of exponential smoothing
  • CSR/ESG analytics dashboard export (PDF)
  • Government food rescue integration

๐ŸŒ Impact

Every successful donation, and every institution using the forecast/processing/sustainability tools, contributes to:

  • Reducing food waste before and after it's generated
  • Feeding vulnerable communities
  • Lowering greenhouse gas emissions
  • Improving coordination between food donors and NGOs
  • Helping institutional kitchens and food processing units plan production and meet ESG goals

SurplusAI demonstrates how autonomous AI systems can solve meaningful real-world problems through explainable, collaborative decision-making โ€” from the moment food is planned, to the moment it's rescued.


Every meal deserves a second chance.

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages