Helping busy urban shoppers make better grocery decisions with minimum changes and maximum nutritional impact.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend β
β (Vite + Tailwind v4 Β· Firebase Auth Β· Firebase Hosting) β
β β
β ββββββββββββ ββββββββββββ ββββββββββ ββββββββββββββββ β
β βOnboardingβ βCart Inputβ βResults β βImpact Charts β β
β ββββββββββββ ββββββββββββ ββββββββββ ββββββββββββββββ β
β β β
β Data Access Layer (DAL) β
β (No raw Firestore SDK in components) β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β HTTP
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Orchestrator (Cloud Run :8080) β
β Fans out to agents, collects results β
β β
β ββββββββββββ ββββββββββββ ββββββββββ ββββββββββββ β
β βCart Parseβ βBehavior β βContext β βOptimize β β
β β :8081 β β :8082 β β :8083 β β :8084 β β
β βββββββ¬βββββ ββββββ¬ββββββ βββββ¬βββββ ββββββ¬ββββββ β
β β β β β β
β Open Food Firestore Time/Season Constraint β
β Facts API History Signals Solver β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββ
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ βββββββββββββ
βFirestore β βCloud β βVertex AI β
β(profiles,β βVision APIβ β(Gemini) β
βhistory, β β(OCR) β β(optional) β
βfeedback) β β β β β
ββββββββββββ ββββββββββββ βββββββββββββ
| Agent | Port | Role |
|---|---|---|
| Cart Parser | 8081 | Classifies items, looks up nutrition via bundled DB + Open Food Facts API |
| Behavior Analysis | 8082 | Reads Firestore purchase history, detects snack dependency, protein deficit |
| Context Engine | 8083 | Injects day/time, season, lifestyle, cooking willingness signals |
| Optimization | 8084 | Constraint solver: produces 3-5 swaps prioritizing protein gap closure |
| Orchestrator | 8080 | Fans out to all agents via HTTP, aggregates results for frontend |
challenge/
βββ frontend/ # React + Vite + Tailwind v4
β βββ src/
β β βββ agents/ # Local agent implementations (browser fallback)
β β β βββ cartParser.js
β β β βββ behaviorAgent.js
β β β βββ contextEngine.js
β β β βββ optimizationAgent.js
β β βββ components/ # Reusable UI components
β β β βββ CartInput.jsx # Text + image upload input
β β β βββ CartSummary.jsx # Nutrition stats + item tags
β β β βββ InsightCard.jsx # Behavior + context insight
β β β βββ SuggestionCard.jsx # ADD/REPLACE/REMOVE cards
β β β βββ ImpactChart.jsx # Before vs After comparison
β β β βββ Navbar.jsx
β β βββ pages/
β β β βββ Landing.jsx # Auth + demo mode
β β β βββ Onboarding.jsx # 3-screen onboarding
β β β βββ Dashboard.jsx # Main analysis view
β β βββ context/ # React context providers
β β βββ services/ # Firebase config, DAL, API client
β β βββ data/ # Bundled grocery dataset (100+ items)
β βββ index.html
β βββ vite.config.js
β βββ package.json
βββ backend/
β βββ orchestrator/ # Fan-out orchestrator
β β βββ index.js
β β βββ package.json
β β βββ Dockerfile
β βββ cart-parser/ # Cart Parser Agent
β β βββ index.js
β β βββ groceryDB.json
β β βββ package.json
β β βββ Dockerfile
β βββ behavior-agent/ # Behavior Analysis Agent
β β βββ index.js
β β βββ package.json
β β βββ Dockerfile
β βββ context-engine/ # Context Engine Agent
β β βββ index.js
β β βββ package.json
β β βββ Dockerfile
β βββ optimization/ # Optimization Agent
β βββ index.js
β βββ package.json
β βββ Dockerfile
βββ .gitignore
βββ README.md
- Node.js 20+
- npm 9+
cd frontend
npm install
npm run dev
# β http://localhost:5173The frontend includes local agent implementations that run entirely in the browser, so it works without the backend services. Click "Try Demo" on the landing page to skip Firebase Auth.
# Install deps for each service
cd backend/orchestrator && npm install
cd ../cart-parser && npm install
cd ../behavior-agent && npm install
cd ../context-engine && npm install
cd ../optimization && npm install
# Run all services (use separate terminals)
cd backend/orchestrator && npm run dev # :8080
cd backend/cart-parser && npm run dev # :8081
cd backend/behavior-agent && npm run dev # :8082
cd backend/context-engine && npm run dev # :8083
cd backend/optimization && npm run dev # :8084- Create a Firebase project at console.firebase.google.com
- Enable Authentication β Google Sign-In provider
- Enable Cloud Firestore (start in test mode)
- Create a
.envfile infrontend/:
VITE_FIREBASE_API_KEY=your-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_ID=000000000
VITE_FIREBASE_APP_ID=1:000:web:000We've included a cloudbuild.yaml file that automatically builds and pushes all 5 microservice containers at once.
# 1. Set your project
export PROJECT_ID=your-gcp-project
gcloud config set project $PROJECT_ID
# 2. Submit the build to Cloud Build (builds all 5 images)
gcloud builds submit --config cloudbuild.yaml .
# 3. Deploy each service to Cloud Run
for service in orchestrator cart-parser behavior-agent context-engine optimization; do
gcloud run deploy cartiq-$service \
--image gcr.io/$PROJECT_ID/cartiq-$service \
--platform managed \
--region us-central1 \
--allow-unauthenticated
doneThen update the orchestrator's environment variables with each service URL:
gcloud run services update cartiq-orchestrator \
--set-env-vars "CART_PARSER_URL=https://cartiq-cart-parser-xxx.run.app,BEHAVIOR_URL=https://cartiq-behavior-agent-xxx.run.app,CONTEXT_URL=https://cartiq-context-engine-xxx.run.app,OPTIMIZATION_URL=https://cartiq-optimization-xxx.run.app"cd frontend
npm run build
firebase init hosting # select your project, set public dir to "dist"
firebase deploy --only hosting- Enable the Cloud Vision API in your GCP project
- The orchestrator service handles OCR via
@google-cloud/vision - Cloud Run services automatically authenticate via service account
Input: Maggi, chips, biscuits, white bread, butter, cola, eggs, banana
Output:
- Cart is 62% processed food, protein deficit detected
- 3-5 suggestions:
- π REPLACE butter β peanut butter β Spread swap, +14g protein/week
- π REPLACE chips β roasted nuts β Same crunch, +18g protein/week
- π REPLACE Maggi β oats β Same 5-min prep, +9g protein/week
- β REMOVE cola β Zero nutrition, save βΉ40/week
- π REPLACE biscuits β dates β Natural sweetness, no refined sugar
- Before: 12% protein, 62% junk
- After: 31% protein, 10% junk
- Effort: unchanged
| Service | Purpose |
|---|---|
| Firestore | User profiles, purchase history, feedback, "never suggest" lists |
| Cloud Run | Hosts all 5 agent APIs as serverless microservices |
| Cloud Vision API | OCR for offline bill/receipt scanning |
| Vertex AI (Gemini) | Optional: natural language reasoning for swap explanations |
| Firebase Hosting | Deploys the React frontend |
| Firebase Auth | Google Sign-In for user authentication |
- Bundled Dataset β 100+ common Indian grocery items with full macros (protein, carbs, fat, calories)
- Open Food Facts API β Fallback lookup for items not in the local dataset
- Mock Purchase History β Simulated data for first-time/demo users
- β Each agent is a separate Cloud Run service with clean REST API
- β Agents communicate via HTTP (decoupled, independently deployable)
- β Frontend calls an orchestrator that fans out to agents
- β
All Firestore operations go through a Data Access Layer (
services/dataLayer.js) - β No raw Firebase SDK calls in UI components
- β Dockerfiles included for every backend service
- β Local agent fallbacks for offline/demo operation