A Node.js backend service that analyzes food waste using Google's Gemini AI and manages student ration data.
PlatePredict is a solution designed to monitor and reduce food waste in school cafeterias. The system analyzes images of leftover food on plates, assigns a waste score, and adjusts student ration allocations accordingly to promote more responsible consumption habits.
- AI-Powered Waste Analysis: Uses Google's Gemini AI to analyze food waste from plate images
- Student Management: Track individual student waste patterns and ration allocations
- RESTful API: Simple API endpoints for integration with frontend applications
- MongoDB Integration: Persistent storage for student data and waste history
- Node.js - JavaScript runtime
- Express - Web framework
- MongoDB - Database
- Google Gemini AI - Image analysis
- Docker - Containerization
- Node.js (v16+)
- MongoDB connection string
- Google Gemini AI API key
-
Clone the repository:
git clone <repository-url> cd platePredit-js-backend
-
Install dependencies:
npm install
-
Create a
.envfile in the root directory:MONGO_URI=your_mongodb_connection_string GENAI_API_KEY=your_google_gemini_ai_key PORT=5000 -
Start the server:
npm start
-
Build and run using Docker Compose:
docker-compose up -d
-
Or build and push using the provided script:
./build.cmd
- POST
/add_entry - Body:
{ "student_id": "string" } - Response:
{ "message": "entry added successfully" }
- POST
/add_waste - Body:
{ "student_id": "string", "image": "base64_encoded_image" } - Response:
{ "message": "waste updated successfully" }
- GET
/get_all_entries - Response: Array of student records
- GET
/get_entry?student_id=123 - Query Parameter:
student_id - Response: Student record object
- Student Registration: A new student is registered with a unique ID
- Waste Recording: After a meal, a photo of the student's plate is submitted
- AI Analysis: The Gemini AI analyzes the image and assigns a waste score (0-10)
- Ration Adjustment:
- Low waste scores (0-1) increase rations
- High waste scores (4+) decrease rations
| Variable | Description |
|---|---|
| MONGO_URI | MongoDB connection string |
| GENAI_API_KEY | Google Gemini AI API key |
| PORT | Port to run the server (default: 5000) |
The application is containerized with Docker and can be deployed to any platform that supports Docker containers.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.