An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          


Food Image

# ๐Ÿฅ— 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 |
|----------------------|-------------------------|--------------|
| Screen 1 | Screen 3 | Screen 2|

---

## ๐Ÿงฉ 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!)