This technical guide walks through deploying an AI-powered Food Recipe Assistant application on Sevalla's Application Hosting platform. We'll cover the deployment process, configuration, and best practices for hosting a Python FastAPI application with AI capabilities.
Posted on Medium first:
Project Overview
The AI Food Recipe Assistant is a modern web application that leverages:
- FastAPI for the backend API
- OpenAI's GPT-3.5 and DALL-E 3 for AI-powered recipe and image generation
- HTML/TailwindCSS/AlpineJS for the frontend
- Environment variables for secure configuration
- Docker for containerization
Application code is available on
Intelligent Recipe Generation
Our deployed AI Food Recipe Assistant will demonstrate the powerful AI capabilities like:
Natural Language Understanding: Users can request recipes in plain English (e.g., “vegan chocolate lava cake”)
Dietary Customization: Automatically adapts recipes for various preferences:
- Vegetarian/Vegan options
- Gluten-free alternatives
- Keto-friendly versions
- Other dietary restrictions
- Cuisine Fusion: Supports multiple cuisine types and cultural adaptations
AI-Generated Content
Each recipe request generates the following:
Detailed Recipe Information:
- Ingredient lists with precise measurements
- Step-by-step cooking instructions
- Cooking times and temperatures
- Serving suggestions
- Nutritional information
Visual Content:
- DALL-E 3 generated photorealistic food images
- Appetizing presentation suggestions
- Visual cooking guides
- Learning Resources:
- Cooking technique explanations
- Ingredient substitution options
- Tips for perfect execution
Sample Output
Here's an example of what the application generates for a "Vegan Italian Choco Lava Cake":
{
"recipe": {
"title": "Vegan Italian Choco Lava Cake",
"description": "Indulge in the decadence of a vegan Italian-style choco lava cake that will impress even the most discerning dessert lovers!",
"ingredients": [
"1 cup all-purpose flour",
"1/2 cup unsweetened cocoa powder",
"1/2 cup sugar",
"1/2 cup plant-based milk",
"// ... other ingredients"
],
"instructions": [
"1. Preheat oven to 375°F (190°C)",
"2. Mix dry ingredients in a bowl",
"// ... detailed steps"
]
},
"image_url": "https://ai-generated-image.example/vegan-lava-cake.jpg",
"learning_resources": [
{
"type": "video",
"title": "Master the Art of Vegan Lava Cakes",
"url": "https://youtube.com/cookingtutorials"
}
]
}
Let’s deploy this…
Prerequisites
Before deploying to Sevalla, ensure you have:
- A
for containerized deployment:
CODEFROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Configure environment variables
cp .env.example .env
# Edit .env and add your OpenAI API key:
# OPENAI_API_KEY=your_api_key_here
Run the application
uvicorn main:app --reload
Feel free to create your own application by referring these
- Log into Sevalla dashboard
- Click "Applications" > "Add application"
- Select "Git repository" and connect to your repository
- Choose deployment settings:
- Repository:
your-repo-url
- Branch:
main
- Build Environment: Python
- Region: Choose nearest to your users
- Repository:
3. Environment Variables
We will now add “OPENAI_API_KEY” inside “Environment variables” to use the power of AI in our application to suggest AI-generated recipes.
Application Architecture on Sevalla
The deployed application architecture includes(:
- SSL/TLS encryption
- DDoS protection through Cloudflare
- Secure environment variable storage
- Isolated application environment
Performance Optimizations
Sevalla automatically implements several performance features:
CDN Integration: Global content delivery
Edge Caching: Improved response times
Auto-scaling: Dynamic resource allocation
Load Balancing: Distributed traffic handling
Deployment Verification
After deployment, verify the application:
- Access the provided domain (e.g.,
https://ai-food-assistant-ll3mo.kinsta.app/) - Test the recipe generation endpoint
- Monitor application logs for any issues
- Verify environment variables are properly set
Troubleshooting Tips
Common issues and solutions:
Port Configuration: Ensure the application uses thePORTenvironment variable
Build Failures: Check requirements.txt for compatibility
Runtime Errors: Monitor logs for application errors
Environment Variables: Verify all required variables are set
Why Sevalla for AI Application Deployment?
Building and deploying AI applications can be challenging. Whether you're a developer working on a side project or part of a team building the next big AI product, you need a reliable and easy way to get your app into production. That's where .
SOCIAL SHARE CARD GENERATOR