How cartoonwithindian/foodguard-backend works
FoodGuard is a food-product analysis backend: requests can submit barcode, label text, or nutrition data and receive product analysis; separate API branches support product discovery, safety guidance, enrichment, and user features. Sampled routes show direct delegation into analysis, scan, chat, assistant, and enrichment services. Many other capabilities are visible in the repository tree but their runtime wiring was not sampled, so those branches are represented without inferred connections.
Main entry points: label/route.ts Label scan API · analyze/route.ts Analysis API · visual-search.ts Visual product search · web-search-providers.ts Search providers
Components 29
API workflows
- HTTP server
src/server.ts - Label scan API
src/app/api/scan/label/route.ts - Analysis API
src/app/api/analyze/route.ts - Chat API
src/app/api/chat/route.ts - Safety assistant API
src/app/api/food-safety-assistant/route.ts - Enrichment API
src/app/api/enrich-product/route.ts - Visual search APIs
src/app/api/visual-search/route.ts - Request validation
src/schemas/index.ts
Product analysis
- Analysis pipeline
src/services/analysis.service.ts - Health findings
src/lib/health-analysis/findings-engine.ts - Health reference values
src/lib/health-analysis/reference-values.ts - OCR processing
src/lib/ocr.ts - Ingredient parsing
src/lib/ingredients/parse.ts - Nutrition parsing
src/lib/nutrition/parse.ts
Product knowledge
- Barcode lookup
src/lib/product-lookup/index.ts - Visual product search
src/lib/visual-search.ts - Web product enrichment
src/services/web-product-enrichment.ts - Web research
src/services/web-research.service.ts - Search providers
src/lib/external/web-search-providers.ts - Catalog search
src/lib/search/search-service.ts - Product catalog store
src/lib/store/catalog.ts - Product alternatives
src/services/alternative-engine.service.ts - Regulatory analysis
src/services/regulatory/fssai/analyzer.ts
User services
- Chat orchestration
src/services/chat/orchestrator.ts - Conversation service
src/services/chat/conversation.service.ts - Safety assistant
src/services/food-safety-assistant/assistant.ts - Gamification service
src/gamification/services/gamification.service.ts
Other components
- User or client
- External data sources
Connections 17
- User or client → HTTP server: sends requests
src/server.ts - Label scan API → OCR processing: extracts text
src/app/api/scan/label/route.ts - Label scan API → Ingredient parsing: parses ingredients
src/app/api/scan/label/route.ts - Label scan API → Nutrition parsing: parses nutrition
src/app/api/scan/label/route.ts - Label scan API → Barcode lookup: looks up barcode
src/app/api/scan/label/route.ts - Label scan API → Visual product search: searches image
src/app/api/scan/label/route.ts - Analysis API → Request validation: validates input
src/app/api/analyze/route.ts - Analysis API → Analysis pipeline: runs analysis
src/app/api/analyze/route.ts - Analysis API → Gamification service: records scan reward
src/app/api/analyze/route.ts - Health findings → Health reference values: uses thresholds
src/lib/health-analysis/findings-engine.ts - Chat API → Chat orchestration: runs assistant
src/app/api/chat/route.ts - Safety assistant API → Safety assistant: runs assistant
src/app/api/food-safety-assistant/route.ts - Enrichment API → Web product enrichment: enriches product
src/app/api/enrich-product/route.ts - Web research → Search providers: searches and extracts
src/services/web-research.service.ts - Catalog search → Product catalog store: queries catalog
src/lib/search/search-service.ts - Visual search APIs → Visual product search: runs vector search
src/app/api/visual-search/route.ts - External data sources → Search providers: provides results