FoodLens is a gamified nutrition & wellness tracker built as a React single-page app.
It combines fun animations, local dataset-driven logging, XP gamification, and badges —
all while working completely offline with localStorage.
🚀 Built for hackathons & demos: no backend required!
- Full-screen animated hero with food & wellness theme.
- Smooth CSS/SVG animations (parallax, gradients, floating icons).
- Bold “Get Healthy!” call-to-action.
- Login modal (no new page).
- Collects:
username,email,dailyCalorieTarget,password (optional). - Data saved in
localStorage→foodLens:user. - Profile menu: edit info, reset data, or logout.
- Quick Log: upload photo OR type dish name (works offline).
- Suggestions modal: top-3 matches from local dataset (optional AI proxy).
- Today’s Log: meals list with time, nutrition, XP earned.
- XP & Levels: animated XP bar, levels every 100 XP.
- Charts: daily macros pie + weekly calories/XP chart.
- Badges panel: milestone XP & streak achievements.
- XP =
healthScore ÷ 2(rounded). - Levels every 100 XP.
- Streak: +1 day if at least one meal has
healthScore ≥ 60. - Badges for XP milestones & 7-day streaks.
- Fun micro-animations (+XP popups, smooth progress bar).
foods.jsonwith 50–80 common Indian & fast-food dishes.- Users can add custom dishes (saved locally).
- Offline-first design ensures demo works without internet.
- Hook to
/api/detect-food(proxy server) for AI suggestions. - Predictions shown alongside local dataset matches.
- Always falls back to typed input if offline.
- ⚛️ React + Vite (SPA, no backend).
- 🎨 CSS & SVG animations (lightweight, polished).
- 📦
localStoragefor persistence. - 📊 Lightweight chart lib / canvas for macros & weekly trends.
- 🧩 Modular React components:
Landing.jsx,LoginModal.jsx,Dashboard.jsx,
UploadInput.jsx,SuggestionsModal.jsx,XPBar.jsx,
Charts.jsx,ProfileMenu.jsx,LogList.jsx.
foodLens:user
{
"username": "Alice",
"email": "alice@example.com",
"dailyCalories": 2200,
"totalXP": 0,
"currentLevel": 1,
"badges": [],
"streak": 0,
"lastHealthyDate": null
}
foodLens:logs
[
{
"id": "uuid",
"dish": "Samosa",
"calories": 260,
"protein": 4,
"fat": 15,
"carbs": 30,
"healthScore": 20,
"xp": 10,
"timestamp": "2025-09-27T12:00:00.000Z"
}
]
foodLens:datasetVersion
1git clone https://github.com/your-username/foodlens.git
cd foodlensnpm installnpm run devApp runs at http://localhost:5173 (default Vite port).
- Open app → show animated landing page.
- Click Get Healthy! → login modal → fill info.
- Dashboard loads with user info (XP = 0).
- Type
Samosa→ select → log → XP +10 → animated progress bar. - Upload a salad photo (if AI proxy enabled) → accept suggestion → log.
- Show streak increment or badge unlock.
- Open Profile menu → change daily calories → reload page → persistence shown.
- Show Reset Data action → confirm → logs cleared, XP reset.
src/
├── assets/ # icons, animations, images
├── components/ # modular UI (Landing, LoginModal, XPBar, Charts...)
├── data/foods.json # local nutrition dataset
├── storage.js # localStorage helpers
├── App.jsx # SPA router / view switching
└── main.jsx # React entry
- Not required for core app.
- If enabled: create
/proxyfolder with a small Express server. - Exposes
/api/detect-food→ forwards to AI Vision API (OpenAI/Gemini). - Configure
PROXY_URLin.env.
📖 See proxy/README.md for setup.
- XP milestones: 50, 200, 500.
- Streak badge: 7-day streak of healthy meals.
- Level formula:
floor(totalXP / 100) + 1.
🎉 Micro-animations highlight new XP, badges, and streaks!
- Install Node.js (>= 18).
- Clone repository and install dependencies with
npm install. - Run dev server using
npm run dev. - Access app locally at
http://localhost:5173. - To reset demo: clear
localStoragekeysfoodLens:user,foodLens:logs,foodLens:datasetVersion.
- Landing Page → animated hero screen with CTA.
- Login Modal → collects user info and saves to
localStorage. - Dashboard → core UI with logging, XP, charts, and badges.
- Profile Menu → manage user data, reset, or logout.
- Storage Layer → wrapper functions in
storage.jsfor persistence. - Dataset →
foods.jsonis the primary nutrition data source.
- React + Vite for fast SPA development.
- Tailwind CSS / custom CSS for modern styling.
- Recharts or Canvas API for lightweight charts.
- LocalStorage API for persistence.
- Optional Node/Express proxy for AI/ML integration.
- Offline-first: The app uses a curated
foods.jsonfor 50–80 dishes. - Typed Input Matching: Local fuzzy search finds closest dishes.
- Optional Vision AI: If enabled, a proxy server calls a model (OpenAI/Gemini) to detect dishes from images. Predictions merged into suggestions modal.
- Fallback Logic: If AI confidence is low or offline, fallback to typed dataset suggestions.
- Gamification Metrics: XP derived from
healthScore(0–100) via formulaXP = healthScore ÷ 2.
Built with 🍎 React + Vite
Designed for health, wellness, and fun gamification ✨
- Author 1: Tarunya Ksh [https://github.com/TarunyaProgrammer]
- Author 2: Yatharth Katta
- Author 3: Rakshit Yadav
- Author 4: Payal Phougat