TruffleNation.ai

AI Pastry Chef Mentor App — Complete Build Plan: Web + Android + iOS

24
Weeks
6
Phases
~$265
/mo Infra
3
Platforms
20K
Day-1 Users

01 Context & Vision

Product Description

TruffleNation.ai is an AI-powered pastry mentor available at trufflenation.ai. It delivers personalized pastry education through AI-generated courses, interactive quizzes, flash cards, audio lessons, and a comprehensive baker's toolkit — all grounded in a proprietary knowledge base built from real pastry expertise.

Proprietary Knowledge Base

  • 29 TN class transcripts — Full day-by-day pastry school curriculum
  • ~100 Scoolinary professional recipe books from 30+ international chefs — covering everything from viennoiserie to molecular pastry

Three Source Documents

  • Oboe Feature Docs
  • Pastry Chef Skill Explainer
  • TruffleNation.ai Product Outline

Ecosystem Integration

  • Student Portal at students.trufflenation.ai — shared authentication, same PostgreSQL database
  • 82-tool Baker's Toolkit superapp — embedded directly into the AI Mentor platform

02 Tech Stack

LayerChoiceReasoning
WebNext.js 14 (App Router)Matches Student Portal stack; SSR for SEO; streaming API routes
MobileExpo (React Native)Shares TypeScript/types; native feel; EAS for store submission
BackendNext.js API routes on VPS (PM2 + Nginx)Same infra as Student Portal; no timeout limits
DatabasePostgreSQL 16 on VPS (existing)Already running; add pgvector extension
ORMPrismaAlready used in Student Portal
Vector DBpgvector (PostgreSQL extension)No external service; SQL-based filtering
EmbeddingsOpenAI text-embedding-3-small$0.02/M tokens; one-time ~$0.02
AI GenerationClaude Sonnet 4 (courses) + Haiku (quizzes, flash cards)Sonnet for quality; Haiku 10-20x cheaper for lightweight
TTSElevenLabsTwo-voice conversational audio; $5/mo
AuthJWT (jose + bcryptjs)Same as Student Portal; shared DB
PaymentsRazorpay (INR) + Stripe (USD)Dual market; IP-based detection
File StorageVPS filesystem → Cloudflare R2 (scale)Start simple
HostingHostinger VPS (existing)$0 incremental; PM2 + Nginx
EmailBrevoExisting TN integration
MonorepoTurborepoapps/web + apps/mobile + packages/shared
VPS Consolidation Benefits
• $0 additional hosting cost
• Same PostgreSQL instance — shared users table
• No serverless timeout limits
• pgvector instead of Pinecone — one fewer external service
• Single deployment target: git pull → build → pm2 restart

Monorepo Structure

trufflenation-ai/
  apps/
    web/                 # Next.js 14 (trufflenation.ai)
    mobile/              # Expo (React Native, iOS + Android)
  packages/
    shared/              # TS types, API client, tier logic, baker's math, SR algorithm
    ui/                  # Design tokens (colors, spacing, fonts)

03 Database Schema

16 tables powering the entire AI Mentor platform. All tables live in the existing VPS PostgreSQL instance alongside the Student Portal.

id, email, password_hash, name, avatar_url, ai_tier (free/home_baker/chef), portal_student (boolean), credits_remaining, credits_reset_at, referral_code, referred_by, created_at, updated_at

id, user_id, title, topic, config_json (difficulty, style, focus), status (generating/complete/error), chapter_count, created_at, updated_at

id, course_id, order_index, title, content_md, rich_elements_json, sources_json, created_at

id, chapter_id, quiz_type (fill_blank/technique_match/fault_diagnosis), questions_json, created_at

id, quiz_id, user_id, answers_json, score, passed (boolean), attempted_at

id, user_id, course_id, cards_json, sm2_state_json (per-card interval, ease_factor, next_review), created_at, updated_at

id, course_id, user_id, content_json (6-section format), created_at

id, chapter_id, script_text, audio_url, duration_seconds, voice_config_json, status (pending/processing/ready/error), created_at

id, question_text, options_json, correct_answer, explanation, category, difficulty, publish_date, created_at

id, daily_bake_id, user_id, selected_answer, is_correct (boolean), responded_at

id, user_id, tier, payment_provider (razorpay/stripe/storekit), provider_subscription_id, status (active/cancelled/past_due), current_period_start, current_period_end, created_at

id, user_id, amount, action (course_generate/qa_query/quiz_generate/study_guide/flash_cards), reference_id, created_at

id, content, embedding (vector 1536), source_type, source_name, metadata (jsonb: day_number, instructor, topic_category, content_type, difficulty, section_title), created_at

id, user_id, bookmarkable_type (chapter/course/daily_bake), bookmarkable_id, created_at

id, user_id, course_id, last_chapter_index, progress_pct, last_accessed_at

id, user_id, code (unique), total_referrals, successful_referrals, current_tier, created_at

id, referrer_id, referee_id, referral_code, status (pending/verified/rewarded/rejected), verified_at, created_at

id, user_id, reward_type (extra_course/unlimited_chapters/flash_cards/study_tools/home_baker_month), activated_at, expires_at, created_at

04 RAG Pipeline

Chunking Strategy

  • Semantic boundaries — one technique, recipe, or concept per chunk
  • Target size: 300-500 tokens/chunk
  • Metadata: { day_number, instructor, topic_category, content_type, difficulty, source, section_title }
  • ~2,000 chunks total

Retrieval Flow

  1. Embed user query with text-embedding-3-small
  2. Query pgvector with SQL WHERE for tier filtering
  3. Re-rank by cosine threshold > 0.75
  4. Assemble ~6,000 tokens of context
  5. Pass to Claude with system prompt + retrieved context + user config

pgvector Setup

CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE knowledge_chunks (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  content TEXT NOT NULL,
  embedding VECTOR(1536),
  source_type VARCHAR(50) NOT NULL,
  source_name VARCHAR(200),
  metadata JSONB NOT NULL,
  created_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX ON knowledge_chunks
  USING ivfflat (embedding vector_cosine_ops)
  WITH (lists = 50);

System Prompt

You are the TruffleNation.ai Pastry Mentor. Draw EXCLUSIVELY from provided knowledge base.
Never fabricate techniques, temperatures, ratios, or chef quotes not in context.
Include: Chef's Corner (attributed quotes), technique tables, storage cards,
equipment callouts, baker's math, common mistakes, glossary terms [[in brackets]].

05 Phase 0 — Knowledge Base Preparation (Weeks 1-2)

06 Phase 1 — Core AI Platform (Weeks 3-6)

Demoable: Generate a full pastry course from a topic, browse with rich elements, click glossary terms, access Baker's Toolkit.

07 Phase 2 — Learning + Engagement + Referrals (Weeks 7-10)

Demoable: Complete learning loop — generate, read, quiz, ask deeper, share, play Daily Bake.

08 Phase 3 — Study Tools + Audio + Payments (Weeks 11-15)

Demoable: Subscribe, listen to audio, study with flash cards, take exam, earn badge.

09 Phase 4 — Mobile Apps (Weeks 16-20)

10 Phase 5 — Polish + Launch (Weeks 21-24)

11 Authentication

  • Web: JWT in httpOnly cookies
  • Mobile: JWT in expo-secure-store
  • Portal ↔ AI Mentor: Same user row, same JWT secret, ai_tier column
  • No cross-domain token dance needed — single domain, single database
  • OAuth (future): Google + Apple
Because the AI Mentor and Student Portal share the same PostgreSQL instance and JWT secret, a user who logs in on one platform is effectively authenticated on both. The ai_tier column on the users table determines access level, and portal students are auto-upgraded to Chef tier.

12 Pricing & Monetization

FeatureFreeHome Baker (₹499/mo)Chef (₹1,499/mo)
AI courses1/mo, 2 chapters10/week, unlimitedUnlimited
AI modelSonnetSonnetSonnet
GlossaryRead-onlyFull + interactiveFull + interactive
Go Deeper Q&A3/month50/dayUnlimited
AudioNoStreamingStreaming + download
Flash cardsNoUnlimitedUnlimited
Study guideNoYesYes
Practical examNoYesYes + certificate
Baker's Toolkit5 toolsAll 82All 82
Daily BakeYesYes + archiveYes + archive
ScoolinaryNoNoYes
PDF exportNoNoYes
Public sharingNoNoYes
Free tier cost: ~₹71/user/mo ($0.85). 1,000 free users = ~$850/mo.

13 Referral System — "Invite a Baker"

Rewards Ladder

ReferralsUnlockWhat they getIncremental cost
0Base Free1 course/mo, 2 chapters, 3 Q&A/mo$0.85/mo
1+1 course2 courses/month+$0.15/mo
3+chapters +cardsUnlimited chapters + flash cards+$0.05/mo
5+study toolsStudy guide + 10 Q&A/week+$0.12/mo
10Free Home BakerFull tier for 1 month~$2.40 one-time
Economics: 10 referrals = $0.24 CAC per user vs $0.60-2.40 for Meta ads

Referral UX

  • Dashboard card with progress bar
  • WhatsApp share with pre-filled message
  • Push notifications on referral events
  • Anti-abuse: email verify + first course + 7-day active check

Viral Loop

Free user
Shares on WhatsApp
Friend installs
Signs up
Views course
Referrer gets reward
Shares more

14 Infrastructure Costs

Monthly Infrastructure

ServiceMonthly
Hostinger VPS$0 incremental
PostgreSQL + pgvector$0 incremental
EAS Free$0
Claude API (cached)~$150-250
ElevenLabs$5
OpenAI Embeddings~$1
Apple Developer$8.25/mo
Total~$165-265/mo

Claude API Breakdown

TaskModelPer callMonthly volumeCost
Course generationSonnet~$1.20~100 (80% cache)$120
Go Deeper Q&ASonnet~$0.05~2,000$100
Quiz generationHaiku~$0.008~500$4
Study guideHaiku~$0.01~300$3
Flash cardsHaiku~$0.005~400$2
Daily BakeHaiku~$0.00330$0.09
Cost Reduction Strategies
1. Pre-generate top 50 courses (~$60 one-time)
2. Cache identical/similar topics
3. Haiku for lightweight tasks
4. Credit system limits free-tier generation

15 Break-Even Analysis

Scenario: 1,000 free users + 100 paying users

Monthly Costs

ItemMonthly
Claude API — paying users~$229
Claude API — free users~$850
ElevenLabs$5
OpenAI$1
Apple Dev$8.25
Total~$1,093/mo

Revenue Scenarios

ScenarioRevenueProfit
100 Home Baker~$600-$493
50 HB + 50 Chef~$1,200+$107
100 HB + 20 Chef~$960-$133
200 Home Baker~$1,200+$107
Key insight: Need ~170 Home Baker users OR healthy HB+Chef mix to cover 1,000 free users.
At 500 free users: Total cost ~$668/mo. Break-even at 112 Home Baker or 56 mixed.

16 Risks & Mitigations

RiskSeverityMitigation
RAG wrong pastry infoHIGHPrototype in Phase 0; 50 test queries; low temp (0.3); source attribution
Claude API cost spikeMEDIUMCredit system; rate limiting; email-required registration
Apple rejects RazorpayMEDIUMStoreKit for iOS; Razorpay Android+web only
KB incompleteMEDIUMPhase 0 dedicated; batch Whisper; Scoolinary already comprehensive
Timeline too aggressiveMEDIUMMVP ships in 6 weeks; validate before committing remaining 18

17 Launch Strategy

WeekMilestone
6Closed Alpha — 50 hand-picked students
10Open Beta — Email 20K students; target 2K signups
15Soft Launch — Payments enabled; beta users get 1 month free
20Mobile Launch — App Store + Play Store
24Full Launch — PR, referral program, Meta ads

18 Verification Plan

  • Run 50 diverse test queries across all 29 class days and Scoolinary sources
  • Verify chef attribution is correct (no misattributed quotes)
  • Check cosine similarity scores — ensure top results exceed 0.75 threshold
  • Test tier-based filtering — free users should not retrieve Scoolinary chunks
  • Validate chunk boundaries — no mid-sentence splits or orphaned technique steps
  • Confirm embedding count matches expected ~2,000 chunks
  • End-to-end course generation: topic input → streaming output → rendered chapters
  • Auth flow: register → login → JWT validation → protected routes
  • Rich renderer: all 6 component types display correctly (ChefTip, TechniqueTable, StorageCard, EquipmentCallout, BakersMathBlock, ChefsCornerSidebar)
  • Glossary: click term → side panel opens with correct definition
  • Baker's Toolkit: all 82 tools load in iframe/embed correctly
  • Mobile responsive: test on iPhone SE, iPhone 14 Pro, Pixel 7
  • Streaming performance: first token under 1s, full course under 30s
  • Quiz generation: all 3 types produce valid, answerable questions
  • Go Deeper: AI follow-ups are contextually relevant to current chapter
  • Daily Bake: new question appears each day; email capture triggers Brevo flow
  • Social sharing: WhatsApp deep link opens correctly with pre-filled message
  • Bookmarking: save, retrieve, and remove bookmarks across sessions
  • Sources panel: displays correct source count and attribution
  • Referral system: code generation, tracking, reward unlocks at correct thresholds
  • Anti-abuse: verify email requirement, first course completion, 7-day active check
  • Flash cards: SM-2 algorithm produces correct review intervals
  • Study guide: all 6 sections generate with relevant content
  • Practical exam: 12 questions, scoring, 80% pass threshold, badge award
  • Audio: script generation → TTS → concat produces playable audio
  • Razorpay: test payment in INR → subscription activates → tier upgrades
  • Stripe: test payment in USD → subscription activates → tier upgrades
  • Credit system: weekly reset fires correctly; limits enforced
  • Portal student: auto-detects portal status → upgrades to Chef tier
  • iOS: all core screens render correctly on iPhone SE through iPhone 15 Pro Max
  • Android: test on Pixel 7, Samsung Galaxy S23, budget device (e.g., Redmi)
  • Audio playback: background audio, lock screen controls, notification
  • Push notifications: daily bake reminder, referral event, new course ready
  • Deep linking: web URL opens correct screen in app
  • Offline: SQLite caches last-viewed course for offline reading
  • TestFlight: internal testers can install and use full flow
  • Play Store internal testing: APK installs and runs without crashes
  • Portal auth: student portal user can log into AI Mentor without re-registering
  • PDF export: Chef tier user exports course → formatted PDF downloads
  • Performance: Lighthouse score > 90 for performance, accessibility, SEO
  • Sentry: errors are captured and reported with correct source maps
  • Content pipeline: new transcript → auto-chunk → embed → available in RAG
  • Admin dashboard: user count, revenue, popular topics, error rate visible
  • Launch email: Brevo campaign sends to 20K list with correct links and tracking
  • Cross-sell: AI Mentor → Portal CTAs render; Portal → AI Mentor CTAs render
  • Load test: simulate 100 concurrent users generating courses without errors