Skip to content

sidhu1512/recipe-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Recipe Assistant

An intelligent backend service that generates creative recipes from a list of ingredients using a powerful generative AI. This project leverages the Grok AI API to provide users with a simple and effective way to discover new meals and reduce food waste.


✨ Key Features

  • Dynamic Recipe Generation: Provide a list of ingredients and get a complete recipe, including title, description, ingredients list, and step-by-step instructions.
  • RESTful API: A clean, well-documented API for easy integration with any front-end application (web or mobile).
  • AI-Powered: Utilizes a state-of-the-art generative AI to ensure creative and coherent recipe suggestions.
  • Scalable Backend: Built with Spring Boot, ensuring a robust, secure, and scalable foundation.

⚙️ How It Works

The application provides a simple yet powerful workflow:

  1. A user sends a POST request to the /api/recipes/generate endpoint with a list of available ingredients in the request body.
  2. The Spring Boot backend receives the request and constructs a carefully crafted prompt for the Grok AI API.
  3. The service makes a secure, server-to-server call to the AI API.
  4. The AI model processes the prompt and returns a structured JSON response containing a complete recipe.
  5. The backend parses this response and sends a clean, well-formatted recipe object back to the user.

🛠️ Technology Stack

  • Backend: Java, Spring Boot
  • API Communication: Spring RestTemplate / WebClient
  • AI Integration: Grok AI API (or other specified generative AI)
  • Data Handling: JSON
  • Build Tool: Maven / Gradle

🚀 Getting Started

To run this project locally, you will need to have Java and Maven/Gradle installed.

1. Clone the repository:

git clone [https://github.com/sidhu1512/recipe-assistant.git](https://github.com/sidhu1512/recipe-assistant.git)
cd recipe-assistant

2. Configure your API Key: The application requires an API key for the AI service. You need to set this as an environment variable.

In your src/main/resources/application.properties file, add the following line:

ai.api.key=YOUR_API_KEY_HERE

(For better security, it's recommended to use environment variables instead of hardcoding the key. You can update the code to read from System.getenv("AI_API_KEY").)

3. Build and run the application:

./mvnw spring-boot:run

The application will start on http://localhost:8080.


Endpoints

Generate a Recipe

  • URL: /api/recipes/generate
  • Method: POST
  • Description: Generates a new recipe based on the provided ingredients.
  • Request Body:
    {
      "ingredients": ["chicken breast", "rice", "broccoli", "soy sauce"]
    }
  • Success Response (200 OK):
    {
      "title": "Simple Chicken and Broccoli Stir-fry",
      "description": "A quick and delicious stir-fry, perfect for a weeknight dinner.",
      "ingredients": [
          "1 lb chicken breast, cubed",
          "1 cup white rice",
          "2 cups broccoli florets",
          "1/4 cup soy sauce"
      ],
      "instructions": "1. Cook rice according to package directions. 2. Sauté chicken in a large skillet... etc."
    }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors