How arun7148/indian-food-rating works
NutriScore IN lets consumers search for or scan packaged foods, then view an A–E rating, nutrient details, ingredient red flags, and (for low grades) alternatives. The main screen coordinates lookup and display; the food service normalizes Open Food Facts data and falls back to local products, while scoring and red-flag rules enrich results. Users can also submit missing products for local scoring and storage. The sampled sources establish these main calls; the product API route’s behavior was not shown, so it is omitted.
Main entry points: page.tsx Main screen · foodService.ts Food lookup service · contributions.ts Contribution handling · SearchBar.tsx Search bar
Components 19
Consumer experience
- Main screen
src/app/page.tsx - Search bar
src/components/SearchBar.tsx - Query debounce
src/hooks/useDebounce.ts - Barcode scanner
src/components/BarcodeScanner.tsx - Product summary
src/components/ProductCard.tsx - Grade badge
src/components/ScoreBadge.tsx - Nutrient details
src/components/NutrientBreakdown.tsx - Better alternatives
src/components/AlternativesSection.tsx - State views
src/components/StateViews.tsx
Product data
- Food lookup service
src/lib/foodService.ts - Open Food Facts
- Indian mock dataset
src/lib/mockData.ts
Nutrition analysis
- Nutri-Score engine
src/lib/calculateNutriScore.ts - Ingredient red flags
src/lib/redFlags.ts
Community contributions
- Product submission form
src/components/ContributeProductModal.tsx - Contribution handling
src/lib/contributions.ts - Browser storage
- Contribution API
src/app/api/contribute/route.ts
Other components
- Consumer
Connections 23
- Consumer → Search bar: enters query
src/components/SearchBar.tsx - Consumer → Barcode scanner: scans barcode
README.md - Search bar → Query debounce: debounces input
src/components/SearchBar.tsx - Search bar → Food lookup service: searches products
src/components/SearchBar.tsx - Barcode scanner → Main screen: reports barcode
src/app/page.tsx - Search bar → Main screen: selects product
src/app/page.tsx - Main screen → Food lookup service: loads products
src/app/page.tsx - Main screen → Product summary: renders result
src/app/page.tsx - Main screen → Nutrient details: renders nutrients
src/app/page.tsx - Main screen → Better alternatives: renders alternatives
src/app/page.tsx - Main screen → State views: renders states
src/app/page.tsx - Product summary → Grade badge: renders grade
src/components/ProductCard.tsx - Food lookup service → Open Food Facts: fetches product data
README.md - Food lookup service → Indian mock dataset: falls back to
src/lib/foodService.ts - Food lookup service → Nutri-Score engine: calculates grade
src/lib/foodService.ts - Food lookup service → Ingredient red flags: detects flags
src/lib/foodService.ts - Main screen → Food lookup service: gets alternatives
src/app/page.tsx - Consumer → Product submission form: submits product
src/components/ContributeProductModal.tsx - Product submission form → Contribution handling: previews and saves
src/components/ContributeProductModal.tsx - Contribution handling → Nutri-Score engine: scores contribution
src/lib/contributions.ts - Contribution handling → Ingredient red flags: checks ingredients
src/lib/contributions.ts - Contribution handling → Browser storage: reads and writes
src/lib/contributions.ts - Contribution handling → Contribution API: posts submission
src/lib/contributions.ts