NutriScan is an AI-powered smart nutrition scanner built to instantly analyze packaged food items (such as packaged snacks, cereals, canned foods, beverages, chocolates, and packaged grocery items) by scanning their QR codes or 1D/2D barcodes.
With a single camera scan of any packaged food item, NutriScan instantly decodes complex nutrition labels, calculates official NutriScore grades (A to E), flags hidden toxic additives (palm oil, HFCS, sodium), evaluates personalized age-aware health risks, and recommends healthier packaged food swaps.
| Resource | URL | Description |
|---|---|---|
| π Web Application | nutriscan-food.vercel.app | Production Frontend hosted on Vercel |
| βοΈ Backend API | nutriscan-6okf.onrender.com | Live Express.js REST API on Render |
| π Postman API Docs | Postman Collection | Complete API Endpoint Documentation |
| π¨ Figma UI Prototype | View Design | Interactive UI/UX Design System |
| πΊ Demo Video | Watch Video | App Walkthrough & Features Demo |
Clean, modern, and accessible packaged food health analytics dashboard.
NutriScan captures QR codes & 1D/2D barcodes on packaged food items and passes them through a cascading multi-tier database strategy.
flowchart TD
subgraph Step1 ["π· 1. Packaged Food Capture"]
A[Scan Packaged Food QR Code / Barcode via Camera]
B[Manual Numeric Barcode Entry]
C[Packaged Food Search Query]
end
subgraph Step2 ["π 2. Cascading Data Fetching Strategy"]
D{MongoDB Cache Hit?}
E{Local Indian Packaged Snacks JSON Hit?}
F[Query Open Food Facts Global API]
G[Save & Cache to MongoDB Database]
end
subgraph Step3 ["π§ 3. Packaged Food Health Engine"]
H["NutriScore Service (AβE Grade)"]
I["Age-Aware Risk Engine (Child / Adult / Senior)"]
J["Additive Radar (Palm oil, HFCS, E-numbers)"]
K["Healthy Packaged Food Swaps Generator"]
end
subgraph Step4 ["π 4. Interactive Health Dashboard"]
L[Grade Badge & Nutritional Radar]
M[Personalized Health & Risk Alerts]
N[Daily Sugar & Calorie Log Tracker]
O[Healthier Packaged Alternatives]
end
A --> D
B --> D
C --> D
D -- Yes --> H
D -- No --> E
E -- Yes --> H
E -- No --> F
F --> G
G --> H
H --> I
I --> J
J --> K
K --> L
K --> M
K --> N
K --> O
sequenceDiagram
autonumber
actor User
participant Frontend as React Frontend
participant Backend as Express REST API
participant Mongo as MongoDB Cache
participant LocalData as Local Snacks DB
participant OFF as Open Food Facts API
User->>Frontend: Scan Packaged Food QR / Barcode
Frontend->>Backend: GET /api/scan/barcode?barcode=XYZ
Note over Backend,Mongo: Step 1: Check MongoDB Cache
Backend->>Mongo: Query product document by barcode
Mongo-->>Backend: Return cached product document (if HIT)
Note over Backend,LocalData: Step 2: Check Local Database
Backend->>LocalData: Fallback query to indianSnacks.json
LocalData-->>Backend: Return local product document (if HIT)
Note over Backend,OFF: Step 3: Fetch External API
Backend->>OFF: Fetch from Open Food Facts REST API
OFF-->>Backend: Return raw food nutritional data
Backend->>Mongo: Cache fetched product document in MongoDB
Note over Backend: Step 4: Run Health Analysis Engines
Backend->>Backend: Calculate NutriScore (A to E Grade)
Backend->>Backend: Evaluate Age-Aware Health Risk (Child / Adult / Senior)
Backend->>Backend: Scan Ingredients for Toxic Additives & Preservatives
Backend->>Backend: Generate Healthier Packaged Alternatives
Backend-->>Frontend: Return analyzed product JSON payload
Frontend->>User: Display grade, warnings, charts & swaps
- Built with
@zxing/library(BrowserMultiFormatReader). - Uses HTML5 video stream to decode standard 1D barcodes (EAN-13, EAN-8, UPC) and 2D QR codes on packaged food boxes, bags, cans, and bottles in real-time.
- Features a camera overlay with animated scanning lines and manual numeric entry fallback.
- Implements an automated NutriScore calculator based on European dietary standards for packaged food evaluation.
- Evaluates negative points (Energy in kJ, Sugars, Saturated Fats, Sodium per 100g) against positive points (Dietary Fiber, Proteins).
- Outputs clear letter grades (A, B, C, D, E) with color-coded visual indicators.
- Dynamically adjusts nutrient danger thresholds based on user age bracket:
- Child: Stricter sugar (<5gβ10g) and fat limits.
- Adult: Standard daily intake limits.
- Senior: Stricter sodium (<400mg) and saturated fat constraints.
- Generates actionable warnings such as "High diabetes + obesity risk" or "Heart & kidney risk".
- Scans packaged food ingredient lists for artificial preservatives, trans fats, high-fructose corn syrup (HFCS), palm oil, and harmful E-number food additives.
- Automatically searches for higher-rated food alternatives within the same packaged food category, providing healthier choices when grocery shopping.
- Logs scanned packaged products to session history.
- Calculates total sugar, sodium, fat, and calories consumed against WHO/AHA daily recommended limits (e.g., 25g max daily sugar).
- Renders 7-day trend charts powered by Chart.js.
- Framework: React 19, Vite
- Styling & UI: Tailwind CSS, Lucide React icons
- Barcode Scanning:
@zxing/library - Data Visualization:
chart.js,react-chartjs-2
- Runtime: Node.js, Express.js REST API
- Database & ORM: MongoDB, Mongoose
- Fuzzy Search:
Fuse.js(for fast local food search with typo tolerance) - External Integration: Open Food Facts REST API
nutriscan/
βββ frontend/ # React + Vite Frontend Application
β βββ public/ # Static assets & health banner
β β βββ health-banner.jpg
β β βββ image.png
β βββ src/
β β βββ components/ # Modular UI Components
β β β βββ Scanner.jsx # Camera Barcode Scanner component (@zxing/library)
β β β βββ NutritionCard.jsx # Nutrient radar & metric breakdown
β β β βββ NutriScoreBadge.jsx # Grade AβE badge indicator
β β β βββ RiskBadge.jsx # Health risk warning card
β β β βββ Alternatives.jsx # Healthier swap recommendations
β β β βββ DailySugarTracker.jsx # Daily consumption tracker
β β β βββ WeeklySugarChart.jsx # Chart.js weekly sugar graph
β β β βββ ManualEntry.jsx # Manual barcode & search entry
β β β βββ HistoryView.jsx # Past scan history list
β β β βββ ProfilePage.jsx # User profile & age group settings
β β βββ App.jsx # Primary application layout & router
β β βββ main.jsx # React application entry point
β βββ package.json
β
βββ backend/ # Node.js + Express.js REST Backend
β βββ src/
β β βββ config/ # Database connection (MongoDB)
β β βββ controllers/ # Route Request Controllers
β β β βββ scan.controller.js # Barcode scan & search logic
β β β βββ analyse.controller.js # Manual product evaluation
β β β βββ alternatives.controller.js # Healthy swap finder
β β β βββ history.controller.js # User scan logs & summaries
β β βββ services/ # Core Analytical Engines
β β β βββ nutriScore.service.js # Official NutriScore AβE algorithm
β β β βββ risk.service.js # Age-aware health risk evaluation
β β β βββ ingredient.service.js # Additive & warning scanner
β β β βββ alternatives.service.js # Healthier substitute matching
β β β βββ scan.service.js # DB scan persistence & summaries
β β βββ models/ # Mongoose Schemas (Product, Scan, User)
β β βββ data/ # Local Indian snacks fallback database
β β β βββ indianSnacks.json
β β βββ routes/ # Express API Route definitions
β β βββ app.js # Express app setup & middleware
β βββ index.js # Backend server entry point
β βββ package.json
β
βββ README.md # Project documentation
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/scan/barcode?barcode={code} |
Fetch product by barcode (MongoDB -> Local -> OpenFoodFacts) |
GET |
/api/scan/search?q={query} |
Search products by name using OpenFoodFacts + Fuse.js |
POST |
/api/scan/analyse |
Analyze manually entered nutritional values |
GET |
/api/scan/alternatives?category={cat} |
Get healthier product alternatives |
GET |
/api/scan/history?sessionId={id} |
Retrieve recent scan history for user session |
GET |
/api/scan/summary/daily?sessionId={id} |
Get daily accumulated nutrient consumption summary |
GET |
/api/scan/summary/weekly?sessionId={id} |
Get 7-day sugar intake history for charting |
- Node.js (v18+)
- npm or yarn
- MongoDB Atlas database URI or local MongoDB instance
Create a .env file inside the backend/ directory:
PORT=3001
MONGO_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/nutriscan?retryWrites=true&w=majority
JWT_SECRET=your_super_secret_jwt_key
OPEN_FOOD_FACTS_API=https://world.openfoodfacts.org/api/v0cd backend
npm install
npm run dev # Starts server on http://localhost:3001cd frontend
npm install
npm run dev # Starts Vite server on http://localhost:5173To maintain open-source transparency, security, and community governance, NutriScan includes standard repository documentation:
| Document | Description | Link |
|---|---|---|
| π License | MIT Open Source License | LICENSE |
| π Code of Conduct | Community pledge and standards (Contributor Covenant v2.1) | CODE_OF_CONDUCT.md |
| π‘οΈ Security Policy | Vulnerability reporting procedure & security practices | SECURITY.md |
We treat security and user privacy as top priorities. If you discover a vulnerability or security issue, please review our Security Policy to report it responsibly.
Distributed under the MIT License. See LICENSE for more information.
Developed with β€οΈ for a healthier lifestyle by Harshit Kumar.
