A web-based application that helps users make informed food choices by providing sustainability and nutrition insights. Scan or search for products to discover their nutritional value and environmental impact.
- Text Search: Enter product name or barcode to search
- Barcode Scanner: Live camera scanning using QuaggaJS
- Auto-fetch: Automatically fetches product data on successful scan
- Product Information: Name, image, brand
- NutriScore: A-E rating for nutritional quality (color-coded)
- EcoScore: A-E rating for environmental impact
- CO₂ Impact: Carbon footprint in g or kg
- Ingredients: Complete ingredients list
- Additives: List of additives detected
- Nutrition Facts: Detailed nutritional table (per 100g)
- Calories
- Proteins
- Carbohydrates
- Fats
- Sugars
- Salt
- Fiber
- Saturated Fat
This project was developed collaboratively by a team of contributors.
-
Vanshika Pahal (Project Lead):
- Project ideation and architecture
- API integration and core feature development
- Deployment and overall coordination
-
Nishi Deo Koshta (Collaborator):
- Reviewed documentation updates
- Provided feedback on feature clarity and usability
-
Other Contributors:
- UI enhancements
- Testing and minor feature improvements
Task distribution, reviews, and coordination were handled through GitHub issues and pull requests to ensure smooth collaboration.
- Built using modern web technologies with a component-based frontend architecture.
- Integrated OpenFoodFacts API to fetch real-time food product and nutrition data.
- Implemented eco-score analysis to help users make sustainable food choices.
- Designed scalable structure to support future features like barcode scanning and gamification
- Deployed on Vercel with environment-based configuration for API access
- Clone the repository
git clone https://github.com/<your-username>/sustainable-food-tracker.git
- Nutrition Chart: Interactive bar chart using Chart.js comparing all nutritional values
- Stores scan/search history in localStorage
- Tracks: name, image, NutriScore, EcoScore, timestamp
- Clickable history items to view products again
- Clear history functionality
- Points System:
- NutriScore A/B + EcoScore A/B → +5 points
- Grade C → +2 points
- Grade D/E → 0 points
- Level System: Every 100 points = 1 level
- Profile Page: Shows total points, level, progress bar, and recent activity
- Home (
index.html): Search and scanner interface - Product (
product.html): Detailed product information - History (
history.html): View scan history - Profile (
profile.html): Eco-points, level, and activity
- HTML5: Structure
- CSS3: Styling with CSS variables, responsive design
- JavaScript (Vanilla): Application logic
- OpenFoodFacts API: Product data source
- Chart.js: Data visualization
- QuaggaJS: Barcode scanning
- FontAwesome: Icons
- localStorage: Data persistence
- A modern web browser (Chrome, Firefox, Safari, Edge)
- Python 3.x (for local server) OR Node.js (alternative)
- Internet connection (for API calls)
# Navigate to project directory
cd Sustainable-Food-Tracker
# Start local server
python -m http.server 8000# Install http-server globally (if not installed)
npm install -g http-server
# Navigate to project directory
cd Sustainable-Food-Tracker
# Start server
http-server -p 8000# Navigate to project directory
cd Sustainable-Food-Tracker
# Start server
npx --yes serve -s . -l 8000Open your browser and navigate to:
http://localhost:8000
Important: The app must be accessed via http://localhost (not file://) for:
- API calls to work (CORS)
- Camera access for barcode scanning
- localStorage to function properly
Sustainable-Food-Tracker/
├── index.html # Home page (search & scanner)
├── product.html # Product details page
├── history.html # History page
├── profile.html # Profile page
├── app.js # Main application logic
├── storage.js # localStorage management
├── scanner.js # Barcode scanner (QuaggaJS)
├── style.css # All styles
├── placeholder.svg # Placeholder image
└── README.md # This file
The following libraries are loaded via CDN:
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>- Purpose: Create nutrition charts
- Version: 4.4.0
- Usage: Bar charts for nutritional values comparison
<script src="https://cdnjs.cloudflare.com/ajax/libs/quagga/0.12.1/quagga.min.js"></script>- Purpose: Barcode scanning from camera
- Version: 0.12.1
- Usage: Live camera scanning for product barcodes
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">- Purpose: Icons throughout the UI
- Version: 6.4.0
- Base URL:
https://world.openfoodfacts.org - Endpoints Used:
- Product by barcode:
/api/v2/product/{barcode} - Product search:
/cgi/search.pl?search_terms={query}&json=1 - Product details:
/api/v0/product/{barcode}.json
- Product by barcode:
The app tries multiple API endpoints for maximum compatibility.
- HTTPS or localhost: Required for camera access
- Camera permissions: Browser will prompt for permission
- Open the app at
http://localhost:8000 - Click "Scan Barcode" button
- Allow camera permissions when prompted
- Point camera at a barcode (EAN-8, EAN-13, UPC, etc.)
- The scanner will automatically detect and navigate to product page
If you don't have physical products, try these test barcodes:
3017620422003- Nutella7622210945078- Oreo3017620429484- Coca Cola5000159461125- Kit Kat
Enter these in the search box or scan if you have the products.
saveToHistory(product): Save product to historygetHistory(): Retrieve scan historyclearHistory(): Clear all historygetEcoPoints(): Get current eco-pointsaddEcoPoints(points): Add pointsgetLevel(): Calculate current levelcalculatePoints(nutriScore, ecoScore): Calculate points based on scores
- Initializes QuaggaJS scanner
- Handles camera access
- Detects barcodes and navigates to product page
- Modal interface for scanning
- Search functionality
- Product fetching from API
- Product display with all details
- History page loading
- Profile page loading
- Chart creation
Color-coded badges for scores:
- A: Green (
--grade-a) - B: Light Green (
--grade-b) - C: Yellow (
--grade-c) - D: Orange (
--grade-d) - E: Red (
--grade-e)
Modern card-based design with:
- Rounded corners
- Soft shadows
- Border styling
- Responsive layout
Fixed bottom navigation bar with:
- Home icon
- History icon
- Profile icon
- Active state indication
- Ensure you're using
http://localhost:8000(notfile://) - Check browser camera permissions
- Try a different browser
- Ensure good lighting for barcode scanning
- Check internet connection
- OpenFoodFacts API might be temporarily down
- Try a different product/barcode
- Check browser console (F12) for detailed errors
- Hard refresh:
Ctrl + F5(Windows) orCmd + Shift + R(Mac) - Clear browser cache
- Check if all CSS files are loading
- Ensure you're using
http://localhost(notfile://) - Check browser settings (some browsers block localStorage in private mode)
- Clear browser data if needed
- ✅ Chrome/Edge (Recommended)
- ✅ Firefox
- ✅ Safari
- ✅ Opera
Note: Camera access requires HTTPS or localhost in all browsers.
- New Page: Create HTML file and add navigation link
- New Function: Add to
app.jsor create new module - New Style: Add to
style.cssusing CSS variables
All colors are defined in :root:
--primary: hsl(158, 64%, 35%);
--primary-light: hsl(158, 64%, 45%);
--primary-dark: hsl(158, 64%, 25%);
--secondary: hsl(158, 30%, 95%);
--accent: hsl(170, 55%, 50%);
/* ... and more */This project is open source and available for educational purposes.
- OpenFoodFacts: Product data API
- Chart.js: Chart library
- QuaggaJS: Barcode scanning library
- FontAwesome: Icons
## 🤝 Contributing
Contributions are welcome!
1. Fork the repository
2. Create a new branch
3. Make your changes
4. Commit and push your changes
5. Open a Pull Request
**Made with ❤️ for sustainable food choices**