IntelliFoods: Smart Recipe Recommendations and Ingredient Substitutions

Inspiration

The idea for IntelliFoods was born from a common kitchen frustration I experienced. Standing in front of a half-stocked pantry, wondering what meals I could create without another grocery run, I often found ingredients going bad before I could use them effectively. This personal challenge resonated with a larger global issue – approximately one-third of all food produced globally goes to waste.

The realization that many others likely face this same dilemma inspired me to create a solution that would not only help people make better use of their available ingredients but also contribute to reducing food waste on a broader scale.

What it does

IntelliFoods is an AI-powered kitchen companion that offers two key functionalities:

  1. Smart Recipe Recommendations: Analyzes your available ingredients and suggests possible recipes you can make right now
  2. Intelligent Substitutions: When you're missing an ingredient, it recommends suitable substitutions based on what you have, making recipes more accessible

The system takes into account ingredient expiry dates, helping users prioritize ingredients that need to be used soon, thereby reducing food waste.

How we built it

Our team of two divided the project into frontend and backend components:

Backend (RAG System & API):

  • Knowledge Base Creation & Data Pipeline:

    • Ingested TheMealDB data into S3 Bucket with structured processing
    • Enhanced recipe data with metadata tagging: json { "recipe_id": "52772", "name": "Teriyaki Chicken Casserole", "metadata": { "category": "Chicken", "cuisine": "Japanese", "main_ingredients": ["chicken", "soy sauce", "rice"] } }
    • Implemented MongoDB Atlas Vector Search for efficient similarity matching
    • Created custom vector index for optimized recipe search
  • RAG System Architecture:

    • Leveraged Amazon Bedrock for knowledge base management
    • Integrated AI21-Jamba-1.5-Mini LLM through LangChain for:
    • Recipe generation and analysis
    • Ingredient substitution recommendations
    • Cooking instructions enhancement
    • Implemented custom prompt templates for consistent output
    • Created vector similarity search with cosine similarity scoring
  • RAG System Implementation:

    class BaseRecipeRecommender:
      def __init__(self, knowledge_base_id: str, model_id: str):
          self.retriever = AmazonKnowledgeBasesRetriever(
              knowledge_base_id=knowledge_base_id,
              retrieval_config={"vectorSearchConfiguration": {"numberOfResults": 10}}
          )
          self.llm = ChatBedrockConverse(
              model_id=model_id,
              temperature=0.7,
              max_tokens=2048
          )
    
    • Built with AI21-Jamba-1.5-Mini LLM through LangChain
    • Implemented ingredient matching and substitution logic
    • Created custom scoring system for recipe relevance
  • API Development:

    • FastAPI endpoints for recipe recommendations:
    @app.post("/recommend")
    async def recommend_recipes(request: BaseIngredientsRequest):
        result = await recommender.recommend_recipes(request)
        return result
    
    @app.post("/substitute")
    async def get_recipe_with_substitutions(request: BaseIngredientsRequest):
        result = await recommender.recommend_recipes(request, include_substitutes=True)
        return result
    
  • Infrastructure as Code:

    • Used AWS CDK for infrastructure deployment: typescript const apiFunction = new lambda.DockerImageFunction(this, "ApiFunc", { code: lambda.DockerImageCode.fromImageAsset("../image"), memorySize: 1028, timeout: cdk.Duration.seconds(360), architecture: lambda.Architecture.ARM_64, });
    • Configured Lambda with:
    • 1GB memory allocation
    • 6-minute timeout for complex queries
    • ARM64 architecture for cost optimization
    • Public URL with CORS support
    • Bedrock full access permissions
  • Tech Stack Integration:

    • Amazon Bedrock: Core LLM & knowledge base
    • MongoDB Atlas: Vector search & data storage
    • LangChain: RAG framework & chain management
    • FastAPI + Lambda: Serverless API
    • Docker: Containerization
    • AWS CDK: Infrastructure

Frontend:

  • Built with Next.js
  • Deployed on Vercel
  • MongoDB integration for user data
  • Responsive UI for recipe display and ingredient input

Challenges we ran into

  1. AWS Service Limitations:

    • Had zero quota for Claude in AWS account
    • Adapted by using AI21-Jamha-1.5-Mini as alternative LLM
    • Couldn't use Bedrock agent due to LLM compatibility
  2. Performance Issues:

    • Long response times for substitution recommendations
    • API timeout challenges
    • Temporary solution with extended Lambda timeouts
  3. Technical Learning Curve:

    • First experience with RAG systems
    • New to AWS Lambda deployment
    • Integration complexities between services

Accomplishments that we're proud of

  1. Successfully built a functional RAG system that effectively recommends recipes
  2. Implemented intelligent ingredient substitution logic
  3. Created a seamless integration between MongoDB Atlas Vector Search and Bedrock
  4. Deployed a production-ready serverless API
  5. Developed a user-friendly interface that makes complex technology accessible
  6. Created a solution that actively contributes to reducing food waste

What we learned

  • Hands-on experience with RAG system architecture
  • AWS ecosystem and serverless deployment
  • MongoDB Atlas Vector Search capabilities
  • LangChain integration techniques
  • FastAPI development and containerization
  • Team collaboration in a full-stack project
  • Balancing technical capabilities with user needs

What's next for IntelliFoods

  1. Technical Enhancements:

    • Async processing implementation
    • Response time optimization
    • Enhanced recipe matching
    • Database expansion
  2. New Features:

    • Meal planning
    • Dietary restrictions
    • Shopping list generation
    • Community sharing
  3. Platform Evolution:

    • Mobile app development
    • Smart device integration
    • Sustainability tracking
    • Personalization

Our goal is to continue evolving IntelliFoods into a comprehensive kitchen management solution that makes cooking more accessible while promoting sustainable food practices.

Built With

Share this project:

Updates