Inspiration

Despite the fact that 1.3 billion tons of food are wasted every year, millions of people still go to bed hungry in our paradoxical society. The issue is not a shortage of food, but rather a lack of information and logistics. We were motivated to use AI to close this gap by creating ResQ Chain. In order to "close the loop" on food waste, we sought to develop a solution that not only saves excess food but also makes sure it is safe to eat before it is given to those in need.

What it does

ResQ Chain is an AI-powered logistics platform that connects food donors (restaurants, grocery stores, individuals) with local drivers and shelters.

AI Freshness Scan: Users simply snap a photo of the food. Our integration with Google Gemini analyses the image to identify the item, estimate quantity, and calculate a "Freshness Score."

Safety Guardrails: If the AI detects spoilage (e.g., a rotten apple), the system automatically rejects the donation and advises the user to compost it, ensuring only safe food enters the supply chain.

Smart Logistics: Validated donations are broadcast to nearby drivers with optimized routes.

Full Cycle Tracking: Donors can track their impact through a history of rescued items.

Sustainability Education: The app features a "Sustainable Garden" and "Tips & Tricks" section to help users grow their own food and extend the shelf life of their groceries.

How we built it

We built ResQ Chain as a modern full-stack application:

Frontend: We used Next.js (React) with Tailwind CSS to create a sleek, responsive, "Glassmorphism" UI that feels professional and trustworthy.

AI/ML: We leveraged Google Gemini 1.5 Flash (via the Google AI Studio API) for multimodal vision analysis. This allows us to detect food types and spoilage without training custom models from scratch.

Backend: We built a robust REST API using Python (FastAPI) to handle image processing and business logic.

Database: We utilized MongoDB for flexible document storage (donations, users) and integrated Snowflake for data warehousing.

Challenges we ran into

AI Hallucinations: Initially, the AI was "too nice" and would rate slightly bruised fruit as 100% fresh. We had to refine our system prompts to be strict about food safety standards.

State Management: Coordinating the data flow between the "Donor" view and the "Driver" view in real-time without a WebSocket server was tricky, but we solved it using efficient state lifting and polling simulation for the demo.

Handling Multi-Item Uploads: Allowing users to upload a mixed bundle of photos (e.g., bread and apples) and parsing the AI response for each item individually required complex JSON parsing logic.

Accomplishments that we're proud of

Deterministic Guardrails on Probabilistic AI: Large Language Models (LLMs) can be unpredictable. We successfully engineered a safety layer that sanitizes the AI's output. By implementing strict logic checks on the "Freshness Score" returned by Gemini, we prevent the system from accepting spoiled items (e.g., scoring a rotten apple <50%), ensuring our platform adheres to food safety regulations automatically.

Multimodal JSON Schema Enforcement: Getting an LLM to look at multiple images and return a strictly formatted JSON array (containing specific keys like shelf_life and freshness_score) is difficult. We perfected our system prompts to ensure Gemini 1.5 Flash returns parseable data 100% of the time, allowing our frontend to render dynamic UI cards without crashing.

Optimized Payload Handling: We engineered the frontend to efficiently handle multiple high-resolution image uploads. By converting streams to optimized Base64 strings and batching them into a single API payload, we reduced the latency between "Upload" and "Analysis" to under 2 seconds, maintaining a responsive user experience.

Hybrid State Management System: To simulate a real-time environment for the hackathon without setting up complex WebSockets, we built a robust React state architecture. This allows data to flow instantly from the Donor View (Input) to the Driver Dashboard (Logistics) and finally to the History Log (Persistence) without losing context or requiring page reloads.

What we learned

Prompt Engineering for Structured Data: We learned that simply asking an AI to "analyze food" yields vague text. We mastered the technique of "One-Shot Prompting" and providing specific JSON skeletons in the prompt context to force the model into acting as a structured API rather than a chatbot.

Handling Asynchronous Vision Tasks: Integrating Google's Generative AI SDK taught us how to manage asynchronous data streams. We learned to handle edge cases where the AI might timeout or return malformed data by implementing fallback simulation logic, ensuring the demo never breaks during presentation.

Cross-Origin Resource Sharing (CORS) & API Routes: By wiring our Next.js frontend to a custom backend route, we deepened our understanding of HTTP methods, headers, and secure API key management (keeping credentials server-side rather than exposing them in the client).

The Complexity of "Food" as Data: We realized that food isn't just a label; it has attributes like state (liquid vs. solid), unit (kg vs. gallons), and perishability. Modeling this data structure in our application state was a valuable lesson in database schema design.

What's next for ResQChain-Food waste management system

IoT Integration: We plan to integrate temperature sensors for cold-chain monitoring during transport.

Gamification: Adding a leaderboard and "Impact Tokens" to reward consistent donors and volunteer drivers.

Mobile App: Porting the web interface to React Native for easier on-the-go access for drivers.

Built With

Share this project:

Updates