Skip to content

Souhardya-Ray/FoodPulse

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍽️ Food Pulse β€” AI-Powered Food Redistribution Platform

🌍 Overview

Food Pulse is a web application designed to bridge the gap between restaurants, NGOs, and old-age homes to minimize food wastage.
It uses AI-driven freshness prediction and a built-in FAQ + AI chatbot to ensure surplus food is redistributed safely and efficiently.


✨ Key Features

  • 🧠 AI-Powered Shelf Life Prediction:
    Uses Groq’s LLaMA-3.3-70B Versatile model to estimate freshness duration (in hours) of any food item.
  • πŸ€– Smart Hybrid Chatbot (FoodPulseChatbot):
    Combines FAQ-based responses with real-time AI chat via Groq API for accurate, context-aware assistance.
  • 🍴 Restaurant Dashboard:
    Restaurants can list surplus food and track freshness automatically.
  • 🏠 NGO / Old Age Home Dashboard:
    NGOs can view, claim, and collect food items safely.
  • πŸ§‘β€πŸ’Ό Admin Dashboard:
    Admins can oversee users, listings, and platform activity.
  • πŸ” Secure Authentication:
    Passwords are hashed securely using werkzeug.security.

🧩 Project Structure


πŸ“ DBMS FINAL WEB/
β”‚
β”œβ”€β”€ πŸ“‚ static/               # Static assets (CSS, JS, images)
β”œβ”€β”€ πŸ“‚ templates/            # HTML templates for Flask
β”œβ”€β”€ πŸ“„ app.py                # Main Flask application
β”œβ”€β”€ πŸ“„ chatbot.py            # Hybrid FAQ + AI Chatbot logic
β”œβ”€β”€ πŸ“„ database.db           # SQLite3 database
β”œβ”€β”€ πŸ“„ init_db.py            # Database initialization script
β”œβ”€β”€ πŸ“„ schema.sql            # SQL schema for tables
β”œβ”€β”€ πŸ“„ .env                  # Environment variables (Groq API key)
β”œβ”€β”€ πŸ“„ .gitignore            # Git ignore configuration
└── πŸ“ **pycache**/          # Auto-generated Python cache files


βš™οΈ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/yourusername/food-pulse.git
cd "DBMS FINAL WEB"

2️⃣ Create and Activate a Virtual Environment

python -m venv venv
source venv/bin/activate     # For Linux/Mac
venv\Scripts\activate        # For Windows

3️⃣ Install Dependencies

pip install flask groq python-dotenv werkzeug requests

4️⃣ Setup Environment Variables

Create a .env file in the root directory:

GROQ_API_KEY=your_groq_api_key_here
FLASK_ENV=development

5️⃣ Initialize the Database

python init_db.py

This script executes schema.sql and creates the database.db file.


πŸš€ Run the Application

python app.py

Then open your browser and visit πŸ‘‰ http://127.0.0.1:5000


🧠 AI Freshness Prediction (Groq Integration)

  • When a restaurant adds food, the system calls Groq’s LLaMA-3.3 model to estimate its safe shelf life in hours.
  • The freshness duration (fresh_until) is computed automatically and stored in the database.
  • Once expired, listings are automatically marked Expired.

πŸ’Ύ Database Overview

🧍 users Table

Column Type Description
id INTEGER Primary key
name TEXT User’s name
email TEXT Unique email
password TEXT Hashed password
account_type TEXT restaurant / ngo / old-age-home / admin
address TEXT Address of organization
phone_number TEXT Contact number
is_profile_complete INTEGER 1 if user added details

🍱 food_listings Table

Column Type Description
id INTEGER Primary key
restaurant_id INTEGER ID of restaurant
food_item TEXT Item name
quantity TEXT Quantity info
status TEXT Available / Claimed / Expired
fresh_until DATETIME Calculated freshness expiry
claimed_by_id INTEGER NGO/Old-age-home that claimed it
timestamp DATETIME Time when food was listed

πŸ€– FoodPulseChatbot Overview

πŸ”Ή How It Works

The chatbot combines instant FAQ answers with AI-powered responses from the Groq API:

  1. First checks against a local FAQ dataset (organized by category).
  2. If no strong match is found, it dynamically queries Groq’s LLaMA 3.1 model using contextual information about the Food Pulse platform.
  3. It uses conversation history, rate limiting, and keyword filtering to stay accurate and efficient.

πŸ”Ή Built-In Capabilities

  • 🧩 FAQ Matching: Matches user queries with a curated set of pre-defined questions and answers (e.g., registration, logistics, food safety).
  • πŸ’¬ AI Context Replies: Falls back to Groq API with a structured system prompt that includes Food Pulse’s documentation and mission.
  • βš™οΈ Rate Limiting: Prevents abuse (1 request/second, 100 requests/day limit).
  • 🧠 Memory: Retains the last 6 exchanges for contextual understanding.
  • 🧹 Topic Filtering: Ignores unrelated queries and redirects the user politely.

πŸ’¬ Chat Endpoint

πŸ”Έ Route

POST /chat

πŸ”Έ Request Format

{
  "message": "How can NGOs request food donations?"
}

πŸ”Έ Example Response

{
  "reply": "NGOs can browse approved listings, filter based on their needs, and click 'Request' to claim an item. The restaurant receives a notification, and upon confirmation, pickup or delivery arrangements can be made."
}

If the question is outside the FAQ, the chatbot will automatically fetch a contextual AI response using Groq API.


🧩 Flask Template Mapping

Template Purpose
index.html Landing page
login.html Login and signup
restaurant_dashboard.html Dashboard for restaurants
ngo_dashboard.html Dashboard for NGOs and old-age homes
admin_dashboard.html Admin overview panel
profile.html User profile setup

πŸͺ„ Future Enhancements

  • 🧾 Add donation tracking and feedback system
  • πŸ“¦ Introduce geolocation-based restaurant–NGO matching
  • ⚑ Integrate real-time freshness sensors via IoT
  • πŸ€– Make chatbot context-aware with multi-turn reasoning
  • πŸ“ˆ Add analytics for food distribution impact

πŸ‘¨β€πŸ’» Contributors

Developed by: Spandan Chakraborty, Sarbatriki Jana, Souhardya Ray, Sreejani Banik & Saraddyuti Chakravarty

Focus Areas: AI Integration, Backend Logic, and Sustainable Solutions


πŸͺͺ License

This project is licensed under the MIT License β€” free to use, modify, and distribute with proper attribution.


πŸ’š β€œCrafting a Seamless Bridge Between Restaurants, NGOs & Communities β€” Powered by AI.”

About

This website provides a platform to connect restaurants and all the NGO's and old age homes and aims to provide a platform that will ensure distribution of excess food among these community centre that ensures minimal wastage of food and optimal usage of resources. HTML,CSS, Java script along side Node JS have been used in this project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 52.6%
  • Python 33.9%
  • CSS 12.5%
  • JavaScript 1.0%