Inspiration

At closing time, a neighborhood grocer may still have milk, bread, produce, and meat approaching their expiry dates. The food still has value, but the window to sell it is closing.

The owner faces a difficult decision:

  • Discount too early and lose margin.
  • Discount too late and risk wasting the product.
  • Apply one blanket discount and ignore differences in demand.

According to the UNEP Food Waste Index Report 2024, 1.05 billion tonnes of food waste were generated across households, food service, and retail in 2022. Retail represented 12% of this total. Food loss and waste also cost the global economy roughly US$1 trillion each year and generate an estimated 8–10% of global greenhouse-gas emissions.

A separate European Commission study estimates that up to 10% of annual EU food waste is linked to date marking.

FreshSaver focuses on one actionable part of this larger problem: helping independent grocers make better markdown decisions while the food can still be sold.

What FreshSaver Does

FreshSaver is an explainable AI markdown copilot and local deal marketplace.

It connects the complete workflow:

  1. A store owner imports inventory through CSV or manual product entry.
  2. FreshSaver identifies products approaching their recorded expiry dates.
  3. XGBoost predicts sell-through under every eligible candidate price.
  4. A deterministic optimizer applies margin, expiry, and minimum-price constraints.
  5. The recommendation is saved as pending instead of being published automatically.
  6. The owner reviews the evidence and approves or rejects the recommendation.
  7. Approved deals appear in the customer marketplace.
  8. Opted-in shoppers receive relevant store and category offers.
  9. Orders and inventory outcomes are recorded for future learning.

The goal is not always to discount. If predicted full-price demand can clear the stock, FreshSaver recommends holding the current price.

Target Users

FreshSaver is designed for independent grocery stores that need practical decision intelligence without expensive hardware or a long enterprise integration.

The platform has two connected experiences:

  • Store owners manage products, subscribers, pricing recommendations, and expiry risk.
  • Shoppers discover approved local deals, opt into store notifications, reserve products, and view their order history.

Key Features

Store-Owner Portal

The owner portal contains four primary pages:

  • Dashboard: inventory, expiry, deal, and subscriber metrics.
  • Products: stock, SKU, category, expiry, original price, current price, discount, and days remaining.
  • Customers: store-specific opted-in shoppers, interests, location, consent source, and notification status.
  • Pricing Log: expiry queue, AI-agent execution, recommendation review, approval, rejection, and audit history.

Owners can also add products manually, import CSV files, inspect model evidence, review email logs, and manage store orders.

Customer Marketplace

Shoppers can:

  • Browse active deals and participating stores.
  • Search and filter by category, urgency, or store.
  • View current price, original price, stock, and store information.
  • Add products to a single-store cart.
  • Use the explicit mock checkout experience.
  • View order history.
  • Opt into store-specific deal notifications.
  • Subscribe through the website or an in-store QR journey.

Explainable Recommendations

Every recommendation records:

  • Candidate prices tested
  • Predicted sales range
  • Clearance probability
  • Expected margin
  • Expected unsold inventory
  • Model provider and version
  • Training-data provenance
  • Important XGBoost factors
  • Deterministic reason codes
  • Generated campaign content
  • Reviewer and approval timestamps

No markdown is published silently. The store owner remains the final authority.

How We Use AI

FreshSaver uses two AI systems for different jobs.

AI 1: XGBoost For Demand Prediction

XGBoost predicts how many units are likely to sell before expiry under each candidate price.

The model uses structured inputs such as:

  • Product category
  • Current stock
  • Days until expiry
  • Original and candidate prices
  • Candidate discount
  • Recent seven-day sales velocity
  • Previous 23-day sales velocity
  • Weekday
  • Number of historical observations

For each candidate, it returns low, expected, and high sell-through estimates, clearance probability, and feature contributions.

We use XGBoost because grocery demand is a nonlinear tabular prediction problem. An LLM is not the right tool for reproducible numerical forecasting.

Deterministic Optimizer For Control

The optimizer is intentionally not AI. It applies hard constraints and selects the strongest eligible candidate.

The objective is:

$$

\text{Expected Contribution}

\text{Expected Revenue}

\text{Cost of Goods Sold}

\text{Expected Disposal Cost} $$

The optimizer enforces:

  • Recorded expiry blocks
  • Merchant minimum price
  • Maximum discount by urgency tier
  • Available stock
  • Manual price overrides
  • Full-price holds when demand is sufficient

This keeps business and safety rules deterministic and testable.

AI 2: Gemini For Communication

Gemini is used for language tasks, not pricing.

It receives only fixed product and model evidence and can generate:

  • A manager-facing explanation
  • Campaign headline and email copy
  • A product-specific recipe idea
  • Short ingredients and preparation steps

Gemini cannot change the selected price, expiry date, model prediction, or guardrails.

Customer names and preferences are never sent to Gemini. Personalization happens locally after generation. Emails can include the shopper's first name, the store and category they opted into, and an escaped recipe card with allergen, storage, package-date, and cooking reminders.

If Gemini is unavailable, FreshSaver uses a clearly labeled deterministic recipe and campaign fallback.

How We Built It

The customer marketplace and owner portal use Next.js 16, React 19, TypeScript, and Tailwind CSS.

Supabase provides:

  • PostgreSQL
  • Authentication
  • Row Level Security
  • CSV object storage
  • Store, product, customer, order, subscription, recommendation, and audit data

The XGBoost model runs in a Python FastAPI service deployed through Docker on Render.

The web application and scheduled pricing scans run on Vercel. The scan progress is streamed to the owner interface using server-sent events.

Brevo is supported for store-specific customer email delivery. Failed sends are recorded and remain eligible for retry.

Challenges We Faced

Separating Prediction From Decision

A major design challenge was deciding which parts should use AI and which should remain deterministic.

We avoided asking an LLM to calculate prices. XGBoost predicts demand, deterministic policy applies constraints, Gemini communicates the evidence, and the owner makes the final decision.

Sparse And Missing Data

New products may not have enough sales history. FreshSaver labels this condition and uses a transparent statistical fallback instead of presenting unsupported estimates as machine learning.

Multi-Store Isolation

Products, subscriptions, scans, recommendations, orders, and logs must remain scoped to the correct store. We implemented store assignments, server-side ownership checks, and Supabase RLS policies.

Trustworthy Generative Output

Generated content must not alter prices or make unsupported food-safety claims. Gemini receives constrained evidence, returns structured JSON, and all generated email and recipe fields are escaped before HTML rendering.

Deployment And Cold Starts

The Next.js application runs on Vercel while XGBoost runs on Render. We added health checks, authenticated prediction requests, configurable timeouts, and a deterministic fallback for model-service outages.

What We Learned

We learned that a useful AI product is not defined by adding a chatbot.

The most important design decision was assigning each component the job it is best suited for:

  • XGBoost predicts.
  • Deterministic policy constrains.
  • Gemini communicates.
  • The store owner decides.

We also learned that transparent fallbacks, evidence provenance, consent tracking, and honest limitations make an AI recommendation more useful than an unexplained confidence score.

Accomplishments We Are Proud Of

  • Deployed public customer and owner experiences
  • Live authenticated XGBoost prediction service
  • Candidate-level prediction ranges and feature contributions
  • Human approval before price publication
  • Store-specific shopper consent
  • Personalized recipe campaign generation with no customer PII sent to Gemini
  • Credential-free synthetic judge demo
  • Public source repository
  • 20 automated tests across seven files
  • Complete model card, security notes, architecture, presentation, and video script

Current Evidence And Limitations

The bundled XGBoost model is evaluated on 4,000 explicitly synthetic rows with an 800-row time-ordered validation split.

The evaluation demonstrates the training, prediction, explanation, and deployment pipeline. It is not evidence of real-store accuracy or causal business impact.

FreshSaver does not currently claim measured:

  • Waste reduction
  • Incremental revenue
  • Margin lift
  • Learned price elasticity
  • Production payment reliability

Checkout is an explicit mock payment experience, and stores remain responsible for food safety, storage, recalls, handling, labels, and local law.

What's Next

The next milestone is a controlled merchant pilot:

  1. Run recommendations in shadow mode.
  2. Compare forecasts with actual sell-through.
  3. Capture owner approval, rejection, and override reasons.
  4. Measure waste, gross margin, and staff time.
  5. Introduce controlled markdown holdouts.
  6. Learn store and category price elasticity.
  7. Add transactional inventory reservations and real payments.
  8. Integrate POS feeds and electronic shelf labels.
  9. Route eligible unsold inventory into donation workflows.

FreshSaver already connects an AI prediction to a reviewable store decision and a real shopper workflow. The next claim will come from measured merchant outcomes, not synthetic campaign totals.

Built With

Share this project:

Updates

Submission history