https://github.com/paramsinghvc/nutrilens
A web app to take real time pictures and get nutrition analysis and health suggestions through OpenAI
https://github.com/paramsinghvc/nutrilens
Last synced: 2 months ago
JSON representation
A web app to take real time pictures and get nutrition analysis and health suggestions through OpenAI
- Host: GitHub
- URL: https://github.com/paramsinghvc/nutrilens
- Owner: paramsinghvc
- License: mit
- Created: 2025-12-02T13:49:33.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-12-08T15:47:10.000Z (8 months ago)
- Last Synced: 2025-12-28T22:11:22.469Z (7 months ago)
- Language: TypeScript
- Homepage: https://nutrilens-jet.vercel.app
- Size: 188 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฅ NutriLens โ AI-Powered Nutrition Analysis App
NutriLens is an intelligent nutrition analysis platform that uses **OpenAI Vision** to analyze food images and provide instant, structured insights about **macros, micronutrients, health notes, and practical suggestions** โ all with a friendly mobile-native interface.
Built with **Next.js 15**, **Express.js**, and **OpenAI GPT-4.1 Vision**, NutriLens brings **AI nutrition analysis** directly to your browser.
---
## โจ Features
- ๐ง **AI-powered Food Recognition** โ Upload a meal photo and let OpenAI identify each ingredient.
- โ๏ธ **Instant Macro Breakdown** โ Get estimated calories, protein, carbs, fats, and fiber.
- ๐งฌ **Micronutrient Insights** โ Vitamins & minerals classified as *Low / Moderate / High*, color-coded for clarity.
- ๐ก **Personalized Health Notes** โ Friendly, emoji-led insights about your meal.
- ๐ฑ **Smarter Meal Suggestions** โ AI-generated quick tips for balance and healthier eating.
- ๐ฑ **Mobile-first UI** โ A clean, interactive, draggable bottom sheet that feels native.
- โ๏ธ **Docker-ready** โ Easily run both frontend and backend in isolated containers.
---
## ๐ธ Preview
| Live Food scanning | AI Nutrient Insights | Health Tips |
|----------------------|-------------------------|--------------|
|
|
|
|
---
## ๐งฉ Project Structure
```
nutrilens/
โโโ app/ # Next.js 16.0.7 frontend (React 19)
โ โโโ components/ # UI components (Donut charts, BottomSheet, etc.)
โ โโโ public/
โ โโโ ...
โโโ server/ # Express.js backend
โ โโโ src/
โ โโโ package.json
โ โโโ .env.example
โโโ docker-compose.yml # Combined app/server config
โโโ README.md
```
---
## โ๏ธ Getting Started
### ๐ง 1. Setup OpenAI API Key
Youโll need an [OpenAI API key](https://platform.openai.com/api-keys).
Create one and add it to your backend `.env` file.
---
### ๐งฐ 2. Start the Express Server
Set environment variables in `server/.env` (based on `.env.example`):
```
OPENAI_API_KEY=sk-xxxxxx
PORT=8083
```
Then start the server:
```bash
npm run docker:server
# or
cd server && yarn dev
```
Server runs at ๐ [http://localhost:8083](http://localhost:8083)
---
### ๐ป 3. Start the Next.js Frontend
Set environment variables in `.env` (based on `.env.example`):
```
NEXT_PUBLIC_API_BASE=http://localhost:8083
PORT=3000
```
Then run the dev server:
```bash
npm run dev
# or
yarn dev
```
Visit ๐ [http://localhost:3000](http://localhost:3000)
---
## ๐ณ Docker Setup (Optional)
You can run everything in Docker with one command:
```bash
docker compose up --build
```
This will spin up:
- `frontend` โ Next.js app (port 8087)
- `backend` โ Express + OpenAI API (port 8083)
---
## ๐ง How It Works
1. User uploads a meal photo.
2. The backend sends the image to **OpenAI GPT-5.1 Vision** via the `responses.create()` API.
3. AI analyzes the meal composition, estimates portions, and outputs structured JSON (validated via **Zod**).
4. Frontend visualizes the data as colorful donut charts and categorized nutrient lists.
---
## ๐ช Tech Stack
| Layer | Technology |
|-------|-------------|
| Frontend | Next.js 16.0.7 (React 19) + TypeScript + Tailwind CSS |
| Backend | Express.js + OpenAI API (GPT-4.1 Vision) |
| Validation | Zod Schema + `zodTextFormat()` |
| Charts | Custom SVG Donut & MultiDonut Components |
| Containerization | Docker & Docker Compose |
| Deployment | Vercel + Nginx Reverse Proxy |
---
## ๐ Deployment
### Deploy the frontend on [Vercel](https://vercel.com)
- Set `NEXT_PUBLIC_API_BASE` to your live API URL.
### Deploy the backend (server)
- On a VPS or platform like DigitalOcean or Render.
- Configure Nginx reverse proxy (e.g. `nutrilens.mollyculelabs.com` โ `localhost:8083`).
- Use `pm2` or Docker for process management.
---
## ๐ Environment Variables
| Variable | Description |
|-----------|--------------|
| `OPENAI_API_KEY` | Your OpenAI API key |
| `PORT` | Express server port |
| `NEXT_PUBLIC_API_BASE` | Base URL for API calls |
| `NODE_ENV` | `development` or `production` |
---
## ๐ง Example AI Output
```json
{
"error": null,
"identifiedFoodItems": ["Paneer Curry", "Rice", "Cucumber Salad"],
"estimatedPortionSize": [
{ "itemName": "Paneer Curry", "itemSize": "200g" },
{ "itemName": "Rice", "itemSize": "150g" }
],
"macros": {
"calories": 520,
"protein": 28,
"carbs": 45,
"fats": 20,
"fiber": 6
},
"micronutrients": {
"Vitamin A": { "category": "Moderate", "note": "Supports vision", "amount": "480ยตg" },
"Iron": { "category": "Low", "note": "Helps oxygen flow", "amount": "1.2mg" }
},
"health_notes": ["๐ช High in protein for muscle recovery."],
"healthier_suggestions": ["๐ฅ Add more greens for micronutrient balance."]
}
```
---
## ๐งโ๐ป Author
**Param Singh**
Full-stack engineer & digital creator
๐ [mollyculelabs.com](https://mollyculelabs.com)
๐ฆ [@paramsinghvc](https://twitter.com/paramsinghvc)
๐ผ [GitHub](https://github.com/paramsinghvc)
---
## โญ๏ธ Show Your Support
If you like this project:
- ๐ Star the repo on [GitHub](https://github.com/paramsinghvc/nutrilens)
- ๐งฉ Open issues or ideas for new features
- โ Buy me a coffee (optional!)