Skip to content

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

62 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍳 Culinary Canvas

An AI-Powered Recipe Management Platform

Culinary Canvas is a modern, intelligent recipe management application that transforms how you discover, create, and manage recipes. Built with cutting-edge AI technology, it offers innovative features like image-to-recipe generation, random recipe suggestions, and ingredients-based recipe creation.

Project Banner TypeScript MongoDB Gemini AI

🌟 Features

πŸ€– AI-Powered Recipe Generation

  • Image to Recipe: Upload any food image and get a complete recipe with ingredients and cooking instructions
  • Random Recipe Generator: Discover new culinary adventures with AI-generated recipes tailored to your preferences
  • Ingredient-Based Creation: Input available ingredients and get personalized recipe suggestions
  • Smart Recipe Optimization: AI-assisted recipe creation with automatic image generation and nutritional insights

🍽️ Recipe Management

  • Complete Recipe Database: Store and organize your personal recipe collection
  • Advanced Search & Filtering: Find recipes by ingredients, category, dietary preferences, and more
  • Recipe Details: Comprehensive recipe view with ingredients, step-by-step instructions, prep/cook times
  • Mobile-Responsive Design: Perfect experience across all devices

πŸ” Authentication & User Management

  • Secure Authentication: Powered by Clerk with support for Google and GitHub OAuth
  • User Profiles: Personalized dashboard with recipe statistics and recent activity
  • Cloud Storage: Automatic image storage and optimization via Cloudinary

πŸ› οΈ Technology Stack

Frontend

  • Framework: Next.js 15 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: shadcn/ui with Radix UI primitives
  • Authentication: Clerk
  • Image Handling: Next.js Image optimization + Cloudinary
  • State Management: React Hooks + Server Actions

Backend

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB with Mongoose ODM
  • Authentication: Clerk Express SDK + JWT
  • AI Services: Google Gemini AI (2.0 Flash)
  • Image Storage: Cloudinary
  • Workflow Automation: n8n integration
  • Environment: Docker-ready configuration

AI & Machine Learning

  • Primary AI: Google Gemini 2.0 Flash
  • Computer Vision: Image analysis for recipe generation
  • Natural Language Processing: Recipe optimization and generation
  • Image Generation: AI-powered recipe image creation
  • Workflow Engine: n8n for AI pipeline orchestration

πŸ€– n8n Workflow Automation

I have also implemented n8n workflows to automate the recipe generation process. Here is a screenshot of the workflow:

n8n Workflow

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm/yarn
  • MongoDB Atlas account or local MongoDB instance
  • Clerk account for authentication
  • Google AI Studio API key
  • Cloudinary account
  • n8n instance (optional, for advanced workflows)

Installation

  1. Clone the repository

    git clone https://github.com/AlphaBeast97/MegaProject.git
    cd MegaProject
  2. Backend Setup

    cd backend
    npm install
    
    # Create .env file
    cp .env.example .env
  3. Frontend Setup

    cd ../frontend
    npm install
    
    # Create .env.local file
    cp .env.local.example .env.local

Environment Configuration

Backend (.env)

# Database
MONGODB_URI=mongodb+srv://your-connection-string

# Authentication
CLERK_PUBLISHABLE_KEY=pk_test_your-key
CLERK_SECRET_KEY=sk_test_your-key
JWT_SECRET=your-jwt-secret

# AI Services
GEMINI_API_KEY=your-gemini-api-key

# Cloud Storage
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret

# n8n Integration
N8N_WEBHOOK_URL_RECIPE=your-n8n-webhook-url
N8N_WEBHOOK_URL_IMAGE=your-n8n-image-webhook-url

# Server Configuration
PORT=5000
NODE_ENV=development

Frontend (.env.local)

# Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your-key
CLERK_SECRET_KEY=sk_test_your-key

# API Configuration
NEXT_PUBLIC_API_BASE_URL=http://localhost:5000/api

# App URLs
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard

# Cloudinary Name
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=your-cloud-name

Running the Application

  1. Start the Backend

    cd backend
    npm run server  # Development with nodemon
    # or
    npm start      # Production
  2. Start the Frontend

    cd frontend
    npm run dev    # Development server on port 9002
    # or
    npm run build && npm start  # Production build
  3. Access the Application

πŸ“– API Documentation

Authentication

All protected endpoints require a Bearer token in the Authorization header:

Authorization: Bearer <your-clerk-jwt-token>

Core Endpoints

Recipes

  • GET /api/recipes - Get user's recipes
  • POST /api/recipes - Create/generate recipe
  • GET /api/recipes/:id - Get specific recipe

Image Upload

  • POST /api/upload-image - Upload image to Cloudinary

User Management

  • GET /api/users/profile - Get user profile
  • PUT /api/users/profile - Update user profile

Recipe Generation Types

1. Ingredient-Based Generation

POST /api/recipes
{
  "type": "ingredients",
  "content": {
    "userid": "user_123",
    "ingredients": ["chicken", "broccoli", "garlic"]
  }
}

2. Image-Based Generation

POST /api/recipes
{
  "type": "image",
  "content": {
    "userid": "user_123",
    "image": "https://cloudinary-url/image.jpg"
  }
}

3. Random Recipe Generation

POST /api/recipes
{
  "type": "random",
  "content": {
    "userid": "user_123",
    "preferences": {
      "cuisine": "Italian", //optional
      "difficulty": "Medium", //optional
      "dietary": "Vegetarian" //optional
    }
  }
}

🎨 Project Structure

MegaProject/
β”œβ”€β”€ frontend/                 # Next.js Frontend Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/             # App Router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/   # User dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ recipes/     # Recipe management
β”‚   β”‚   β”‚   β”œβ”€β”€ image-to-recipe/  # Image upload & generation
β”‚   β”‚   β”‚   β”œβ”€β”€ random-recipe/    # Random recipe generator
β”‚   β”‚   β”‚   └── about/       # Project information
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/         # shadcn/ui components
β”‚   β”‚   β”‚   β”œβ”€β”€ AppLayout.tsx
β”‚   β”‚   β”‚   └── AppSidebar.tsx
β”‚   β”‚   β”œβ”€β”€ ai/             # AI integration
β”‚   β”‚   β”‚   β”œβ”€β”€ flows/      # Genkit AI flows
β”‚   β”‚   β”‚   └── genkit.ts   # AI configuration
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ types/          # TypeScript type definitions
β”‚   β”‚   └── utils/          # Utility functions
β”‚   β”œβ”€β”€ public/             # Static assets
β”‚   └── package.json
β”œβ”€β”€ backend/                 # Express.js Backend API
β”‚   β”œβ”€β”€ controllers/        # API route handlers
β”‚   β”‚   β”œβ”€β”€ recipe.controller.js
β”‚   β”‚   └── user.controller.js
β”‚   β”œβ”€β”€ models/            # MongoDB schemas
β”‚   β”‚   β”œβ”€β”€ recipe.model.js
β”‚   β”‚   └── user.model.js
β”‚   β”œβ”€β”€ routes/            # API routes
β”‚   β”‚   β”œβ”€β”€ recipe.routes.js
β”‚   β”‚   └── user.routes.js
β”‚   β”œβ”€β”€ libs/              # External service integrations
β”‚   β”‚   └── image_generator.js
β”‚   β”œβ”€β”€ utils/             # Utility functions
β”‚   β”‚   β”œβ”€β”€ db.js          # Database connection
β”‚   β”‚   β”œβ”€β”€ env.js         # Environment variables
β”‚   β”‚   └── jwtUtils.js    # JWT utilities
β”‚   β”œβ”€β”€ config/            # Configuration files
β”‚   β”‚   └── cloudinary.js
β”‚   β”œβ”€β”€ server.js          # Application entry point
β”‚   └── package.json
β”œβ”€β”€ Docs/                   # Project documentation
β”‚   β”œβ”€β”€ PRD + Wireframes.md
β”‚   └── wireframe_mob.png
└── README.md

πŸ”§ Configuration Details

Database Schema

Recipe Model

{
  title: String,           // Recipe name
  description: String,     // Recipe description
  category: String,        // Recipe category
  clerkId: String,        // User identifier
  ingredients: [String],   // List of ingredients
  instructions: [String], // Step-by-step instructions
  prepTime: String,       // Preparation time
  cookTime: String,       // Cooking time
  imageUrl: String,       // Recipe image URL
  timestamps: true        // createdAt, updatedAt
}

User Model

{
  username: String,
  email: String,
  clerkId: String,        // Clerk user ID
  timestamps: true
}

AI Workflows

Genkit Flows

  1. Recipe Title & Description Generation

    • Input: ingredients, instructions
    • Output: creative title and description
  2. Recipe Suggestions from Ingredients

    • Input: comma-separated ingredients
    • Output: recipe suggestions array
  3. Recipe Suggestions from Image

    • Input: food image URI (base64)
    • Output: recipe suggestions based on visual analysis

πŸš€ Deployment

Frontend (Vercel)

# Build and deploy to Vercel
npm run build
vercel --prod

Backend (Railway/Heroku)

# Set environment variables in your platform
# Deploy using platform-specific methods

Database (MongoDB Atlas)

  • Create a MongoDB Atlas cluster
  • Configure network access and database users
  • Update connection string in environment variables

Cloud Services Setup

Cloudinary Configuration

  1. Create Cloudinary account
  2. Get cloud name, API key, and API secret
  3. Configure upload presets for image optimization

Clerk Authentication

  1. Create Clerk application
  2. Configure OAuth providers (Google, GitHub)
  3. Set up webhooks for user management
  4. Configure redirect URLs

πŸ§ͺ Testing

Frontend Testing

cd frontend
npm run lint        # ESLint checks
npm run typecheck   # TypeScript validation

Backend Testing

cd backend
npm test           # Run test suite (if configured)

πŸ“ˆ Performance Optimization

Frontend Optimizations

  • Image Optimization: Next.js Image component with Cloudinary
  • Code Splitting: Automatic with Next.js App Router
  • Bundle Analysis: Built-in Next.js bundle analyzer
  • Caching: Server-side caching for API responses

Backend Optimizations

  • Database Indexing: Optimized MongoDB queries
  • Rate Limiting: API rate limiting for stability
  • Compression: Gzip compression for responses
  • Caching: Redis caching for frequently accessed data

πŸ›‘οΈ Security Features

  • Authentication: Secure JWT-based authentication with Clerk
  • Authorization: Role-based access control
  • Input Validation: Comprehensive request validation
  • Environment Security: Secure environment variable management
  • CORS Configuration: Proper cross-origin resource sharing setup
  • Image Upload Security: File type and size validation

πŸ› Troubleshooting

Common Issues

Authentication Problems

# Check Clerk configuration
# Verify environment variables
# Clear browser cookies and local storage

Database Connection Issues

# Verify MongoDB connection string
# Check network access in MongoDB Atlas
# Ensure database user permissions

AI Generation Failures

# Verify Gemini API key
# Check API quota and limits
# Validate image formats and sizes

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Team

  • AlphaBeast - Full Stack Developer (Backend & AI Integration)
  • MaximumCell - Frontend Developer (UI/UX & React Components)

πŸ™ Acknowledgments

  • Google Gemini AI for powerful AI capabilities
  • Clerk for seamless authentication
  • Cloudinary for image management
  • MongoDB for flexible data storage
  • Vercel for deployment platform
  • Next.js team for the amazing framework
  • shadcn/ui for beautiful UI components

πŸ”— Links


⭐ Star this repository if you found it helpful!

Made with ❀️ by the Culinary Canvas Team

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages