reverse.engineer.mp4
This app was built in one prompt with cursor.
A modern Next.js web application that uses AI to analyze food images and generate detailed recipes. Upload a photo of any dish and get a complete recipe with ingredients, instructions, and cooking details!
- 🖼️ Image Upload: Drag and drop or click to upload food images
- 🤖 AI-Powered Analysis: Uses Google's Gemini 2.0 Flash model via OpenRouter
- 📝 Complete Recipes: Get detailed recipes with:
- Creative dish titles
- Ingredient lists with measurements
- Step-by-step instructions
- Prep and cook times
- Serving sizes
- Difficulty levels
- 🎨 Modern UI: Clean, responsive design with Tailwind CSS
- ⚡ Real-time Processing: Live loading states and error handling
- 📱 Mobile Friendly: Responsive design works on all devices
- Node.js 18+ installed
- pnpm package manager
- OpenRouter API key
-
Clone the repository
git clone <your-repo-url> cd ai-recipe-generator
-
Install dependencies
pnpm install --save
-
Set up environment variables
cp .env.local.example .env.local
-
Configure your OpenRouter API key
Edit
.env.local
and add your OpenRouter API key:OPENROUTER_API_KEY=your_actual_api_key_here SITE_URL=http://localhost:3000
Get your API key from: https://openrouter.ai/keys
-
Run the development server
pnpm dev
-
Open your browser
Navigate to http://localhost:3000
- Framework: Next.js 14 with TypeScript
- Styling: Tailwind CSS with custom components
- AI Model: Google Gemini 2.0 Flash (via OpenRouter)
- Image Processing: Base64 encoding for API transmission
- Package Manager: pnpm
ai-recipe-generator/
├── pages/
│ ├── api/
│ │ └── generate.ts # API route for recipe generation
│ ├── _app.tsx # App wrapper with global styles
│ └── index.tsx # Main application page
├── styles/
│ └── globals.css # Global styles and Tailwind imports
├── types/
│ └── index.ts # TypeScript type definitions
├── .env.local.example # Environment variables template
└── README.md # Project documentation
- Upload an Image: Click the upload area or drag and drop a food image
- Generate Recipe: Click the "Generate Recipe" button
- View Results: The AI will analyze your image and provide a complete recipe
- Copy or Save: Use the generated recipe for cooking!
The app uses Tailwind CSS with custom colors defined in tailwind.config.js
:
chef-red
: Primary red color for buttons and accentschef-dark-red
: Darker red for hover statesrecipe-bg
: Light background for recipe cardsrecipe-border
: Border color for recipe cards
Modify the prompt in pages/api/generate.ts
to customize how the AI analyzes images and generates recipes.
Generates a recipe from an uploaded image.
Request Body:
{
"image": "base64_encoded_image_string"
}
Response:
{
"recipe": {
"title": "Delicious Pasta Carbonara",
"description": "Creamy Italian pasta dish...",
"ingredients": ["400g spaghetti", "200g pancetta", ...],
"instructions": ["Boil water for pasta", "Cook pancetta...", ...],
"prepTime": "15 minutes",
"cookTime": "20 minutes",
"servings": "4 servings",
"difficulty": "Medium"
}
}
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenRouter for AI model access
- Google Gemini for the vision AI model
- Next.js for the React framework
- Tailwind CSS for styling
- API Key Error: Make sure your OpenRouter API key is correctly set in
.env.local
- Image Upload Failed: Check that your image is under 10MB and in a supported format (JPG, PNG, GIF)
- Recipe Generation Failed: Ensure you have sufficient credits in your OpenRouter account
If you encounter any issues, please:
- Check the browser console for error messages
- Verify your environment variables are set correctly
- Ensure your OpenRouter API key has sufficient credits
- Open an issue on GitHub with detailed error information
Made with ❤️ and 🧑🍳 for food lovers everywhere!