Skip to content

balasaravanank/FoodLoop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍲 Food Waste Reduction & Hunger Relief System

A comprehensive Flask web application that connects food donors with organizations helping people in need, using machine learning to prioritize distribution.

Features

Admin Dashboard

  • View all donations and needs
  • Interactive charts and statistics (Chart.js)
  • Priority heatmap visualization (Folium)
  • Smart donation-to-need matching algorithm
  • Real-time analytics

Donor Portal

  • Submit food donations via intuitive form
  • View donation history
  • Track donation status
  • Bootstrap 5 responsive design

NGO Portal

  • Submit need requests
  • View needs with AI-predicted priority scores
  • Priority heatmap for needs distribution
  • Sort by priority levels

Project Structure

Food-Waste-Reduction-Hunger-Relief-System/
├── app.py                      # Main Flask application
├── api_routes.py               # API endpoints (Blueprint)
├── requirements.txt            # Python dependencies
├── README.md                   # Documentation
├── data/
│   ├── donations.csv          # Donations dataset
│   └── needs.csv              # Needs dataset
├── model/
│   └── priority_model.pkl     # Trained ML model (RandomForest)
├── templates/
│   ├── index.html             # Home/Role selection page
│   ├── admin.html             # Admin dashboard
│   ├── user.html              # Donor dashboard
│   ├── ngo.html               # NGO dashboard
│   ├── donations.html         # Donations view
│   ├── needs.html             # Needs view
│   ├── charts.html            # Charts view
│   └── heatmap.html           # Heatmap view
└── static/
    ├── css/
    │   └── style.css          # Custom styles
    └── js/
        └── utils.js           # Utility functions

Getting Started

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/FoodLoop.git
    cd FoodLoop
  2. Install dependencies

    pip install -r requirements.txt
  3. Run the application

    python app.py
  4. Access the application Open your browser and navigate to:

    http://localhost:5000
    

📊 API Endpoints

Method Endpoint Description
GET /api/donations Get all donations
GET /api/needs Get all needs with priority scores
POST /api/donate Submit new donation
POST /api/need Submit new need
GET /api/match Get donation-to-need matches
GET /api/statistics Get statistics for charts

Example API Usage

Submit a Donation:

curl -X POST http://localhost:5000/api/donate \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "food_type": "Vegetables",
    "quantity_kg": 25.5,
    "lat": 12.9716,
    "lon": 77.5946,
    "freshness": 0.85
  }'

Submit a Need:

curl -X POST http://localhost:5000/api/need \
  -H "Content-Type: application/json" \
  -d '{
    "org_name": "Care Foundation",
    "need_description": "Rice",
    "people_count": 100,
    "urgency": 3,
    "lat": 12.9716,
    "lon": 77.5946
  }'

🤖Machine Learning Model

The system uses a RandomForestClassifier (priority_model.pkl) to predict priority scores for needs based on:

  • Number of people affected FoodLoop — Food Waste Reduction & Hunger Relief

A compact, production-minded Flask app that connects food donors with NGOs and uses a trained model to prioritize urgent needs. This README is tailored for hackathon judges: it highlights goals, architecture, how to run the app quickly, the core ML idea, and how we validated the approach.

Why this matters

  • Reduce edible food waste by matching donations to verified needs.
  • Prioritize distribution to high-impact, high-urgency requests.
  • Simple, deployable stack that demonstrates data-driven social impact.

Repository at-a-glance

  • app.py — Flask application and route registration
  • api_routes.py — JSON API endpoints used by frontend and integrations
  • models.py — SQLAlchemy models and DB initialization
  • data/ — sample CSVs: donations.csv, needs.csv
  • model/priority_model.pkl — trained priority model (RandomForest)
  • templates/ + static/ — UI (Bootstrap, Chart.js, Folium heatmap)

Core features (concise)

  • Donor portal: submit donations with location, quantity and freshness
  • NGO portal: submit needs (people_count, urgency) and receive a priority score
  • Admin: dashboards, charts and a heatmap to visualize demand and supply
  • API: simple JSON endpoints for donations, needs, matches and stats
  • ML: a RandomForest model that predicts priority for needs (packaged at model/priority_model.pkl)

API (examples)

  • GET /api/donations — returns all donations
  • GET /api/needs — returns needs with priority score
  • POST /api/donate — submit donation
  • POST /api/need — submit need
  • GET /api/match — returns suggested matches

Example: submit a need (curl)

curl -X POST http://localhost:5000/api/need -H "Content-Type: application/json" -d "{\"org_name\":\"Care Foundation\",\"need_description\":\"Rice\",\"people_count\":100,\"urgency\":3,\"lat\":12.97,\"lon\":77.59}"

Machine learning summary

  • Model: scikit-learn RandomForestClassifier saved as model/priority_model.pkl.
  • Input features used in this demo: people_count, urgency (and optionally engineered spatial/time features).
  • Output: a discrete or scaled priority score used to sort/visualize needs.
  • Notes: model in the repo is a demo trained on synthetic data. For production, retrain with real labels, add cross-validation, feature importance tracking, and clear performance metrics..

About

A data-driven system built for IBM Z Hackathon that predicts high-demand food zones using machine learning and facilitates food redistribution via Flask API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors