Back to Projects

MealPlan AI Agent

AI-Powered Meal Planning

Overview

NestJS + Python FastAPI dual-service backend with PostgreSQL, BullMQ job queues, and Passport.js JWT auth. SSE streaming pipeline proxies real-time AI responses across 3 service boundaries. Stripe integration handles subscription billing.

Key Features

  • NestJS + Python FastAPI dual-service architecture in pnpm monorepo
  • PostgreSQL database with BullMQ job queues for async processing
  • SSE streaming pipeline proxying real-time AI responses across 3 service boundaries
  • Passport.js JWT authentication with refresh tokens
  • Stripe subscription billing with webhook integration
  • Railway deployment with Docker containers

Tech Stack

Backend

NestJSFastAPIPythonPostgreSQLBullMQPassport.js JWT

Infrastructure

pnpm monorepoRailwayStripeDocker

AI

LangGraphLangChainQdrantRAGOpenAI APILangfuseArize Phoenix

Frontend

Next.jsReactTypeScriptshadcn/uiSSR/SSG

Challenges & Solutions

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.

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.

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

Dual-Service
NestJS + Python FastAPI with clean service boundaries
SSE Streaming
Real-time pipeline across 3 service boundaries
BullMQ
Async job processing with PostgreSQL persistence
Stripe
Subscription billing with webhook integration