FreshTrack AI is a full-stack, AI-powered food expiry tracking and waste reduction web application. Designed with a premium dark cyberpunk aesthetic, it helps users track their pantry, intelligently predicts when items will spoil, and automatically generates recipes using expiring ingredients to minimize food waste.
Camera-based OCR using Tesseract.js directly in the browser. It extracts expiry dates with confidence scoring (High/Medium/Low) and supports over 7 different date formats. Privacy first: All OCR processing happens client-side; no image data is ever sent to any external server.
A robust PostgreSQL-backed pantry tracking product name, category, expiry date, and quantity. The system auto-computes status (Fresh โ Expiring Soon โ Critical โ Expired) and days remaining via generated columns. Row Level Security (RLS) ensures strict user data isolation.
A dedicated FastAPI microservice calculates a dynamic urgency score per item using the formula:
score = (1 / days_remaining) ร category_weight ร quantity_factor
Items are ranked and displayed with visual urgency badges to prioritize consumption.
Zero user input required. When critical items are detected, a pipeline triggers: detects critical cluster โ ranks by urgency โ sends a structured POST request to Google Gemini 2.0 Flash โ parses the JSON recipe response โ saves to recipe history โ notifies the user.
Users can specify available ingredients alongside dietary preferences (e.g., gluten-free, vegan). This uses the same Gemini 2.0 Flash pipeline with preference injection for highly tailored culinary suggestions.
Database-backed, actionable alerts such as "Milk expires in 2 days โ Make Pancakes". The dashboard auto-refreshes these alerts every 60 seconds. Notifications are triggered automatically upon item addition and auto-recipe generation.
Visualizes your impact using Recharts. Includes a PieChart for inventory status breakdown and a BarChart comparing total category count vs. critical items. Tracks key metrics: Items Saved This Week, Waste Reduction %, Critical Count, and Total Tracked.
Allows users to mark items as Consumed or Discarded (Expired/Waste). This historical log feeds the analytics engine, enabling precise waste reduction percentage calculations.
Secure real email/password authentication via JWT. All routes are strictly auth-gated. A pre-configured demo account (demo@freshtrack.ai) with seeded realistic inventory is available for instant exploration.
A sleek dark cyberpunk/neon aesthetic featuring glassmorphism cards and fluid Framer Motion page transitions. The interface is fully responsive, offering a desktop sidebar and a mobile bottom navigation bar, styled with custom color tokens: Primary (#00ff9d), Accent (#00d4ff), and Secondary (#bf00ff).
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CLIENT TIER โ
โ Browser / Mobile Device (React 19, Tailwind, Framer) โ
โ [ Tesseract.js (In-Browser OCR) ] โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FRONTEND HOSTING โ โ MICROSERVICE โ
โ Vercel (Next.js 16 App) โ โ Render (FastAPI / Python) โ
โ - API Routes โโโโผโโบ - Urgency Scoring โ
โ - Server Actions โ โ - External AI Calls โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DATABASE & AUTH TIER โ โ AI LLM TIER โ
โ Supabase (PostgreSQL) โ โ Google Gemini 2.0 Flash โ
โ - Row Level Security โ โ - JSON Recipe Generation โ
โ - JWT Auth โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Layer | Technology |
|---|---|
| Frontend Framework | Next.js 16, React 19, TypeScript |
| Styling & UI | Tailwind CSS, shadcn/ui, Framer Motion |
| Backend Service | FastAPI (Python) |
| Database & Auth | Supabase (PostgreSQL + RLS) |
| LLM / AI | Google Gemini 2.0 Flash |
| Computer Vision | Tesseract.js |
| Data Visualization | Recharts |
| Deployment | Vercel (Frontend), Render (Backend) |
The system relies on 4 core tables managed in Supabase PostgreSQL:
inventory_itemsid(uuid, PK),user_id(uuid, FK),name(text),category(text),expiry_date(date),quantity(int),status(computed),created_at(timestamp)
consumption_logsid(uuid, PK),item_id(uuid, FK),user_id(uuid, FK),action(text: consumed/discarded),logged_at(timestamp)
recipe_historyid(uuid, PK),user_id(uuid, FK),recipe_json(jsonb),used_items(text[]),created_at(timestamp)
notificationsid(uuid, PK),user_id(uuid, FK),message(text),type(text),is_read(boolean),created_at(timestamp)
- Node.js 18+
- Python 3.10+
- Supabase Account
- Google Gemini API Key
-
Clone the repository
git clone https://github.com/Aakansh-tandon/FreshTrack_AI.git cd FreshTrack_AI -
Setup the Frontend (Next.js)
npm install
-
Setup the Backend (FastAPI)
cd backend python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` pip install -r requirements.txt
Create a .env.local in the root (for Next.js) and a .env in the /backend folder (for FastAPI).
| Variable | Location | Description |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Frontend | Your Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
Frontend | Your Supabase anonymous API key |
NEXT_PUBLIC_API_URL |
Frontend | URL of the FastAPI backend (e.g., http://localhost:8000) |
SUPABASE_SERVICE_ROLE_KEY |
Backend | Supabase service key for backend admin operations |
GEMINI_API_KEY |
Backend | Google Gemini 2.0 Flash API key for recipe generation |
Start the FastAPI Backend:
cd backend
uvicorn main:app --reload(Runs on http://localhost:8000)
Start the Next.js Frontend:
# In the project root
npm run dev(Runs on http://localhost:3000)
The FastAPI backend exposes the following endpoints:
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/inventory |
Fetch all user inventory items. |
POST |
/api/inventory |
Add a new item. Body: { name, category, expiry_date, quantity } |
PATCH |
/api/inventory/[id] |
Update item status or quantity. |
POST |
/api/recipes |
Generate custom recipe. Body: { ingredients: [], preferences: [] } |
GET |
/api/notifications |
Fetch user notifications. |
POST |
/api/notifications |
Create a new alert or mark as read. |
GET |
/api/consumption-logs |
Fetch historical logs for analytics. |
GET |
/api/auto-trigger |
Manually invoke the automated recipe pipeline. |
To prioritize which food needs to be eaten first, the FastAPI service calculates a score based on expiration proximity, item type, and amount.
Formula:
Score = (1 / Days Remaining) ร Category Weight ร Quantity Factor
Category Weights:
| Category | Weight | Reason |
|---|---|---|
| Seafood | 2.0 | Highest risk of foodborne illness |
| Meat | 1.8 | High spoilage risk |
| Dairy | 1.5 | Moderate to high spoilage risk |
| Produce | 1.2 | Moderate spoilage, visually detectable |
| Frozen/Pantry | 0.5 | Long shelf life |
Items with higher scores receive priority placement and aggressive UI highlighting.
FreshTrack AI proactively prevents waste by suggesting what to cook before it goes bad.
- Trigger: The system detects a cluster of items entering the "Critical" state (โค 2 days remaining).
- Rank: Items are sorted descending by their Urgency Score.
- Prompt Construction: The backend formats the top critical ingredients into a structured prompt, enforcing JSON output requirements.
- LLM Invocation: The prompt is sent to Google Gemini 2.0 Flash.
- Parsing: The response is validated and parsed into a JSON recipe object (title, prep time, instructions, macros).
- Persistence & Alert: The recipe is saved to
recipe_historyand a notification is dispatched to the user dashboard.
A pre-populated demo account is available for recruiters and reviewers to instantly explore the dashboard without setting up an account.
Login Credentials:
- Email:
demo@freshtrack.ai - Password: (Try logging in via the demo button on the auth page)
What's included in the Demo:
- A populated pantry with a mix of Fresh, Expiring Soon, and Critical items.
- Pre-calculated waste reduction analytics on the dashboard.
- Historical consumption logs.
- Generated recipes based on the current critical inventory.
- Create a new Supabase project.
- Execute the provided SQL schema file to generate tables and RLS policies.
- Retrieve the
URL,Anon Key, andService Role Key.
- Connect your GitHub repository to Render.
- Create a new Web Service.
- Build Command:
pip install -r requirements.txt - Start Command:
uvicorn main:app --host 0.0.0.0 --port 10000 - Add
GEMINI_API_KEYandSUPABASE_SERVICE_ROLE_KEYto Environment Variables.
- Import the repository into Vercel.
- Framework Preset: Next.js.
- Add
NEXT_PUBLIC_SUPABASE_URL,NEXT_PUBLIC_SUPABASE_ANON_KEY, andNEXT_PUBLIC_API_URL(pointing to the Render URL) to Environment Variables. - Click Deploy.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.