NutriLens AI
Multimodal vision nutrition & clinical metabolic intelligence mobile engine.

Secure multi-session authentication with credential caching and partitioned profile binding
System Overview & Engineering Longevity
A full-stack cross-platform mobile intelligence engine built with React Native and Expo SDK 54, integrating multimodal AI vision, zero-latency grocery barcode scanning, and dynamic Mifflin-St Jeor metabolic expenditure calculations. Designed to eliminate calorie logging friction, NutriLens routes in-memory Base64 image buffers through OpenRouter with an automated offline heuristic dataset fallback. Daily caloric expenditure, BMR, and TDEE adapt dynamically to activity levels and goal pacing, while an embedded clinical nutrition AI coach analyzes real-time daily intake to provide actionable dietary guidance without syntax clutter.
Key Engineering Highlights
Architected with clean domain separation, strict TypeScript contracts, and automated telemetry logging.
Vision Inference Latency
End-to-end photo capture to itemized meal segmentation and macro breakdown.
Grocery Barcode Database
Instant OpenFoodFacts lookup across global UPC, EAN-8, and EAN-13 barcodes.
Offline Availability
Guaranteed heuristic dataset fallback during connectivity interruptions.
Filesystem Cache Overhead
Direct in-memory Base64 streaming bypassing temporary storage writes.
End-to-End System Data Flow
How user inputs, computer vision pipelines, and transaction protocols flow across the stack.
In-Memory Image Ingestion
Camera or gallery captures photo with direct base64: true buffer generation, bypassing local disk I/O and eliminating file latency.
OpenRouter Vision Routing
Multimodal payload dispatches to AI vision models, with automated circuit-breaker fallback to local clinical dataset if network drops.
Segmented Nutrition Normalization
AI-detected food items and portion weights are normalized into standard grams, caloric values, and precise P/C/F splits.
Mifflin-St Jeor Budget Validation
Metabolic engine computes meal impact against dynamic BMR/TDEE targets, updating remaining budget and surplus warning states.
Zustand & Cloud State Synchronization
Meal draft commits to Zustand reactive store and synchronously syncs to Firebase Realtime Database under partitioned user path.
System Capabilities & 6+ Functional Modules
Multimodal AI Food Vision
In-memory image capture and segmentation pipeline converting plate photography into structured macronutrient telemetry without intermediate disk I/O.
Zero-Latency Barcode Scanner
High-throughput barcode scanning engine utilizing native camera sensors to identify packaged grocery items and fetch official nutrition facts.
Mifflin-St Jeor Physics Engine
Clinically validated mathematical engine computing exact Basal Metabolic Rate and Total Daily Energy Expenditure based on dynamic biometrics.
Clinical AI Nutritionist Coach
Goal-oriented clinical sports nutrition assistant injecting real-time metabolic context into every query for highly targeted dietary advice.
90-Day Compliance & Trajectory
Long-term metabolic adherence engine visualizing adherence trends, caloric trajectories, and multi-week macro distribution splits.
Reactive State & Cloud Isolation
Zustand 5 reactive store architecture combined with strictly partitioned Firebase Realtime Database isolation.
Key Engineering Bottlenecks & Solutions
Memory Leaks and Navigation Race Conditions in Legacy Event Emitters
Migrated the entire global event bus (EventRegister) to Zustand v5 reactive stores (useMealDraftStore, useUserStore). State updates became synchronous, predictable, and cleanly bound to React component lifecycles without dangling unmount listeners.
Filesystem I/O Latency in Mobile Camera Capture
Configured CameraView.takePictureAsync and ImagePicker with direct base64: true in-memory buffers. This eliminated intermediate file system cache reads/writes, avoided deprecated Expo SDK 54 file-system APIs, and cut vision payload dispatch time by over 400ms.
API Rate Limits and Offline Single-Point-of-Failure
Engineered a dual-layer resilience architecture. If OpenRouter returns HTTP 429 or network timeouts occur, the ingestion pipeline immediately routes to a bundled 180KB verified clinical nutrition dataset, ensuring users can always log meals.
Unstyled Markdown Syntax Clutter in Native Mobile UI
Built a lightweight regex-based cleanMarkdownText sanitizer in lib/ai.ts that strips markdown asterisks, bold/italic markers, and hash headers while preserving native line breaks and list bullets, delivering clean native mobile typography.
FinGo Marketplace
Multi-vendor commerce platform with role-based merchant operations.