Live Demo: food-ai-ten.vercel.app
FoodAI is a comprehensive nutrition analysis platform that provides AI-powered insights, detailed nutritional facts, and personalized health recommendations for any food item. Built with modern technologies and featuring a subscription-based model with tiered access to premium features.
- AI-Powered Food Analysis: Get comprehensive insights on pros, cons, and health benefits
- Detailed Nutritional Facts: Complete macronutrient and micronutrient breakdown
- Search History: Track and revisit your nutrition exploration journey
- Responsive Design: Seamless experience across desktop and mobile devices
- Dark/Light Mode: Toggle between themes for comfortable viewing
- Unlimited Searches: No monthly limits on food analysis
- Organ-Specific Health Impact: Detailed analysis of how foods affect different organs
- Cooking Tips & Meal Suggestions: Personalized recommendations for food preparation
- Food Pairing Recommendations: Discover optimal food combinations
- Better Alternatives: Get suggestions for healthier substitutes
- Meal Plan Generator: Create personalized nutrition plans
- Export Functionality: Download insights as PDF/CSV
- API Access: Integrate FoodAI data into your applications
- Advanced Analytics: Comprehensive nutrition tracking dashboard
- Framework: Next.js 15.4.4 with App Router
- Language: TypeScript 5.0
- Styling: Tailwind CSS with custom components
- UI Components: Radix UI primitives
- Authentication: NextAuth.js v5
- State Management: React Hooks (useState, useEffect)
- Runtime: Node.js
- Database: PostgreSQL with Prisma ORM
- Authentication: NextAuth.js with multiple providers
- Payment Processing: Razorpay integration
- AI Integration: Google Gemini API
- Nutrition Data: Nutritionix API
- Deployment: Vercel (99% uptime)
- Database Hosting: PostgreSQL (Cloud)
- Storage: Prisma with migration system
- Email: Resend for transactional emails
- Node.js 18+ and npm/yarn
- PostgreSQL database
- Google Gemini API key
- Nutritionix API credentials
- Razorpay account (for payments)
-
Clone the repository
git clone https://github.com/Ashraful-Fuqha/FoodAI.git cd FoodAI -
Install dependencies
npm install
-
Set up environment variables Create a
.env.localfile in the root directory:# Database PRISMA_DATABASE_URL="postgresql://..." # NextAuth NEXTAUTH_SECRET="your-nextauth-secret" NEXTAUTH_URL="http://localhost:3000" # Google Gemini AI GEMINI_API_KEY="your-gemini-api-key" # Nutritionix API NUTRITIONIX_APP_ID="your-app-id" NUTRITIONIX_API_KEY="your-api-key" # Razorpay RAZORPAY_KEY_ID="your-key-id" RAZORPAY_KEY_SECRET="your-key-secret" # Email (Resend) RESEND_API_KEY="your-resend-key"
-
Set up the database
npx prisma generate npx prisma db push
-
Run the development server
npm run dev
-
Open http://localhost:3000 in your browser
The application uses a comprehensive PostgreSQL schema with the following key models:
- User: Authentication and profile management
- Subscription: Plan management (FREE/PRO/PREMIUM)
- Payment: Razorpay transaction records
- Usage: Monthly search tracking
- SearchHistory: User food search history
- Account/Session: NextAuth.js authentication tables
- Multiple Auth Providers: Google, GitHub, Email/Password
- Secure Session Management: NextAuth.js with JWT
- Email Verification: Resend integration for account verification
- Password Hashing: bcryptjs for secure password storage
- Route Protection: Middleware-based authentication checks
- Free: 10 monthly searches, basic features
- Pro (βΉ49/month): Unlimited searches, advanced insights
- Premium (βΉ99/month): Everything + meal plans, export, API access
- Razorpay: Secure payment processing
- Webhook Verification: Cryptographic signature validation
- Automatic Plan Management: Usage limits and feature access control
// Google Gemini API integration for food analysis
const insights = await getFoodAIInsights(foodName);
// Returns: pros, cons, health benefits, organ impact, cooking tips// Automatic usage increment on successful search
await incrementUsage(userId);
// Enforces plan limits and prevents overuse// Real-time subscription status checking
const subscription = await getUserSubscription(userId);
// Controls feature access based on plan tier- Mobile-First Approach: Optimized for all screen sizes
- Touch-Friendly Interface: Easy navigation on mobile devices
- Progressive Web App Ready: Fast loading and offline capabilities
- Dark Mode Support: Automatic theme switching
GET /api/auth/*- Authentication endpointsPOST /api/auth/signin- User sign in
GET /api/subscription/status- Get user subscription detailsPOST /api/subscription/cancel- Cancel current subscriptionPOST /api/razorpay/create-order- Create payment orderPOST /api/razorpay/verify-payment- Verify payment successDELETE /api/history/[id]- Delete search history entry
The application is deployed on Vercel with the following configuration:
{
"build": "npx prisma generate && npx next build",
"start": "next start"
}- Database migrations run automatically on build
- Environment variables configured in Vercel dashboard
- CDN optimization for static assets
- TypeScript: Full type safety throughout the application
- Error Handling: Comprehensive error boundaries and try-catch blocks
- Loading States: User-friendly loading indicators
- Form Validation: Client-side and server-side validation
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Google Gemini AI for powerful food analysis
- Nutritionix for comprehensive nutrition database
- Razorpay for seamless payment processing
- Vercel for reliable hosting platform
- Next.js Team for the amazing framework
Mjafarsadiq D - mjafarsadiqdharwad@gmail.com
Project Link: https://github.com/Ashraful-Fuqha/FoodAI
Live Demo: https://food-ai-ten.vercel.app
β Star this repo if you find it helpful!