Skip to content

feat: enhance recipe generation with complete user preferences - #40

Open
jeremyLabrado wants to merge 18 commits into
aws-samples:mainfrom
jeremyLabrado:feature/enhanced-recipe-preferences
Open

jeremyLabrado wants to merge 18 commits into
aws-samples:mainfrom
jeremyLabrado:feature/enhanced-recipe-preferences

Conversation

@jeremyLabrado

Copy link
Copy Markdown
Contributor

Summary

Enhances recipe generation to respect all 6 user preference types from the preferences page.

Changes

  • ✅ Backend: Add support for health goals, religious requirements, disliked ingredients, and favorite cuisines
  • ✅ Frontend: Migrate from legacy localStorage to unified userPreferences object
  • ✅ Improved prompt engineering with explicit constraints for each preference type

Recipe Generation Now Respects:

  1. Allergies (existing)
  2. Dietary preferences - vegan, keto, etc. (existing)
  3. Health goals - weight loss, muscle gain, etc. (new)
  4. Religious requirements - halal, kosher, hindu (new)
  5. Disliked ingredients - cilantro, mushrooms, etc. (new)
  6. Favorite cuisines - Italian, Asian, etc. (new)

Testing

  • ✅ Deployed and tested on CloudFront
  • ✅ All 6 preference types properly sent to Lambda
  • ✅ LLM generates recipes respecting all constraints

Files Changed

  • lambda/recipe_proposals/index.py (+42, -11)
  • resources/ui/src/pages/components/recipe_proposals.tsx (+16, -6)

Fixes: Recipe generation not respecting all user preferences from settings page

- Add support for all 6 user preference types in recipe generation
- Include health goals (weight loss, muscle gain, maintain, general)
- Include religious requirements (halal, kosher, hindu)
- Include disliked ingredients filtering
- Include favorite cuisines preferences
- Improve prompt engineering with explicit constraints
- Update frontend to send unified userPreferences object
- Migrate from legacy localStorage format to new unified format

This ensures recipe proposals are truly personalized based on:
1. Allergies (existing)
2. Dietary preferences (existing)
3. Health goals (new)
4. Religious requirements (new)
5. Disliked ingredients (new)
6. Favorite cuisines (new)

Fixes: Recipe generation not respecting all user preferences from settings page
- Add 3 fridge test images (fridge1.jpeg, fridge2.jpeg, fridge3.jpeg)
- Add 'Load Test Images' button in dev mode
- Deploy test images to S3 imgBucket via CDK
- Enable one-click testing without camera/file upload

Benefits:
- Faster testing and demos
- No need for physical products or camera
- Consistent test data for development
- Available only in dev mode to avoid confusion
- Update hero section for B2B2C grocery positioning
- Change title: 'Shop Smarter with AI' (retail-focused)
- Update subtitle: Emphasize cart integration and food waste reduction
- New color scheme: Fresh green gradient (grocery/produce theme)
- Update fridge titles for retail appeal:
  - Fresh & Healthy (health-conscious shoppers)
  - Meal Prep Ready (convenience-focused)
  - Family Favorites (family meal planning)
- Remove repetitive CTAs from cards
- Fix title rendering issues (solid color instead of gradient)
- Update README with complete 6-preference system documentation
- Add demo mode section for trade shows and retail environments

Target market: Leclerc, Carrefour, Walmart, Trader Joe's
Value proposition: Increase basket size + reduce food waste
- Add Recipe Context form with 4 filters on /recipe page
- Time: 15/30/45/60/90+ minutes
- People: 1/2/4/6/8+ servings
- Equipment: All/Stovetop/Oven/Microwave/No cooking
- Budget per person: $5/$10/$15/$20/$30+
- Context saved to localStorage and persists across sessions
- Passed to Lambda for recipe generation constraints
- LLM respects all context parameters in recipe suggestions

Benefits:
- Faster recipe filtering (no unsuitable recipes)
- Better personalization (time, budget, equipment constraints)
- Improved grocery retail value (budget-conscious shopping)
- Add shopping cart with localStorage persistence
- Add favorites page to save and reorder recipes
- Add cart icon to top navigation with live count
- Add ingredient-to-barcode mapping (54 validated items)
- Add Product Info links in cart to barcode scanner
- Auto-fetch product details when navigating from cart
- Unified design system (green gradient across all pages)
- Compact home page for mobile (favorites/cart visible)
- Add animated loading screens for better UX
- Improve recipe display with featured/alternative layout
- Add structured ingredients and instructions sections

Shopping cart features:
- Add ALL ingredients (not just missing)
- Mock pricing with consistent hash-based prices
- Group items by recipe
- Calculate subtotal, tax, total
- Simple checkout flow (clears cart)

Favorites features:
- Save recipes with star button
- View all saved recipes
- Add to cart from favorites
- Expandable recipe details
- Remove from favorites

Product linking:
- 54 ingredients mapped to Open Food Facts barcodes
- Validated against API
- Seamless navigation from cart to product details
- Auto-fetch on barcode page
- Restore enhanced recipe card layout
- Add featured recipe with RECOMMENDED badge
- Add 'Add All Ingredients to Cart' button
- Add star button to save favorites on all 3 recipes
- Add compact alternative recipe cards
- Add animated loading screen with 3 steps
- Add structured ingredients section (checkmarks)
- Add structured instructions section
- Mobile-optimized layout

Recipe features:
- Featured recipe: Large image, stats, ingredients, 3 action buttons
- Alternative recipes: Compact horizontal layout with thumbnail
- All recipes can be saved to favorites
- All recipes can add ingredients to cart
- Step-by-step expandable for all recipes
Emotional Payoff (Cart Success Modal):
- Replace generic alert with celebratory modal
- Show recipe preview image
- Display success metrics with green checkmarks
- Show item count, total cost, budget comparison
- Highlight quick meal if under 30 min
- Actions: View Cart or Keep Shopping
- Positive reinforcement for shopper commitment

Leftover Suggestions (Post-Cooking):
- Modal appears after marking recipe complete
- Rating system (1-5 stars)
- Save to favorites option
- Suggests complementary recipe using leftovers
- Shows leftover amount estimate
- Lists new ingredients needed with prices
- Emphasizes cost savings ($0 for leftovers)
- Actions: Add to Cart, Save for Later, Dismiss
- Demonstrates waste reduction intelligence

Benefits:
- Reduces food waste (uses leftovers)
- Increases basket size (complementary items)
- Builds loyalty (long-term meal planning)
- Positive emotional response (celebration)
- Clear next steps (reduces friction)
Checkout Success Screen:
- Replace generic alert with celebratory modal
- Show order confirmation with random order number
- Display delivery details (time, location)
- Show order summary (total, item count)
- Add cooking reminder notification (6:15 PM)
- Actions: View Recipe or Go Home
- Cart clears after dismissing modal
- Professional e-commerce feel

Button Rename:
- 'Step-by-Step Guide' → 'Start Cooking'
- More action-oriented and engaging
- Better aligns with grocery/cooking context

Benefits:
- Provides closure to shopping experience
- Sets delivery expectations
- Proactive cooking reminder
- Professional, complete transaction feel
- Reduces anxiety with clear next steps
Ingredient Detection Improvements:
- Replace removable chips with categorized text display
- Add positive header: 'Found in your fridge (X items)'
- Auto-categorize ingredients by type:
  * 🥦 Vegetables (15+ items)
  * 🥩 Proteins (11+ items)
  * 🥛 Dairy (5 items)
  * 🍎 Fruits (8+ items)
  * 🌾 Other (grains, condiments, etc.)
- Remove negative 'correction' framing
- Add clear CTA: 'Generate Recipes' button
- Clean, scannable layout

Benefits:
- Positive validation (not error correction)
- Easy to scan by category
- Confirms AI understanding
- Professional, organized display
- Reduces user anxiety
Journey Progress Tracker:
- Visual breadcrumb showing user's position in shopping flow
- 4 steps: Photo → Recipe → Cart → Checkout
- Shows completed steps with green checkmarks
- Highlights current step in green
- Grays out future steps
- Progress bars between completed steps
- Icons for each step (📸 👨‍🍳 🛒 ✅)

Appears on:
- Recipe page (after ingredients detected)
- Cart page (when viewing cart)

Benefits:
- Clear orientation (where am I?)
- Shows next step (what's next?)
- Sense of progress and accomplishment
- Reduces user uncertainty
- Hand-holding through shopping journey
- Professional e-commerce feel

@Flolight Flolight left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Jeremy Labrado added 8 commits February 15, 2026 21:03
…Summit 2026

Major improvements:
- Add ingredient detection caching (96% faster for demo fridges)
- Add recipe generation caching (97% faster)
- Fix leftover modal UX (stays open after actions)
- Add cart navigation after 'Add to Cart'
- Fix 'Product Info' button with partial barcode matching
- Remove unnecessary 'Generate Recipes' button
- Add mobile-friendly header icons
- Update documentation for grocery retailer showcase
- Add demo GIF and screenshots
- Add ARCHITECTURE.md, CUSTOMER_JOURNEY.md, CACHING_IMPLEMENTATION.md, PRODUCTION_READINESS.md

Performance: 26s → 1s for cached requests
Cost savings: 99.998% on cache hits
Ready for AWS Summit 2026 demos
- Enable CloudFront caching for static assets (50% fewer Lambda calls)
- Add DynamoDB TTL (30 days) for automatic cache cleanup
- Enable Cognito MFA (optional for demos, can be required for production)
- Add CloudTrail for audit logging and compliance
- Add cost allocation tags for expense tracking
- Create operational runbooks (10 incident response procedures)
- Add deployment validation script

Note: Lambda memory (10GB) and timeout (5min) kept high intentionally
for AWS Summit 2026 demo reliability. Cost optimization can be applied
post-Summit for production deployments.

Well-Architected Score: 8.5/10 → 8.7/10
- Consolidate from 2 models (Claude 3 Sonnet + Claude 3 Haiku) to 1 model (Claude Haiku 4.5)
- Update all 6 Lambda functions to use Claude Haiku 4.5
- Update documentation to reflect model change
- Benefits: 70-75% cost reduction on Bedrock, simpler operations, single model to monitor

Model changes:
- barcode_ingredients: Claude 3 Sonnet → Claude Haiku 4.5
- barcode_product_summary: Claude 3 Haiku → Claude Haiku 4.5
- barcode_image: Claude 3 Sonnet → Claude Haiku 4.5
- recipe_image_ingredients: Claude 3 Sonnet → Claude Haiku 4.5 (vision)
- recipe_proposals: Claude 3 Sonnet → Claude Haiku 4.5
- recipe_step_by_step: Claude 3 Haiku → Claude Haiku 4.5

Tested and verified working with manual tests.
- Add docs/ directory with index.md
- Add AWS_SUMMIT_DEMO_TICKET.md for Summit submission
- Update README.md with links to documentation

Note: Full technical docs can be regenerated if needed
- Add docs/codebase_info.md (project overview)
- Add docs/architecture.md (system design)
- Add docs/components.md (component analysis)
- Add docs/interfaces.md (API specifications)
- Add docs/data_models.md (data structures)
- Add docs/workflows.md (process flows)
- Add docs/dependencies.md (external dependencies)

All docs reflect latest changes:
- Claude Haiku 4.5 for all text generation
- CloudFront caching enabled
- DynamoDB TTL enabled
- 5 tables, 7 Lambda functions
- Link to docs/ for technical details
- Link to root operational docs
- Clear separation between technical and operational docs
- Remove duplicate ARCHITECTURE.md from root
- Keep docs/architecture.md as single source
- Move WELL_ARCHITECTED_REVIEW.md to docs/
- Update README.md links to reflect correct locations

Final structure:
- Root: README.md, RUNBOOKS.md, AWS_SUMMIT_DEMO_TICKET.md
- docs/: All technical and operational documentation (9 files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants