# BabyMealBot > WhatsApp-powered baby recipe assistant for parents — extract, organize, and safety-check baby recipes from any source. ## Overview BabyMealBot is a web platform with a WhatsApp-native bot that helps parents collect, organize, and verify baby food recipes. Parents can: 1. Send recipe links/photos to the WhatsApp bot to extract and save recipes 2. Upload screenshots at /organize to get a digital cookbook ($4.99 one-time) 3. Use the free Safety Checker at /safety to verify any recipe URL for allergens, choking hazards, and age-appropriateness Production domain: https://babymealbot.com ## Key Features - **WhatsApp Integration**: Recipe extraction via WhatsApp messaging — no app to download - **Screenshot to Cookbook (/organize)**: Upload up to 15 baby food recipe screenshots, AI extracts recipes with safety checks, get a digital cookbook for $4.99 one-time payment (no subscription) - **Safety Directory (/safety)**: Free Safety Checker tool + 8 in-depth allergen/safety guides (avocado, peanut, egg, honey, strawberry, fish, dairy, wheat) - **Recipe Management**: Personal cookbook with age-appropriate recipes - **Smart Grocery Lists**: Browser-based aggregator with quantity merging and ingredient categorization - **Multi-source Input**: TikTok, Instagram Reels, YouTube Shorts, Facebook, Pinterest, websites, and photos/screenshots - **AI-Powered Extraction**: Recipe parsing using Gemini 2.5 Pro via Lovable AI Gateway - **Three-Stage Conversion**: 3 free recipes (no credit card) → 7-day trial (credit card required) → Personal ($7/mo) or Family ($9/mo) subscription via LemonSqueezy - **Family Plan**: Up to 3 WhatsApp numbers sharing one cookbook + grocery list ## Technology Stack ### Frontend - React 18 with TypeScript - Vite build tool with prerender plugin (per-route SEO HTML) - TailwindCSS + shadcn/ui components - Framer Motion animations - React Router v6 - React Query (TanStack Query) - React Helmet Async (SEO) - Hosted on Render (auto-deployed via GitHub from Lovable) ### Backend (Lovable Cloud / Supabase) - PostgreSQL database - Edge Functions (Deno) - Row Level Security (RLS) policies - Realtime subscriptions - File storage ### Integrations - Twilio (WhatsApp Business API) - LemonSqueezy (payments & subscriptions, including $4.99 cookbook one-time) - Apify (web scraping fallbacks for Instagram, Pinterest, etc.) - Tikwm / Jina (lightweight social scrapers — public data only) - Google Cloud Vision (OCR) - Lovable AI Gateway (Gemini 2.5 Pro for extraction & safety analysis) - OpenAI Whisper (WhatsApp voice transcription) - Resend (transactional email) - Google reCAPTCHA v3 (bot protection, soft-fail on edge functions) ## Database Schema (Public Tables) - `user_profiles`: User account data, WhatsApp phone, subscription status & type (regular/family), baby info, onboarding_status (allowed: 'complete' or 'batch_upload' — never 'completed') - `recipes`: Extracted recipes with ingredients, instructions, age appropriateness, safety flags - `family_groups`: Family plan groups with shared baby profile, invite tokens, member limits - `family_members`: Links users to family groups with roles (owner/member) - `conversation_state`: WhatsApp conversation flow state - `cookbook_access_tokens`: Shareable cookbook tokens (private link reconstruction) - `trial_reminders`: Trial expiration notification tracking - `trial_messages_sent`: WhatsApp trial message log - `extraction_events`: Recipe extraction analytics and tracking - `tiktok_extraction_counts`: TikTok extraction usage per billing period - `daily_extraction_counts`: Daily extraction limits for coupon users - `coupons`: Discount codes with custom trial durations - `error_logs`: System error tracking - `batch_cookbooks` / `batch_recipes` / `batch_sessions`: Organize tool screenshot upload sessions ## Edge Functions (API Endpoints) ### WhatsApp & Recipes - `whatsapp-webhook`: Handles incoming WhatsApp messages - `extract-recipe`: Extracts recipe from URL/caption using AI - `get-cookbook`: Retrieves user's cookbook via token - `delete-recipe`: Removes recipe from cookbook - `safety-check`: Free Safety Checker tool backend (returns 200 OK with `rate_limited: true` flag instead of 429) - `safety-warm-cache`: Pre-warms safety check cache for popular recipes ### Organize Tool - `create-batch-session`: Starts a screenshot upload session - `get-batch-preview`: Restores existing session by token - `process-batch-image`: Per-image AI extraction + safety check - `create-batch-checkout`: $4.99 LemonSqueezy checkout for cookbook - `convert-batch-to-user`: Converts batch user to full WhatsApp account post-payment ### Auth, Payments & Email - `upsert-profile`: Creates/updates user profile - `verify-recaptcha`: Bot protection - `create-checkout`: Initiates LemonSqueezy subscription checkout - `lemon-squeezy-webhook`: Processes subscription events - `lemonsqueezy-sync`: Manual sync helper - `send-welcome-email`: Onboarding email - `send-cookbook-email`: Sends digital cookbook link - `send-safety-report`: Emails safety check results - `send-contact-email`: Contact form submissions (Resend) - `trial-reminders`: Scheduled trial expiration notifications - `unsubscribe`: Email preference management - `family-invite`: Generates/redeems family invite tokens ### Admin & Misc - `admin-analytics`: Internal extraction analytics - `extraction-digest`: Daily summary of extraction events - `upload-logo`: Custom branding upload ## Pages & Routes ### Marketing & Conversion - `/` — Homepage (Hero with dual CTAs "Try 3 Recipes Free" + "Organize My Recipes", How It Works with embedded tool, Problem, Solution, Testimonials, Pricing Teaser, FAQ) - `/pricing` — Plan comparison: free tier banner, Personal ($7/mo) vs Family ($9/mo) side-by-side, how-it-works steps, partner nudge ("Add partner for $2 more"), testimonials, FAQ link - `/faq` — Standalone FAQ page with categorized sections (Getting Started, Platforms, Safety, Pricing, Organize tool) - `/contact` — Contact form (Resend) - `/partners` — Partner landing page ### Product Tools - `/organize` — Screenshot-to-Cookbook tool. Upload up to 15 baby food recipe screenshots, AI extracts each, $4.99 one-time payment for the digital cookbook. Includes "How It Works" visual (Upload → Safety Check → Cookbook), embedded YouTube demo, secondary CTA to share Instagram/TikTok saves to WhatsApp bot. Sessions expire after 7 days. - `/cookbook` — User's recipe collection with Recipes and Grocery List tabs (token-gated) - `/demo-cookbook` — Public demo cookbook with pre-selected recipes and grocery list preview ### Safety Directory - `/safety` — Baby food safety directory (CollectionPage) with free Safety Checker tool. 1 free check per 24 hours per IP. Social media URLs (TikTok, Instagram, YouTube) redirect to WhatsApp bot for full video analysis. - `/safety/avocado` — Avocado: BLW prep, choking risk, latex link - `/safety/peanut` — Peanut: AAP early-introduction guidelines, allergy prevention - `/safety/egg` — Egg: yolk + white from 6 months, allergy signs - `/safety/honey` — Honey: 12-month rule, infant botulism risk - `/safety/strawberry` — Strawberry: prep by age, allergy info - `/safety/fish` — Fish: mercury guidance, omega-3 benefits - `/safety/dairy` — Dairy: yogurt/cheese vs cow's milk timing - `/safety/wheat` — Wheat: gluten introduction, celiac considerations Each safety topic page includes: hero with YouTube facade video, age recommendation, preparation tips by age, choking/allergy warnings, nutrition highlights, FAQ accordion (JSON-LD FAQPage), pro tip, example recipes from trusted sources, sources block (AAP/CDC), and embedded Safety Checker tool. ### Auth & Account - `/auth` — Authentication (login/signup, Google OAuth) - `/unsubscribe` — Email unsubscribe - `/privacy` — Privacy policy - `/terms` — Terms of service (includes takedown clause) ### Internal/Admin - `/analytics` — Extraction analytics dashboard - `/grocery-mockup`, `/color-preview`, `/test-email`, `/upload-logo` — Internal tools ## Safety Checker Tool The `/safety` directory features a free recipe safety checker: - Paste any recipe URL to check for allergens, choking hazards, and age-appropriateness - 1 free check per 24 hours per IP (rate limited — returns 200 OK with `rate_limited: true` flag, never 429) - Social media URLs (TikTok, Instagram, YouTube) redirect to WhatsApp bot for full video analysis - Results include age badge, allergen flags, choking hazards, preparation tips - All results include a non-dismissible medical disclaimer - Deep link integration: clicking WhatsApp CTA sends "I want to safety check this recipe: [URL]" which triggers onboarding + auto-extraction - Data retention: safety check results stored for 7 days max ## User Flow ### WhatsApp-First Flow (Free Tier — Primary Funnel) 1. User sends recipe link/photo to WhatsApp bot directly (or clicks "Try 3 Recipes Free" CTA) 2. System creates profile automatically 3. User gets 3 free recipe extractions (no credit card) 4. After 3 recipes, prompted to start 7-day trial (credit card required) ### Organize Flow (One-Time Cookbook) 1. User visits `/organize` 2. Uploads up to 15 recipe screenshots from camera roll 3. AI extracts each recipe with allergen/safety checks 4. Sees CookbookPreview with first recipe full + others blurred behind sticky paywall 5. Pays $4.99 one-time via LemonSqueezy 6. Receives digital cookbook + WhatsApp transfer option (wa.me link to continue on WhatsApp) 7. Welcome email sent if user skips WhatsApp connection ### Subscription Flow (Trial) 1. User signs up with email + WhatsApp number, or upgrades from free tier 2. Redirected to LemonSqueezy checkout for 7-day trial (credit card required) 3. Welcome email sent 4. User sends recipe links/photos to WhatsApp bot 5. Trial reminder emails sent at 3-day and 1-day marks 6. Subscription auto-converts after trial ## Recipe Extraction Process 1. User sends message to WhatsApp bot (URL, caption, or media) 2. `whatsapp-webhook` receives message and resolves any short/redirect URLs 3. `extract-recipe` function: - Detects platform (TikTok, Instagram, YouTube, Facebook, Pinterest, website) - Scrapes content with platform-specific fallback chain (Tikwm/Jina → Apify) - Performs OCR on images/carousels (Google Vision + Gemini Flash) - For Hebrew or text-only content: skips visual processing - Extracts structured recipe via Gemini 2.5 Pro - Validates age appropriateness and safety (AAP/CDC guidelines) - Confidence scoring flags partial extractions 4. Recipe saved to database with user association 5. Confirmation sent via WhatsApp ## Subscription Model ### Free Tier - 3 free recipe extractions (no credit card required) - Personal cookbook access - Basic safety checks - No account needed — just message the bot ### Personal Plan — $7/month - 1 WhatsApp number - Unlimited recipe extractions from all platforms (Instagram Reels, YouTube Shorts, TikTok, Facebook, Pinterest, websites, screenshots) - Age & allergen AI safety filtering - Personal cookbook + grocery lists - 7-day free trial (credit card required to start) ### Family Plan — $9/month (Most Popular) - Up to 3 WhatsApp numbers (partner, nanny, grandparent) - Unlimited recipes + priority AI extraction (faster, including screenshots) - Safety checks for all family members - Synced family cookbook (everyone sees the same recipes) - Shared grocery lists for collaborative meal planning - Family invite system via WhatsApp commands - Shared monthly extraction count (60 recipes/month soft cap) - Family reminders suppressed for free members ### One-Time: Organize Cookbook — $4.99 - Available at `/organize` - Upload up to 15 recipe screenshots - AI extraction + safety/allergen checks - Digital cookbook delivered (web + WhatsApp transfer option) - No subscription required ### Payment & Status - **Payment**: LemonSqueezy (subscriptions + one-time) - **Trial**: 7-day free trial for subscriptions - **Status tracking**: `subscription_status` enum (active, past_due, cancelled, trialing, inactive, free_tier) - **Polling**: Post-checkout polling with 90-second timeout UI - **Coupons**: Custom trial durations and discount upgrades ### Family Invite System - Family plan owners use `invite` command to generate 7-day invite links - Recipients join via `join [token]` WhatsApp command - All family members share the same cookbook and baby profile ## CTAs Across the Site - **Hero (Homepage)**: "Try 3 Recipes Free" (primary, opens WhatsApp) + "Organize My Recipes" (secondary, → /organize) - **Pricing page**: "Start 7-day free trial" (Personal) + "Start Family Trial – 7 days free" (Family) + green "Try free" pill in 3-recipes banner - **Organize page**: Sticky payment bar with "Get my cookbook for $4.99" after first successful extraction - **Safety pages**: "Check this recipe" (Safety Checker) + WhatsApp deep-link CTA on social URLs - **Cookbook**: WhatsApp share link for Instagram/TikTok saves - **Footer**: WhatsApp CTA + pricing/FAQ/contact links ## SEO Implementation - Per-route prerendered HTML via custom Vite plugin (`scripts/prerender-plugin.ts`) — each route ships real `