Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍽️ FoodWise - Smart Surplus Food Redistribution

A intelligent platform connecting food surplus from canteens with users in need, reducing food waste while supporting communities.


🌟 Overview

FoodWise is a smart food redistribution platform that enables canteens and food establishments to share surplus food with users in need. By connecting food donors with recipients in real-time, we reduce food waste and combat food insecurity.

Key Goals

  • πŸ“‰ Reduce food waste from canteens and establishments
  • 🀝 Connect surplus food with people in need
  • πŸ“Š Track food redistribution metrics
  • ⏰ Prevent food spoilage with pickup time management

✨ Features

For Canteens

  • βœ… Post surplus food listings with details (name, quantity, location)
  • βœ… Set pickup times for fresh food distribution
  • βœ… Track claimed food items
  • βœ… Monitor redistribution statistics
  • πŸ”’ Secure authentication with email/password

For Users

  • βœ… Browse available food listings in real-time
  • βœ… Claim food items for pickup
  • βœ… View food details (quantity, location, pickup time)
  • πŸ”’ Secure authentication with email/password
  • βœ… Password recovery options

General

  • πŸ“Š Real-time stats dashboard
  • πŸ”„ Automatic expiration handling
  • πŸ“± Responsive web interface
  • πŸ” Firebase authentication & Firestore database

πŸ› οΈ Tech Stack

Layer Technology
Frontend HTML5, CSS3, JavaScript (Vanilla)
Backend Node.js + Express.js
Database Firebase Firestore
Authentication Firebase Auth
Email Nodemailer
Styling Tailwind CSS

πŸ“ Project Structure

smart-food-redistribution-FoodWise/
β”œβ”€β”€ public/                          # Static frontend files
β”‚   β”œβ”€β”€ index.html                   # Main entry point
β”‚   β”œβ”€β”€ canteen/                     # Canteen UI
β”‚   β”‚   β”œβ”€β”€ canteen-login.html      # Canteen login page
β”‚   β”‚   β”œβ”€β”€ canteen-login.css       # Canteen login styles
β”‚   β”‚   β”œβ”€β”€ canteen-dashboard.html  # Canteen dashboard
β”‚   β”‚   └── reset-pass-canteen.html # Password reset
β”‚   └── user/                        # User UI
β”‚       β”œβ”€β”€ user-login.html         # User login page
β”‚       β”œβ”€β”€ user-login.css          # User login styles
β”‚       β”œβ”€β”€ user-dashboard.html     # User dashboard
β”‚       └── reset-pass-user.html    # Password reset
β”‚
β”œβ”€β”€ src/                             # Source code
β”‚   β”œβ”€β”€ app/                         # Application logic
β”‚   β”‚   β”œβ”€β”€ canteen-app.js          # Canteen JavaScript
β”‚   β”‚   β”œβ”€β”€ user-app.js             # User JavaScript
β”‚   β”‚   β”œβ”€β”€ canteen-login.js        # Canteen login handler
β”‚   β”‚   └── user-login.js           # User login handler
β”‚   └── config/                      # Configuration
β”‚       β”œβ”€β”€ firebaseconfig.js        # Firebase setup
β”‚       └── serviceAccountKey.json   # Firebase service account
β”‚
β”œβ”€β”€ server/                          # Backend server
β”‚   └── server.js                    # Express server & API
β”‚
β”œβ”€β”€ package.json                     # Dependencies
β”œβ”€β”€ .env                             # Environment variables
└── README.md                        # This file

πŸ“¦ Prerequisites

  • Node.js v16+ and npm/yarn
  • Git for version control
  • Firebase Account with Firestore & Authentication enabled
  • Firebase Service Account Key (for admin operations)
  • Modern web browser (Chrome, Firefox, Safari, Edge)

πŸš€ Installation

1. Clone the Repository

git clone <repository-url>
cd smart-food-redistribution-FoodWise

2. Install Dependencies

npm install

3. Set Up Firebase

  1. Go to Firebase Console
  2. Create a new project or use existing one
  3. Enable Firestore Database and Authentication (Email/Password)
  4. Download your Firebase Admin SDK private key (JSON)
  5. Save it as src/config/serviceAccountKey.json

4. Configure Environment Variables

Create a .env file in the root directory:

# Firebase Configuration
SERVICE_ACCOUNT_JSON={"type":"service_account",...}
# OR use with the JSON file directly
GOOGLE_APPLICATION_CREDENTIALS=./src/config/serviceAccountKey.json

# Server Configuration
PORT=3000
NODE_ENV=development

# Email Configuration (Optional - for password reset)
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-app-password

▢️ Running the Project

Development Mode

npm run dev
  • Backend runs on http://localhost:3000
  • Frontend can be served via Live Server or Python

Production Mode

npm start

Serve Frontend (Alternative)

# Using Python 3
cd public
python3 -m http.server 8000

# Using Python 2
python -m SimpleHTTPServer 8000

# Visit http://localhost:8000

πŸ“‘ API Documentation

Base URL

http://localhost:3000/api

Endpoints

Health Check

GET /api/health

Response:

{ "status": "ok" }

Post Food Listing

POST /api/food
Content-Type: application/json

{
  "foodName": "Leftover Pizza",
  "quantity": "5 slices",
  "location": "Main Canteen, Building A",
  "pickupTime": "2026-05-16T18:00:00Z",
  "postedBy": "canteen-user@example.com"
}

Get Available Food

GET /api/food

Response:

[
  {
    "id": "food123",
    "foodName": "Leftover Pizza",
    "quantity": "5 slices",
    "location": "Main Canteen",
    "pickupTime": "2026-05-16T18:00:00Z",
    "status": "available",
    "postedBy": "canteen@example.com",
    "createdAt": "2026-05-16T12:00:00Z"
  }
]

Claim Food

POST /api/food/:id/claim
Content-Type: application/json

{
  "claimedBy": "user@example.com"
}

Get Statistics

GET /api/stats

Response:

{
  "totalListings": 42,
  "availableListings": 15,
  "claimedListings": 20,
  "expiredListings": 7,
  "totalQuantity": "150 items"
}

Expire Food Listings (Maintenance)

POST /api/expire

Automatically marks expired listings based on pickupTime.


πŸ—„οΈ Database Schema

Firestore Collection: food_listings

{
  "id": "food_12345",
  "foodName": "string",
  "quantity": "string",
  "location": "string",
  "pickupTime": "timestamp",
  "status": "available | claimed | expired",
  "postedBy": "string (email)",
  "createdAt": "timestamp",
  "claimedBy": "string | null (email)",
  "claimedAt": "timestamp | null",
  "expiresAt": "timestamp"
}

Firestore Collection: users

{
  "uid": "firebase-uid",
  "email": "string",
  "displayName": "string",
  "role": "canteen | user",
  "createdAt": "timestamp",
  "lastLogin": "timestamp"
}

πŸ” Environment Variables

Variable Description Required
SERVICE_ACCOUNT_JSON Firebase service account JSON βœ…
GOOGLE_APPLICATION_CREDENTIALS Path to service account file βœ… (if not using above)
PORT Server port ❌ (default: 3000)
NODE_ENV Environment type ❌ (default: development)
EMAIL_USER Email for password reset ❌
EMAIL_PASSWORD Email app password ❌

🀝 Contributing

We welcome contributions! Here's how:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Coding Standards

  • Use consistent naming conventions
  • Add comments for complex logic
  • Test before submitting PR
  • Update documentation

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

About

Smart surplus food redistribution platform connecting canteens with people in need - reducing food waste with real-time listings, claim tracking, and Firebase-backed authentication.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages