A comprehensive recipe management application with advanced AI/ML features for recipe analysis, ingredient recognition, nutrition calculation, and meal planning.
The application consists of two main components:
- Framework: Next.js 14 with TypeScript
- Styling: Tailwind CSS with Radix UI components
- Database: PostgreSQL with Prisma ORM
- Authentication: NextAuth.js
- File Uploads: UploadThing
- Framework: FastAPI with async support
- Computer Vision: YOLO v8, CLIP, OpenCV
- NLP: spaCy, NLTK, Transformers
- ML Libraries: PyTorch, scikit-learn, sentence-transformers
- Database: PostgreSQL with SQLAlchemy
- Drag & Drop Interface: Easy image upload with visual feedback
- Camera Capture: Direct photo capture on mobile devices
- Base64 Storage: Efficient image storage in database
- Real-time Analysis: Instant AI-powered food recognition
- Recipe Generation: Automatic recipe suggestions based on detected food
- Nutritional Analysis: Detailed nutritional information
- Image History: Persistent storage of uploaded images and analysis
- β Create and upload user-generated recipes
- β Rich image upload with robust photo management
- β Recipe categorization and tagging
- β Search and filter functionality
- Ingredient Recognition: Advanced computer vision to identify ingredients from food images
- Recipe Generation: AI suggests complete recipes based on detected ingredients
- Confidence Scoring: Each detected ingredient comes with confidence scores
- Bounding Box Detection: Visual localization of ingredients in images
- Smart Tagging: Automatically generate relevant tags (vegetarian, gluten-free, quick meal, etc.)
- Cuisine Detection: Identify cuisine types from ingredients and cooking methods
- Dietary Classification: Automatic detection of dietary restrictions and preferences
- Cooking Method Analysis: Tag recipes by cooking techniques (grilled, baked, stir-fry, etc.)
- Comprehensive Calculation: Detailed nutritional information per serving
- Ingredient Database: Extensive nutritional database with unit conversions
- Portion Estimation: Smart portion size estimation for better accuracy
- Dietary Tracking: Track calories, macros, vitamins, and minerals
- Semantic Search: Find recipes using natural language queries
- Dietary Filtering: Filter by dietary restrictions and preferences
- Similarity Matching: Find similar recipes based on ingredients and techniques
- Personalized Suggestions: Learn from user preferences and behavior
- Food & Drink Pairings: AI suggests complementary dishes and beverages
- Cuisine-Aware: Culturally appropriate pairing suggestions
- Seasonal Recommendations: Suggest pairings based on seasonal ingredients
- Personalized Plans: Generate meal plans based on dietary preferences
- Balanced Nutrition: Ensure nutritional balance across meals
- Shopping Lists: Automatic generation of ingredient shopping lists
- Flexible Duration: Support for 1-14 day meal plans
- β Like/Upvote recipes
- β Save recipes to personal collections
- β "Made" status with user reviews and photos
- β Follow other users and see recipes from your network
- β Recipe reviews and ratings
- β Trending recipes algorithm
- β Recipe discovery based on user circle
- β Promote featured content creators
- β Shopping integration potential
- β Chatbot for recipe finding
- β Real-time recipe analysis
- β Multi-language support potential
- Node.js 18+ and npm
- Python 3.11+ (recommended for ML compatibility)
- PostgreSQL database
- Git
git clone <repository-url>
cd recipe-ai-app
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env.local
# Configure your environment variables:
# - DATABASE_URL: PostgreSQL connection string
# - NEXTAUTH_SECRET: Random secret for NextAuth
# - UPLOADTHING_SECRET: UploadThing API keys
# - ML_BACKEND_URL: ML backend URL (http://localhost:8000)
# Generate Prisma client and run migrations
npx prisma generate
npx prisma db push
# Start the development server
npm run dev
# Navigate to ML backend directory
cd ml-backend
# Create virtual environment with Python 3.11
python3.11 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Setup environment variables
cp .env.example .env
# Configure your environment variables:
# - DATABASE_URL: Same PostgreSQL connection string
# - API_HOST: 0.0.0.0
# - API_PORT: 8000
# Download required models (first run will download automatically)
# - YOLO models (~50MB)
# - Sentence transformers (~100MB)
# - spaCy language models
# Start the ML backend
python run.py
-- Create PostgreSQL database
CREATE DATABASE recipe_ai_db;
-- The Prisma migrations will handle table creation
- Frontend: http://localhost:3000
- ML Backend: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Upload Image: Use the drag & drop area or click "Choose File" to upload a food photo
- Analysis: Click "Analyze" to process the image with AI
- View Results: See detected food, nutritional info, ingredients, and recipe suggestions
- History: All uploaded images are stored and can be viewed in the right panel
Upload a food image for analysis.
Request Body:
{
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...",
"filename": "food-photo.jpg"
}
Response:
{
"food_name": "Pizza Margherita",
"confidence": 0.95,
"calories": 285,
"cooking_time": 25,
"ingredients": ["flour", "tomatoes", "mozzarella", "basil"],
"recipe": "1. Prepare the dough... 2. Add toppings... 3. Bake at 450Β°F for 20-25 minutes"
}
Retrieve all uploaded food images and their analysis.
model FoodImage {
id String @id @default(cuid())
filename String
base64 String @db.Text
uploadedAt DateTime @default(now())
analysis Json?
userId String?
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
recipeId String?
recipe Recipe? @relation(fields: [recipeId], references: [id], onDelete: SetNull)
}
recipe-ai-app/
βββ src/ # Next.js frontend
β βββ app/ # App router pages
β β βββ api/
β β β βββ recipe-analysis/ # Food photo analysis API
β β βββ components/ # React components
β β β βββ ui/ # Reusable UI components
β β β βββ ImageUpload.tsx # Image upload component
β β β βββ ImageDisplay.tsx # Image display component
β β βββ lib/ # Utilities and configurations
β β βββ styles/ # CSS and styling
β βββ ml-backend/ # Python ML backend
β β βββ app/ # FastAPI application
β β β βββ models/ # ML model implementations
β β β β βββ food_recognition.py
β β β β βββ nutrition_analyzer.py
β β β β βββ recipe_recommender.py
β β β β βββ tag_generator.py
β β β βββ utils/ # Utility functions
β β β βββ schemas.py # Pydantic models
β β β βββ database.py # Database configurations
β β β βββ main.py # FastAPI app
β β βββ requirements.txt # Python dependencies
β β βββ run.py # Startup script
β βββ prisma/ # Database schema
β βββ public/ # Static assets
βββ README.md # This file
- YOLO v8: Object detection and ingredient localization
- CLIP: Semantic understanding of food images
- ResNet: Custom food classification
- Sentence Transformers: Recipe similarity and search
- spaCy: Named entity recognition and linguistic analysis
- NLTK: Text preprocessing and tokenization
- TF-IDF: Keyword matching and relevance scoring
- Cosine Similarity: Recipe recommendation scoring
- Clustering: Ingredient categorization
- Feature Engineering: Nutritional analysis and portion estimation
- Rule-based Systems: Dietary classification and pairing suggestions
POST /analyze-food-image
- Analyze uploaded food imagesPOST /generate-recipe-tags
- Generate AI tags for recipesPOST /analyze-nutrition
- Calculate nutritional informationPOST /generate-pairings
- Generate food/drink pairingsPOST /recommend-recipes
- Find recipes by criteriaPOST /generate-meal-plan
- Create personalized meal plansPOST /analyze-recipe-complete
- Complete recipe analysisGET /health
- Health checkGET /models/status
- ML model status
# Build and deploy
npm run build
# Deploy to Vercel or your preferred platform
# Dockerfile for ML backend
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "run.py"]
- Use GPU instances for better ML performance
- Implement model caching and optimization
- Setup load balancing for high traffic
- Use Redis for caching ML results
- Monitor model performance and accuracy
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
- ML models download on first run (initial startup time)
- Image processing can be memory intensive
- Some nutrition data may be approximate
- Mobile app support
- Offline recipe access
- Voice recipe instructions
- Integration with smart kitchen appliances
- Advanced meal planning with calendar integration
- Recipe cost estimation
- Allergen detection and warnings
For issues and questions:
- Check the GitHub Issues page
- Review the API documentation at
/docs
- Check model status at
/models/status
Built with β€οΈ using Next.js, FastAPI, and cutting-edge ML techniques.