Meet PantryPal: Your Personal AI-Powered Sous-Chef ππ½οΈ
Say goodbye to pantry panic! PantryPal instantly transforms whatever youβve got on handβplus any dietary preferencesβinto mouth-watering, chef-level recipes in just seconds. No more copy-pasting lists into ChatGPT or scrolling through endless recipe sites.
Built from the frustration of βwhatβs for dinner?β, PantryPal combines the power of Google Gemini AI with a sleek, intuitive Streamlit interface. Simply list your ingredients, set your dietary restrictions and servings, and watch as AI crafts a custom recipe complete with step-by-step instructions, nutrition breakdown, shopping list, and stunning hero images. Cooking has never been this effortlessβor this inspiring!
- π Live App
- π Features
- π οΈ Prerequisites
- π Installation
- π Configuration
- π Directory Structure
βΆοΈ Running the App- π§° Linting & Formatting
- π§βπ³ How to Use
- βοΈ Customization
- π³ Docker Support
- π Analysis Scripts
- π€ Contributing
- π License
- π§ Contact
- π Acknowledgments
Try it now in your browser: https://pantrypal-app.streamlit.app. Feel free to explore and generate recipes with your pantry items!
Although Streamlit is not a full-fledged web framework, it provides a simple and effective way to create interactive data-based web applications. Here are some of the key features of PantryPal:
- Pantry-based recipe generation: Enter your pantry items and get a recipe tailored to what you have.
- Surprise Me!: Let the AI create a random recipe from scratch.
- Dietary restrictions: Choose from options like Vegetarian, Vegan, Gluten-Free, and more.
- Servings slider: Adjust the number of servings from 1 to 12.
- Hero image selection: Pick a beautiful image for your recipe from Unsplash.
- Interactive ingredients checklist: Check off ingredients as you gather them.
- Shopping list download: Download a TXT file of your shopping list.
- Nutrition bar & donut charts: Visualize the nutritional breakdown per serving.
- Estimated difficulty: Get an idea of how challenging the recipe is.
- Download recipe: Save your recipe as JSON, Markdown, or plain TXT.
- Docker support: Run the app in a containerized environment for easy deployment.
- Linting & formatting: Code is formatted with Black and imports are sorted with isort.
- Environment variable management: Use
.env
or.streamlit/secrets.toml
for sensitive information. - Interactive charts: Nutrition information is displayed using Altair for better visualization.
- Persistent storage: Recipe history is saved and persists across sessions for easy access.
- User-friendly UI: Built with Streamlit for a clean and intuitive interface.
- Python 3.9 or later
- A Google Cloud API key with access to the Generative AI (Gemini) API
- An Unsplash developer access key for fetching food images
-
Clone the repository
git clone https://github.com/hoangsonww/PantryPal-Streamlit-App.git cd PantryPal-Streamlit-App
-
Create & activate a virtual environment
python3 -m venv .venv source .venv/bin/activate # for macOS/Linux .venv\Scripts\activate # for Windows PowerShell
-
Install dependencies
pip install --upgrade pip pip install -r requirements.txt
Create a file named .env
in the project root with the following variables:
# .env
GOOGLE_AI_API_KEY=<YOUR_GOOGLE_GEMINI_API_KEY>
UNSPLASH_ACCESS_KEY=<YOUR_UNSPLASH_ACCESS_KEY>
- GOOGLE_AI_API_KEY: Your Google Cloud API key for the Generative AI (Gemini) API.
- UNSPLASH_ACCESS_KEY: Your Unsplash Access Key (register at https://unsplash.com/developers).
Alternatively, create a .streamlit/secrets.toml
file with the same variables:
# .streamlit/secrets.toml
GOOGLE_AI_API_KEY = "<YOUR_GOOGLE_GEMINI_API_KEY>"
UNSPLASH_ACCESS_KEY = "<YOUR_UNSPLASH_ACCESS_KEY>"
pantrypal/
βββ app.py
βββ .env # Environment variables
βββ .streamlit/
β βββ config.toml # Streamlit configuration
β βββ secrets.toml # Alternative for .env
βββ Dockerfile # Dockerfile for containerization
βββ docker-compose.yml # Docker Compose file
βββ analysis/
β βββ ingredient_frequency.py
β βββ nutrition_summary.py
β βββ trends_over_time.py
βββ components/
β βββ inputs.py # Sidebar input UI
β βββ display.py # Recipe & history rendering
βββ utils/
β βββ genai_client.py # Gemini AI wrapper
β βββ image_fetcher.py # Unsplash image fetcher
β βββ storage.py # JSONβfile storage for history
βββ requirements.txt # Python dependencies
βββ README.md # This file
With your virtual environment active and .env
configured, simply run:
streamlit run app.py
Then open the URL shown in your terminal (e.g. http://localhost:8501
) in your browser.
We use Black for code formatting and isort for import sorting. To check and format your code, run:
# Check code style
black --check .
isort --check .
# Format code
black .
isort .
- Enter Ingredients
- Paste a comma-separated list of pantry items (e.g.
chicken, rice, tomato
).
- Paste a comma-separated list of pantry items (e.g.
- Select Dietary Restrictions (optional)
- Choose from Vegetarian, Vegan, Gluten-Free, Dairy-Free, etc.
- Adjust Servings
- Slide to set portions (1β12).
- Generate
- Click Generate Recipe to fetch from Gemini AI.
- Pick a Hero Image
- If images are available, select your favorite and click Confirm Image once.
- View Recipe
- See the title, image, ingredients checklist, shopping list, nutrition charts, difficulty, instructions, and substitutions.
- Download
- Grab the recipe as JSON, Markdown, or plain TXT; download your shopping list (TXT).
- History
- Scroll down to revisit past recipes; use Delete to remove any entry.
- Surprise Me!
- Click to have Gemini invent a random recipe from scratch (no pantry required).
- Clear History
- Wipe all saved recipes with one click.
- Enjoy Cooking!
- Get cooking with your generated recipe! π§βπ³
- Share your creations on social media with #PantryPal!
- Max output tokens & temperature for AI calls can be adjusted in
utils/genai_client.py
. - Caching for images is handled in
utils/image_fetcher.py
(TTL = 1 hour). - Recipe History uses Local Storage to persist recipe history across sessions.
- This allows you to revisit past recipes without needing to regenerate them.
To run the app in a Docker container, use the provided Dockerfile
and docker-compose.yml
. Build and run the container with:
docker-compose up --build
This will create a Docker image and start the app in a container. Access it at http://localhost:8501
.
Once you have generated some recipes, you can analyze the data using the scripts in the analysis/
directory. These scripts provide insights into ingredient frequency, nutrition summaries, and trends over time.
Run the following commands from the project root to execute the analysis scripts:
python analysis/ingredient_frequency.py
python analysis/nutrition_summary.py
python analysis/trends_over_time.py
- Fork the repo
- Create a new branch (
git checkout -b feature/foo
) - Commit your changes (
git commit -m "Add foo"
) - Push to the branch (
git push origin feature/foo
) - Open a Pull Request
This project is licensed under the MIT License. See LICENSE for details.
This project is created and maintained by Son Nguyen. Below are my contact details:
- LinkedIn: hoangsonw
- GitHub: @hoangsonww
- Streamlit for the web framework
- Google Gemini AI for recipe generation
- Unsplash for beautiful images
- Altair for interactive charts
- Python-dotenv for environment variable management
- pandas for data manipulation
- Snowflake for cloud deployment
Thank you for checking out PantryPal! π¨βπ³ We hope it makes your cooking adventures easier and more fun. If you have any questions or suggestions, feel free to reach out! π