An intelligent nutrition search and recommendation system for Smoothie King menu items, powered by advanced RAG (Retrieval-Augmented Generation) architecture with FDA-compliant nutrition visualization.
BlendIntel Core transforms natural language nutrition queries into personalized smoothie recommendations by combining vector search, semantic reranking, and conversational AI. Users can type questions like "What's a high-protein smoothie with strawberries?" and receive accurate, context-aware suggestions with complete nutritional information displayed in familiar FDA nutrition label format.
- Pixel-Perfect Rendering: Professionally formatted nutrition facts display
- Size-Aware Display: Shows nutrition for selected serving size (20oz, 32oz, 44oz)
- Visual Impact: Instantly recognizable format builds user trust
- Vector Embeddings: OpenAI's
text-embedding-3-small(512 dimensions) converts menu items into semantic representations - Pinecone Vector Database: Stores and queries 300+ smoothie embeddings for lightning-fast similarity search
- Rich Metadata: Each vector includes nutrition facts, allergens, ingredients, and available sizes
- Two-Stage Retrieval: Initial vector search retrieves 30 candidates, then BGE-Reranker-v2-m3 reranks for precision
- Cross-Encoder Model: Deeply analyzes query-document pairs for superior relevance vs. pure vector similarity
- Context-Aware: Understands multi-constraint queries ("45g protein AND strawberries AND under 400 calories")
- GPT-3.5 Turbo: Generates natural language explanations for recommendations
- Nutrition-Focused: Highlights protein content, macros, allergens, and portion sizes
- Top 5 Alternatives: Provides options for dietary restrictions and preferences
- URL State Persistence: Share search results via unique URLs
- Auto-Search from URLs: Recipients see results instantly
- Category Filtering: Browse by smoothies, bowls, or power eats
User Input (Text)
โ
[OpenAI Embeddings] โ Query Vector (512d)
โ
[Pinecone Search] โ Top 30 Candidates (vector similarity)
โ
[BGE Reranker] โ Top 10 Results (relevance scoring)
โ
[GPT-3.5 Turbo] โ Natural Language Response
โ
Frontend Display:
- AI Conversational Response
- Top Recommendation Card
- Expandable Alternatives
- Collapsible Ingredients
- Share Functionality
1. User types โ "High protein smoothie with strawberries"
2. Category filter (optional) โ Smoothies
3. RAG pipeline processes โ Gladiatorยฎ Strawberry found
4. Display results:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI: "Perfect choice! The โ
โ Gladiatorยฎ Strawberry has โ
โ exactly 45g of protein..." โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Top Recommendation โ
โ โ
โ Gladiatorยฎ Strawberry โ
โ Calories: 220 | Protein: 45g โ
โ Carbs: 3g | Fat: 3g โ
โ โ
โ ๐ฅฃ Ingredients (12) โ
โ [Expand to view] โ
โ โ
โ ๐ Share results โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
5. User clicks share โ URL copied to clipboard
6. Share with friend โ Auto-loads same results
- Scraped 100+ Smoothie King menu items with complete nutrition profiles
- Extracted size variations, ingredients, allergens, and macros
node scripts/embed.js
# โ Generates embeddings for all smoothies
# โ Output: smoothies_vectors.json, ingredients_vectors.json, etc.node scripts/upload-to-pinecone.js
# โ Sanitizes metadata (flattens nested objects)
# โ Chunks uploads (100 vectors/batch)
# โ Creates index if neededRequest:
{
"query": "What is a Smoothie with 45 protein and strawberries",
"topK": 10,
"category": "smoothies"
}Response:
{
"query": "...",
"category": "smoothies",
"topRecommendation": {
"id": "smoothies_27",
"name": "Gladiatorยฎ Strawberry",
"nutrition_protein": 45,
"nutrition_calories": 220,
"nutrition_carbs": 3,
"nutrition_fat": 3,
"nutrition_sugar": 1,
"nutrition_fiber": 1,
"allergens": ["Egg", "Milk"],
"ingredients": ["Strawberries", "Protein Blend", ...],
"availableSizes": ["small(20 oz)", "medium(32 oz)", "large(44 oz)"],
"nutritionSize": "medium(32 oz)"
},
"topFive": [ ... ],
"allResults": [ ... ],
"aiResponse": "Great choice! The Gladiatorยฎ Strawberry is perfect for your request with exactly 45g of protein...",
"total": 10,
"reranked": true
}| Component | Technology | Purpose |
|---|---|---|
| Framework | Next.js 15 (App Router) | Full-stack React framework |
| Frontend | React + TypeScript | Type-safe UI components |
| Styling | Tailwind CSS | Responsive, utility-first styling |
| Vector DB | Pinecone (Serverless) | Semantic search at scale |
| Embeddings | OpenAI text-embedding-3-small | 512d vectors, $0.00002/1K tokens |
| Reranker | Pinecone Inference (bge-reranker-v2-m3) | Precision relevance scoring |
| LLM | OpenAI GPT-3.5 Turbo | Natural language responses |
| Analytics | Vercel Analytics | Search tracking & insights |
| Language | TypeScript/JavaScript | Type-safe development |
| Query | Category | Top Result | Why It Works |
|---|---|---|---|
| "45g protein with strawberries" | All | Gladiatorยฎ Strawberry (45g) | Exact protein match + ingredient |
| "Low calorie high protein" | Smoothies | Original High Protein Banana (330 cal, 27g) | Optimizes both constraints |
| "Something for after the gym" | All | The Activatorยฎ Recovery | Context-aware (post-workout) |
| "Nut-free option under 300 calories" | Power Eats | Power Punch Plusยฎ (280 cal) | Allergen exclusion + calorie filter |
- โ Chat-style conversational UI
- โ Category filtering (all, smoothies, bowls, power-eats)
- โ URL state persistence for sharing
- โ Auto-search from shared URLs
- โ Loading states with animations
- โ Empty state with category suggestions
- โ Error handling with friendly messages
- โ AI-generated explanation with bold markdown support
- โ Top recommendation with nutrition grid
- โ Category badges with color coding
- โ Allergen warnings
- โ Collapsible ingredients section
- โ Share button (Web Share API + clipboard)
- โ Expandable alternatives (show top 5)
- โ Responsive design (mobile-first)
# OpenAI API
OPENAI_API_KEY=your_openai_key_here
# Pinecone Vector Database
PINECONE_API_KEY=your_pinecone_key_here
PINECONE_INDEX_NAME=nutrition-information- OpenAI: platform.openai.com
- Pinecone: app.pinecone.io
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Add your API keys to .env
# Generate embeddings (one-time setup)
node scripts/embed.js
# Upload to Pinecone (one-time setup)
node scripts/upload-to-pinecone.js
# Start development server
npm run dev
# Open http://localhost:3000/searchText Search:
curl -X POST http://localhost:3000/api/nutritionSearchRerank \
-H "Content-Type: application/json" \
-d '{"query":"high protein smoothie","topK":10,"category":"smoothies"}'# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod
# Set environment variables in Vercel dashboard- Add all API keys to Vercel project settings
- Ensure Pinecone index is created and populated
- Verify rate limiting is working (10 requests/hour per IP)
- Limit: 10 searches per hour per IP address
- Purpose: Protect OpenAI API costs during demo
- Implementation: In-memory rate limiter with automatic cleanup
- User Experience: Friendly error message with retry time
This project demonstrates:
- โ Production RAG architecture (retrieve โ rerank โ generate)
- โ Vector database optimization (metadata sanitization, chunking)
- โ Multi-model orchestration (embeddings + reranker + LLM)
- โ Cost-effective AI (strategic model selection)
- โ Real-world data pipeline (scraping โ embedding โ indexing)
- โ Rate limiting & cost protection
- โ Chat-style conversational interface
- โ Responsive, mobile-first design
- โ Real-time user feedback (loading states, animations)
- โ URL state management for sharing
- โ Progressive disclosure (collapsible sections)
- โ Markdown parsing for rich text formatting
- โ Next.js 15 App Router patterns
- โ TypeScript type safety across stack
- โ API route design for AI services
- โ Server-side rate limiting
- โ Analytics integration
- โ Error handling & user feedback
- Spanish Language Support: Bilingual UI and query translation for Hispanic customers
- Nutrition-Based Filtering: Client-side filters for calories, protein, carbs, allergens
- User Preferences: Save favorite searches and dietary restrictions
- Comparison Mode: Side-by-side nutrition comparison of multiple items
- Enhanced Analytics: Track popular queries, category preferences, conversion metrics
- Caching Layer: Redis for frequently searched queries
- Component Refactoring: Break down large components for better maintainability
- Spanish embeddings index for better multilingual search
- Advanced reranking with nutrition-aware scoring
- Progressive Web App (PWA) capabilities
- Offline mode with cached results
- A/B testing framework for search quality
- Comprehensive unit and integration tests
- Lines of Code: 6,353 (smoothies.json)
- Menu Items: 300+
- Categories: 3 (Smoothies, Bowls, Power Eats)
- Nutrition Fields: 6 per item (calories, protein, carbs, fat, sugar, fiber)
- Vector Dimensions: 512
- Average Search Latency: ~2-3 seconds (embedding + vector search + rerank + GPT)
MIT
BlendIntel uses a modular component architecture with centralized state management for maintainability and scalability.
src/app/search/components/
โโโ layout/ # Page structure (header, filter, input)
โโโ states/ # Loading, error, empty states
โโโ messages/ # Chat interface components
โโโ results/ # Search result display
โโโ shared/ # Reusable UI components
Context API (SearchContext) manages:
- Search query and results
- Loading/error states
- Category selection
- UI state (expanded items, show all results)
Props for pure display components:
NutritionGrid,AllergenBadges,CategoryBadge- Better testability and reusability
- Determine if state comes from Context or Props
- Create component in appropriate directory
- Add to barrel export (
index.ts) - Import and use in parent component
Built with โค๏ธ for nutrition-conscious smoothie lovers
Combining the power of RAG, semantic search, and thoughtful UX design to make healthy choices effortless.