Inspiration
Every day, grocery stores in India throw away tonnes of perfectly good food simply because it's approaching its expiry date. A packet of milk with 6 hours left. A tray of bakery items baked this morning. A bottle of juice that expires tomorrow. These products aren't unsafe — they're just unsellable at full price.
We grew up in Hyderabad and watched this happen at the local kirana store down the street. The owner would rather discard stock than deal with the complexity of discounting it dynamically. Meanwhile, families nearby are price-sensitive and would gladly buy quality food at a discount.
NearExpiry was born from one question: what if the price of a product automatically dropped as its expiry approached — and consumers nearby got notified in real time?
What it does
NearExpiry is a two-sided marketplace connecting stores with near-expiry inventory to conscious consumers through dynamic, time-based discounts.
For store owners:
- List products with expiry dates and watch discounts calculate automatically (10% → 80% as expiry approaches)
- Products under 3 hours from expiry flip to Flash Deal status at 80% off
- Receive real-time claim notifications with a 30-minute pickup window
- Track revenue recovered and environmental impact on the analytics dashboard
For consumers:
- Open an interactive map and see nearby deals with live discount badges
- Flash deal markers pulse on the map so urgent deals are impossible to miss
- Claim a deal, pay via Stripe, and receive a 4-digit code + QR code for pickup
- Build an impact profile: track kg of food saved, kg of CO₂ avoided, and level up from 🌱 Seedling to 🌍 Planet Saver
The platform also features:
- AI-powered listing assistant (ERNIE/Baidu LLM) that auto-generates product descriptions
- AI deal curator that personalises recommendations by consumer history and weather
- Shareable impact cards generated with Kling Image Generation
- Voice search: say "cheap dairy nearby" and the map filters instantly
- Weather-based deal boosting — on a 35°C Hyderabad day, Beverages and Dairy deals surface first
How we built it
We built NearExpiry entirely on the MeDo platform, using its visual builder for UI and its plugin ecosystem for all external integrations.
| Layer | Technology |
|---|---|
| Frontend | React 18 + TypeScript + Vite |
| UI components | shadcn/ui + Tailwind CSS |
| Backend & auth | Supabase (PostgreSQL + Auth + Storage + Edge Functions) |
| Real-time | Supabase Realtime subscriptions |
| Maps | Leaflet.js with custom clustering |
| Payments | Stripe Checkout (via Supabase Edge Functions) |
| AI features | Baidu ERNIE (LLM), Kling (image generation) |
| Notifications | MeDo Push Notifications plugin |
| QR codes | MeDo QR Code Generator plugin |
| Analytics | Chart.js (4-chart store dashboard) |
The discount engine is the heart of the platform. A background service recalculates discount_percentage and current_price for every active listing every 5 minutes based on time remaining to expiry:
$$ \text{discount} = \begin{cases} 10\% & \text{if } t > 24\text{h} \ 25\% & \text{if } 12 < t \leq 24\text{h} \ 40\% & \text{if } 6 < t \leq 12\text{h} \ 60\% & \text{if } 3 < t \leq 6\text{h} \ 80\% & \text{if } t \leq 3\text{h (Flash Deal)} \end{cases} $$
The CO₂ impact is calculated per claim using category-specific emission factors:
$$ \text{CO}2\text{ avoided (kg)} = \text{weight (kg)} \times \text{EF}{\text{category}} $$
Where $\text{EF}{\text{dairy}} = 3.2$, $\text{EF}{\text{meat}} = 6.1$, $\text{EF}_{\text{bakery}} = 1.1$, etc.
Row Level Security (RLS) is enabled on all 8 Supabase tables, with role-based access for consumers, store owners, and admins.
Challenges we ran into
1. Real-time discount synchronisation — keeping countdown timers and discount badges in sync across multiple browser sessions without hammering the database required careful use of Supabase Realtime subscriptions combined with client-side timer interpolation.
2. Geolocation + map performance — clustering 50+ listings on Leaflet.js while maintaining smooth pan/zoom performance with live distance calculations from the user's location needed careful debouncing and virtual marker rendering.
3. Two-sided UX in one codebase — store owners and consumers have fundamentally different mental models. Building role-based route guards, dashboards, and notification flows without creating a tangled codebase required disciplined separation of concerns from day one.
4. Stripe + Supabase claim atomicity — ensuring that a successful Stripe payment always creates exactly one claim record (and never zero or two) under concurrent load required idempotency keys and database-level unique constraints.
5. AI prompt quality for ERNIE — getting the Baidu ERNIE LLM to produce concise, trustworthy product descriptions (not hallucinated nutritional claims) for Indian food categories required significant prompt engineering and output validation.
Accomplishments that we're proud of
- A fully working dynamic discount engine that runs every 5 minutes and transitions products to Flash Deal status automatically
- A complete two-sided marketplace with distinct, polished dashboards for store owners and consumers
- Real environmental impact tracking — not just a vanity metric, but calculated from actual CO₂ emission factors per food category
- A gamified consumer level system (Seedling → Sprout → Green Thumb → Eco Warrior → Planet Saver) that makes sustainability feel rewarding
- Stripe payment integration that works end-to-end, from claim to pickup confirmation
- 5 seeded demo stores across real Hyderabad localities (Banjara Hills, Jubilee Hills, Madhapur, Kondapur, Gachibowli)
What we learned
- Urgency is a product feature. The countdown timer and pulsing flash deal marker aren't decorations — they drive action. We learned that showing time pressure visually converts browsers into buyers.
- Two-sided marketplaces need to be built from the middle out. We started with the claim record — the moment of transaction — and built outward to both sides. This kept the data model clean.
- MeDo's plugin ecosystem is genuinely powerful. Wiring Kling image generation into an impact card in under 2 hours would have taken days building infrastructure from scratch.
- CO₂ numbers need to be explainable. Early testers asked "how did you calculate that?" — we added the methodology page to build trust.
What's next for NearExpiry
- Merchant app (Android) — store owners need a dedicated mobile experience for scanning claim QR codes at pickup
- Subscription tier for stores — premium analytics, priority listing placement, and bulk listing imports via CSV
- Neighbourhood impact leaderboard — which Hyderabad locality saved the most food this week?
- B2B expansion — hotel chains, restaurant groups, and cloud kitchens generating large near-expiry volumes
- Carbon credit integration — verified CO₂ savings fed into a carbon offset marketplace
- WhatsApp notifications — for the majority of Indian consumers who prefer WhatsApp over push notifications
Built With
- ai
- baidu
- chart.js
- css
- edge
- ernie
- functions
- kling
- leaflet.js
- level
- medo
- postgresql
- react
- realtime
- row
- security
- shadcn/ui
- speech
- stripe
- supabase
- tailwind
- typescript
- vite
- web
Log in or sign up for Devpost to join the conversation.