TruffleNation.ai
AI Pastry Chef Mentor App — Complete Build Plan: Web + Android + iOS
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
| Layer | Choice | Reasoning |
|---|---|---|
| Web | Next.js 14 (App Router) | Matches Student Portal stack; SSR for SEO; streaming API routes |
| Mobile | Expo (React Native) | Shares TypeScript/types; native feel; EAS for store submission |
| Backend | Next.js API routes on VPS (PM2 + Nginx) | Same infra as Student Portal; no timeout limits |
| Database | PostgreSQL 16 on VPS (existing) | Already running; add pgvector extension |
| ORM | Prisma | Already used in Student Portal |
| Vector DB | pgvector (PostgreSQL extension) | No external service; SQL-based filtering |
| Embeddings | OpenAI text-embedding-3-small | $0.02/M tokens; one-time ~$0.02 |
| AI Generation | Claude Sonnet 4 (courses) + Haiku (quizzes, flash cards) | Sonnet for quality; Haiku 10-20x cheaper for lightweight |
| TTS | ElevenLabs | Two-voice conversational audio; $5/mo |
| Auth | JWT (jose + bcryptjs) | Same as Student Portal; shared DB |
| Payments | Razorpay (INR) + Stripe (USD) | Dual market; IP-based detection |
| File Storage | VPS filesystem → Cloudflare R2 (scale) | Start simple |
| Hosting | Hostinger VPS (existing) | $0 incremental; PM2 + Nginx |
| Brevo | Existing TN integration | |
| Monorepo | Turborepo | apps/web + apps/mobile + packages/shared |
• $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
- Embed user query with
text-embedding-3-small - Query pgvector with SQL WHERE for tier filtering
- Re-rank by cosine threshold > 0.75
- Assemble ~6,000 tokens of context
- 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)
07 Phase 2 — Learning + Engagement + Referrals (Weeks 7-10)
08 Phase 3 — Study Tools + Audio + Payments (Weeks 11-15)
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_tiercolumn - No cross-domain token dance needed — single domain, single database
- OAuth (future): Google + Apple
ai_tier column on the users table determines access level, and portal students are auto-upgraded to Chef tier.12 Pricing & Monetization
| Feature | Free | Home Baker (₹499/mo) | Chef (₹1,499/mo) |
|---|---|---|---|
| AI courses | 1/mo, 2 chapters | 10/week, unlimited | Unlimited |
| AI model | Sonnet | Sonnet | Sonnet |
| Glossary | Read-only | Full + interactive | Full + interactive |
| Go Deeper Q&A | 3/month | 50/day | Unlimited |
| Audio | No | Streaming | Streaming + download |
| Flash cards | No | Unlimited | Unlimited |
| Study guide | No | Yes | Yes |
| Practical exam | No | Yes | Yes + certificate |
| Baker's Toolkit | 5 tools | All 82 | All 82 |
| Daily Bake | Yes | Yes + archive | Yes + archive |
| Scoolinary | No | No | Yes |
| PDF export | No | No | Yes |
| Public sharing | No | No | Yes |
13 Referral System — "Invite a Baker"
Rewards Ladder
| Referrals | Unlock | What they get | Incremental cost |
|---|---|---|---|
| 0 | Base Free | 1 course/mo, 2 chapters, 3 Q&A/mo | $0.85/mo |
| 1 | +1 course | 2 courses/month | +$0.15/mo |
| 3 | +chapters +cards | Unlimited chapters + flash cards | +$0.05/mo |
| 5 | +study tools | Study guide + 10 Q&A/week | +$0.12/mo |
| 10 | Free Home Baker | Full tier for 1 month | ~$2.40 one-time |
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
14 Infrastructure Costs
Monthly Infrastructure
| Service | Monthly |
|---|---|
| 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
| Task | Model | Per call | Monthly volume | Cost |
|---|---|---|---|---|
| Course generation | Sonnet | ~$1.20 | ~100 (80% cache) | $120 |
| Go Deeper Q&A | Sonnet | ~$0.05 | ~2,000 | $100 |
| Quiz generation | Haiku | ~$0.008 | ~500 | $4 |
| Study guide | Haiku | ~$0.01 | ~300 | $3 |
| Flash cards | Haiku | ~$0.005 | ~400 | $2 |
| Daily Bake | Haiku | ~$0.003 | 30 | $0.09 |
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
| Item | Monthly |
|---|---|
| Claude API — paying users | ~$229 |
| Claude API — free users | ~$850 |
| ElevenLabs | $5 |
| OpenAI | $1 |
| Apple Dev | $8.25 |
| Total | ~$1,093/mo |
Revenue Scenarios
| Scenario | Revenue | Profit |
|---|---|---|
| 100 Home Baker | ~$600 | -$493 |
| 50 HB + 50 Chef | ~$1,200 | +$107 |
| 100 HB + 20 Chef | ~$960 | -$133 |
| 200 Home Baker | ~$1,200 | +$107 |
16 Risks & Mitigations
| Risk | Severity | Mitigation |
|---|---|---|
| RAG wrong pastry info | HIGH | Prototype in Phase 0; 50 test queries; low temp (0.3); source attribution |
| Claude API cost spike | MEDIUM | Credit system; rate limiting; email-required registration |
| Apple rejects Razorpay | MEDIUM | StoreKit for iOS; Razorpay Android+web only |
| KB incomplete | MEDIUM | Phase 0 dedicated; batch Whisper; Scoolinary already comprehensive |
| Timeline too aggressive | MEDIUM | MVP ships in 6 weeks; validate before committing remaining 18 |
17 Launch Strategy
| Week | Milestone |
|---|---|
| 6 | Closed Alpha — 50 hand-picked students |
| 10 | Open Beta — Email 20K students; target 2K signups |
| 15 | Soft Launch — Payments enabled; beta users get 1 month free |
| 20 | Mobile Launch — App Store + Play Store |
| 24 | Full 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