A comprehensive nutrition planning app built with React Native, Expo Router, Supabase PostgreSQL backend, and Google Gemini AI for intelligent meal plan generation.
- Real AI-Powered Meal Plans: Uses Google Gemini Pro to generate personalized meal plans
- Turkish & Mediterranean Cuisine: AI specializes in Turkish and Mediterranean recipes
- Intelligent Recipe Creation: Generates new recipes based on user preferences and dietary restrictions
- Fallback System: Automatically falls back to rule-based generation if AI is unavailable
- Retry Logic: Implements exponential backoff for reliable AI API calls
- Personalized Prompts: Generates detailed prompts based on user profile, goals, and restrictions
- Nutritional Accuracy: AI calculates calories and macros for each generated recipe
- Dietary Compliance: Respects all dietary preferences (vegetarian, gluten-free, etc.)
- Cultural Authenticity: Focuses on authentic Turkish and Mediterranean dishes
- Recipe Validation: Validates AI-generated content before saving to database
- PostgreSQL Database with Supabase
- Row Level Security (RLS) for data protection
- Real-time data synchronization
- Secure authentication with token validation
- API endpoints for all CRUD operations
- AI Meal Planning with Google Gemini Pro
- User Profiles with health metrics and goals
- Recipe Management with nutrition information
- Meal Planning with weekly schedules
- Grocery Lists auto-generated from meal plans
- Authentication with email/password and social login
- Users/Profiles: Personal information, health metrics, goals
- Recipes: Detailed recipes with ingredients and nutrition (AI-generated + curated)
- Meal Plans: Weekly meal schedules linked to recipes
- React Native with Expo SDK 52
- Expo Router for navigation
- TypeScript for type safety
- Custom hooks for API integration
- Supabase as Backend-as-a-Service
- PostgreSQL database
- Row Level Security for data protection
- Real-time subscriptions
- Google Gemini Pro for meal plan generation
- Custom prompt engineering for Turkish/Mediterranean cuisine
- Intelligent fallback to rule-based generation
- Recipe validation and nutritional analysis
- Custom API wrapper with error handling
- Loading states and optimistic updates
- Automatic fallback to mock data in development
- Type-safe API calls with TypeScript
├── supabase/
│ └── migrations/ # Database schema and seed data
├── lib/
│ ├── api.ts # API layer with all endpoints
│ ├── supabase.ts # Supabase client configuration
│ ├── geminiApi.ts # Google Gemini AI integration
│ └── mealPlanGenerator.ts # AI + rule-based meal planning
├── hooks/
│ └── useApi.ts # Custom hooks for API calls
├── contexts/
│ └── AuthContext.tsx # Authentication state management
├── types/
│ └── index.ts # TypeScript type definitions
└── app/ # Expo Router pages
-
Get Gemini API Key
- Visit Google AI Studio
- Create a new API key for Gemini Pro
- Copy your API key
-
Configure Environment Variables
# Add to your .env file
EXPO_PUBLIC_GEMINI_API_KEY=your_gemini_api_key_here- AI Features
- ✅ Personalized meal plan generation
- ✅ Turkish & Mediterranean recipe creation
- ✅ Dietary restriction compliance
- ✅ Nutritional calculation
- ✅ Automatic fallback to rule-based generation
The app uses sophisticated prompt engineering to generate culturally authentic and nutritionally accurate meal plans:
// Example prompt structure
`Sen Türk ve Akdeniz mutfağı konusunda uzman bir diyetisyensin.
Aşağıdaki kullanıcı profili için 7 günlük kişiselleştirilmiş beslenme planı oluştur:
KULLANICI PROFİLİ:
- İsim: ${user.name}
- Yaş: ${user.age}
- Hedef: ${goalDescription}
- Beslenme Kısıtlamaları: ${dietaryRestrictions}
HEDEF KALORI: ${targetCalories} kcal/gün
...`- id (uuid, primary key, references auth.users)
- email (text, unique)
- name (text)
- age (integer)
- gender (text)
- weight_kg (numeric)
- height_cm (numeric)
- activity_level (text)
- primary_goal (text)
- dietary_preferences (text[])
- is_premium_user (boolean)- id (uuid, primary key)
- title (text)
- description (text)
- cuisine_type (text)
- photo_url (text)
- prep_time_minutes (integer)
- cook_time_minutes (integer)
- calories (integer)
- protein_grams (numeric)
- carbs_grams (numeric)
- fat_grams (numeric)
- ingredients (jsonb)
- instructions (text[])- id (uuid, primary key)
- user_id (uuid, references profiles)
- start_date (date)
- end_date (date)
- daily_meals (jsonb)- Row Level Security (RLS) enabled on all tables
- User-specific data access policies
- Secure authentication with Supabase Auth
- Token-based API authentication
- Input validation and sanitization
- AI response validation and sanitization
- Node.js 18+
- Expo CLI
- Supabase account
- Google Gemini API key (optional, for AI features)
- Clone the repository
git clone <repository-url>
cd diet-plan-app- Install dependencies
npm install-
Set up Supabase
- Create a new Supabase project
- Run the migration files in
supabase/migrations/ - Copy your project URL and anon key
-
Configure environment variables
cp .env.example .envFill in your credentials:
EXPO_PUBLIC_SUPABASE_URL=your_supabase_project_url
EXPO_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
EXPO_PUBLIC_GEMINI_API_KEY=your_gemini_api_key
- Start the development server
npm run devimport { mealPlanApi } from '@/lib/api';
// Generate AI-powered meal plan
const { data, error } = await mealPlanApi.generatePersonalizedPlan(
userId,
mealCount, // 3 or 4 meals per day
forceRefresh // true for premium users
);- Automatic Recipe Creation: AI generates new recipes based on user preferences
- Nutritional Accuracy: Each recipe includes calculated calories and macros
- Cultural Authenticity: Focuses on Turkish and Mediterranean cuisine
- Dietary Compliance: Respects all dietary restrictions and preferences
- Intelligent Fallback: Uses rule-based generation if AI is unavailable
import { profileApi } from '@/lib/api';
// Get user profile
const { data, error } = await profileApi.getProfile(userId);
// Update profile
const { data, error } = await profileApi.updateProfile(userId, updates);import { recipeApi } from '@/lib/api';
// Get all recipes (includes AI-generated)
const { data, error } = await recipeApi.getAllRecipes();
// Get recipe by ID
const { data, error } = await recipeApi.getRecipeById(recipeId);import { mealPlanApi } from '@/lib/api';
// Get user meal plans
const { data, error } = await mealPlanApi.getUserMealPlans(userId);
// Generate AI meal plan
const { data, error } = await mealPlanApi.generatePersonalizedPlan(userId, 3);The app automatically falls back to rule-based meal planning when:
- Gemini API key is not configured
- AI API calls fail or timeout
- Network connectivity issues
This ensures the app remains functional even without AI integration.
- Deploy migrations to Supabase
- Configure RLS policies
- Set up authentication providers
- Build the app:
npm run build:web - Deploy to your preferred hosting platform
- Configure environment variables including Gemini API key
- Ensure Gemini API key is properly configured
- Test AI meal plan generation
- Monitor API usage and costs
- Set up error monitoring for AI failures
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Test AI integration if modifying AI features
- Submit a pull request
This project is licensed under the MIT License.