Back to Projects

MealPlan AI Agent

AI-Powered Meal Planning

Overview

Full-stack AI meal planning platform built as a pnpm monorepo. NestJS handles business logic while a separate Python FastAPI service runs the AI brain — LangGraph StateGraph for meal generation, RAG pipeline with Qdrant for recipe retrieval, Langfuse for full LLM observability.

Key Features

  • LangGraph StateGraph with generation, validation, and diversity enforcement nodes
  • RAG pipeline with Qdrant vector DB and USDA nutritional validation
  • Real-time SSE streaming from Python → NestJS → Next.js
  • Langfuse integration for token/cost tracking, trace visualization, and prompt versioning
  • SEO-optimized with SSG/ISR for 95+ Lighthouse performance score
  • Stripe integration for subscription billing

Tech Stack

Backend

NestJSFastAPIPythonPostgreSQLBullMQPassport.js JWT

AI

LangGraphLangChainQdrantRAGOpenAI APILangfuseArize Phoenix

Frontend

Next.jsReactTypeScriptshadcn/uiSSR/SSG

Infrastructure

pnpm monorepoRailwayStripeDocker

Challenges & Solutions

Reliable AI Meal Generation

Problem

LLM outputs are non-deterministic — generated meals could have invalid nutritional data, duplicate recipes, or fail dietary constraints.

Solution

LangGraph StateGraph with dedicated nodes for generation, validation, and diversity enforcement. Each node validates structured output against schemas before passing to the next stage.

Real-Time Streaming Across Services

Problem

Meal generation takes 10-30s through the AI pipeline. Users need immediate feedback, but the response crosses 3 service boundaries (Python → NestJS → Next.js).

Solution

SSE streaming pipeline where Python FastAPI streams tokens to NestJS, which proxies them to the Next.js frontend. Users see meals being generated in real-time.

Recipe Retrieval Quality

Problem

Simple keyword search returned irrelevant recipes. Users with specific dietary needs (keto, vegan, allergen-free) got poor matches.

Solution

RAG pipeline with Qdrant vector DB for semantic recipe retrieval. USDA nutritional data validates macro targets. Retrieval quality improved significantly over keyword-based search.

Key Achievements

LangGraph
StateGraph with generation, validation, diversity enforcement nodes
RAG Pipeline
Qdrant vector DB + USDA nutritional validation
SSE Streaming
Real-time Python → NestJS → Next.js streaming
Langfuse
Token/cost tracking, trace visualization, prompt versioning