Skip to content

Latest commit

Β 

History

58 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯¦ NutriPrompt

Applied AI Β· From structured context to validated, explainable outcomes

Prompt Engineering Β· RAG Β· OCR Β· Multi-Provider LLM Orchestration Β· Validation Β· Structured Outputs


Python Django Streamlit Gemini OpenAI RAG Tests


NutriPrompt is an Applied AI system designed to transform structured user context into retrieved, validated, explainable and actionable workflows.


Free Β· No login Β· No registration


Live Demo Β· Portfolio Β· LinkedIn


✨ Overview

NutriPrompt is not simply a meal-plan generator.

It is a production-minded Applied AI / AI Systems Engineering project built to explore a more interesting question:

How do you turn an LLM into a reliable product workflow?

Instead of sending raw user input directly to a model, NutriPrompt builds a controlled pipeline around generation:

structured input β†’ retrieval β†’ context construction β†’ LLM generation β†’ validation β†’ actionable output

The system combines:

  • 🧠 structured Prompt Engineering
  • πŸ“š domain-specific Retrieval-Augmented Generation (RAG)
  • πŸ‘οΈ OCR and ingredient intelligence
  • πŸ›‘οΈ deterministic validation
  • πŸ”„ multi-provider LLM orchestration
  • πŸ“¦ structured JSON outputs
  • πŸ›’ shopping intelligence
  • πŸ“„ HTML / PDF generation
  • πŸ’¬ user-facing AI explanations
  • πŸ§ͺ automated testing

The nutrition domain provides a practical use case.

The engineering pattern is designed to be reusable.


πŸš€ Live Technical Demo

Explore the complete AI workflow

πŸ‘‰ nutriprompt-live.streamlit.app

No account required. Just open it and test the workflow.

The public Streamlit demo lets you:

Capability
πŸ“ Create a structured user profile
πŸ“š Inspect retrieved RAG context
🧠 Explore the AI generation pipeline
πŸ‘οΈ Analyze labels/documents through OCR
πŸ›‘οΈ Review validation results
πŸ’¬ Interact with the AI Copilot
πŸ›’ Generate a shopping list
πŸ“„ Download the resulting weekly PDF

Why Streamlit?
The public demo is intentionally separated from the main Django application so the AI workflow can be explored quickly and interactively without requiring access to the complete product environment.


πŸ“Έ Product Walkthrough

01 Β· AI System Overview

A product-oriented dashboard exposes the different layers involved in the workflow.

NutriPrompt AI Dashboard


02 Β· AI Workflow Pipeline

The pipeline makes the orchestration visible instead of hiding everything behind a single generation call.

NutriPrompt AI Pipeline


03 Β· Generated Plan

Structured AI output is transformed into a usable weekly plan rather than being returned as free-form model text.

NutriPrompt Generated Plan


04 Β· OCR & Ingredient Intelligence

Unstructured information from labels and documents can be transformed into structured signals for downstream analysis.

NutriPrompt Vision


🎯 The Engineering Problem

Generating text with an LLM is easy.

Building a useful AI product around it is not.

A reliable AI workflow needs to answer questions such as:

  • What information should reach the model?
  • Which domain knowledge should be retrieved?
  • Which constraints should be deterministic?
  • How should model output be structured?
  • How do we detect invalid recommendations?
  • What happens when the primary AI provider fails?
  • How can the workflow remain observable to the user?
  • How do we transform generation into an actionable outcome?

NutriPrompt explores those problems through a concrete product workflow.

The objective is not simply:

Generate a meal plan.

The objective is:

Combine domain knowledge, business rules, retrieval, validation and Generative AI into a controlled software system.


🧠 AI Engineering Capabilities

Capability Implementation
Prompt Engineering Structured user context and controlled prompt construction
RAG Domain-specific retrieval from a curated nutrition knowledge base
Knowledge Grounding Relevant retrieved rules injected before inference
LLM Orchestration Gemini primary provider + OpenAI fallback
Structured Generation JSON-based AI outputs
Validation Deterministic checks before accepting generated plans
Corrective Retry Regeneration when validation detects an invalid result
OCR Extraction of information from labels and documents
Compatibility Analysis Rule-based checks against user restrictions
Shopping Intelligence Recommendations transformed into execution-oriented outputs
Explainability User-facing context, validation and recommendation explanations
Resilience Provider abstraction and graceful fallback
Observability Technical dashboard and interactive Streamlit demo

πŸ—οΈ System Architecture

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚     USER INPUT     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ STRUCTURED INTAKE  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚  PROFILE ANALYSIS  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ RAG QUERY BUILDER  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ DOMAIN KNOWLEDGE RETRIEVAL β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   PROMPT BUILDER   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚       GEMINI       β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ OUTPUT VALIDATION  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                             β”‚
                  VALID                         INVALID
                    β”‚                             β”‚
                    β”‚                             β–Ό
                    β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                    β”‚ CORRECTIVE RETRY β”‚
                    β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                             β”‚
                    β”‚                      Provider failure
                    β”‚                             β”‚
                    β”‚                             β–Ό
                    β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                    β”‚ OPENAI FALLBACK  β”‚
                    β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                             β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚  STRUCTURED JSON   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ RULES + COMPATIBILITY      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ SHOPPING INTELLIGENCE      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ PRESENTATION LAYER β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β–Ό          β–Ό          β–Ό
                      HTML        PDF      COPILOT

The architecture separates five major concerns:

Input β†’ Retrieval β†’ Generation β†’ Validation β†’ Presentation

This separation keeps the system modular, testable and easier to evolve.


πŸ“š Retrieval-Augmented Generation

NutriPrompt implements a lightweight, domain-specific RAG pipeline over a curated nutrition knowledge base.

Retrieval flow

User Profile
     β”‚
     β–Ό
RAG Query Builder
     β”‚
     β–Ό
Nutrition Knowledge Base
     β”‚
     β–Ό
Rule / Keyword Scoring
     β”‚
     β–Ό
Top-K Relevant Rules
     β”‚
     β–Ό
Retrieved Context
     β”‚
     β–Ό
Prompt Augmentation
     β”‚
     β–Ό
LLM Generation

For every request, the system:

  1. extracts relevant profile information;
  2. builds a retrieval query;
  3. scores nutrition rules against that query;
  4. retrieves the most relevant rules;
  5. constructs the RAG context;
  6. injects that context into the final prompt;
  7. generates a structured response.

Why lexical retrieval?

The current implementation uses rule-based / keyword-scored retrieval, rather than presenting a vector database as something the project does not yet require.

This keeps retrieval:

  • transparent
  • inspectable
  • deterministic
  • easy to debug
  • independently testable

The architecture allows this retriever to be replaced later by semantic retrieval without redesigning the complete AI workflow.

RAG modules

nutrition_rules.json
        β”‚
        β–Ό
knowledge_base.py
        β”‚
        β–Ό
retriever.py
        β”‚
        β–Ό
rag_context_builder.py
        β”‚
        β–Ό
prompt_builder.py
        β”‚
        β–Ό
Gemini / OpenAI

πŸ›‘οΈ Validation-First AI

NutriPrompt does not blindly trust the first model response.

Three complementary layers help control generation.

1 Β· Structured input interpretation

Explicit user constraints are identified before inference.

Examples include:

  • vegetarian / vegan preferences
  • gluten restrictions
  • lactose restrictions
  • low-FODMAP context
  • budget constraints
  • cooking access
  • tupper requirements
  • lifestyle context

2 Β· Retrieved domain knowledge

Relevant rules are retrieved from the knowledge base and included in the model context.

3 Β· Post-generation validation

Generated plans are parsed and validated before being accepted.

GENERATE
    β”‚
    β–Ό
  PARSE
    β”‚
    β–Ό
 VALIDATE
    β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€ VALID ────────► ACCEPT
    β”‚
    └──────── INVALID
                 β”‚
                 β–Ό
         CORRECTIVE PROMPT
                 β”‚
                 β–Ό
               RETRY

If validation fails, the corrective workflow can include:

  • the validation error
  • the previous invalid output
  • the original user context
  • the retrieved RAG context

The objective is not to claim that hallucinations can be eliminated.

The objective is to reduce inconsistent outputs and detect constraint violations before presenting results to the user.


πŸ”„ Multi-Provider LLM Orchestration

NutriPrompt abstracts generation from a single AI provider.

              GEMINI
                 β”‚
                 β–Ό
              GENERATE
                 β”‚
                 β–Ό
              VALIDATE
                 β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                 β”‚
      VALID             INVALID
        β”‚                 β”‚
        β”‚                 β–Ό
        β”‚               RETRY
        β”‚
        β”‚          Provider failure
        β”‚                 β”‚
        β”‚                 β–Ό
        β”‚          OPENAI FALLBACK
        β”‚                 β”‚
        β”‚                 β–Ό
        └──────────►   VALIDATE

Current configuration

Role Provider
Primary LLM Gemini 2.5 Flash
Fallback LLM GPT-5 mini

Why this matters

  • reduced provider dependency
  • graceful degradation
  • provider abstraction
  • consistent validation across providers
  • more resilient demonstrations

Important: this is multi-provider LLM orchestration, not a multi-agent architecture.


πŸ‘οΈ OCR + Ingredient Intelligence

NutriPrompt also explores workflows where unstructured information becomes structured product context.

The Vision/OCR layer can process:

  • food labels
  • ingredient lists
  • nutrition documents
  • product images
IMAGE / DOCUMENT
        β”‚
        β–Ό
 OCR EXTRACTION
        β”‚
        β–Ό
TEXT NORMALIZATION
        β”‚
        β–Ό
INGREDIENT DETECTION
        β”‚
        β–Ό
COMPATIBILITY RULES
        β”‚
        β–Ό
STRUCTURED INSIGHT

Extracted information can then participate in the same compatibility and validation workflow as structured user data.

NutriPrompt OCR


πŸ’¬ Explainable & Observable AI

A useful AI product should not simply return an answer.

NutriPrompt exposes relevant parts of its workflow so users and technical reviewers can inspect:

  • interpreted profile context
  • retrieved domain knowledge
  • applied restrictions
  • validation results
  • generated recommendations
  • contextual explanations through the Copilot
  • system architecture through the technical dashboard

The objective is observable AI behaviour and user-facing explanations, not disclosure of private model chain-of-thought.


πŸ›’ From Generation to Action

The workflow does not stop when the LLM returns text.

NutriPrompt transforms model output into practical artifacts:

AI GENERATION
      β”‚
      β–Ό
STRUCTURED PLAN
      β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β–Ί Weekly planning
      β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β–Ί Shopping list
      β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β–Ί Compatibility review
      β”‚
      └────────► Downloadable PDF

This reflects a product principle behind the project:

Useful AI should help users act, not just generate text.


🌍 Beyond Nutrition

Nutrition is the demonstration domain.

The underlying architecture represents a reusable pattern:

STRUCTURED INPUT
       β”‚
       β–Ό
DOMAIN KNOWLEDGE
       β”‚
       β–Ό
    RETRIEVAL
       β”‚
       β–Ό
CONTROLLED GENERATION
       β”‚
       β–Ό
   VALIDATION
       β”‚
       β–Ό
ACTIONABLE OUTPUT

Similar patterns can be explored in domains such as:

  • document analysis
  • internal knowledge assistants
  • compliance workflows
  • customer-support copilots
  • procurement
  • education
  • operations
  • decision-support systems

The transferable engineering question is:

How can domain knowledge, business constraints and Generative AI work together without blindly trusting the model?


βš™οΈ Technology Stack

Layer Technology
Backend Django 5.x
Language Python 3.13
Primary LLM Gemini 2.5 Flash
LLM Fallback GPT-5 mini
Retrieval Custom domain-specific RAG
Knowledge Base Structured JSON
Retrieval Strategy Rule / keyword relevance scoring
OCR Tesseract OCR
AI Output Structured JSON
PDF Rendering WeasyPrint
Frontend HTML + CSS
Public Demo Streamlit
Testing Django Test Framework

πŸ“ AI Service Architecture

nutriprompt_app/
β”‚
└── services/
    β”‚
    β”œβ”€β”€ ai/
    β”‚   β”œβ”€β”€ ai_generator.py
    β”‚   β”œβ”€β”€ gemini_client.py
    β”‚   β”œβ”€β”€ openai_client.py
    β”‚   β”œβ”€β”€ prompt_builder.py
    β”‚   β”œβ”€β”€ json_parser.py
    β”‚   β”œβ”€β”€ validator.py
    β”‚   └── rules.py
    β”‚
    β”œβ”€β”€ rag/
    β”‚   β”œβ”€β”€ knowledge_base.py
    β”‚   β”œβ”€β”€ retriever.py
    β”‚   β”œβ”€β”€ rag_context_builder.py
    β”‚   └── embeddings.py
    β”‚
    β”œβ”€β”€ profiles/
    β”‚   └── profile_classifier.py
    β”‚
    β”œβ”€β”€ vision/
    β”‚   β”œβ”€β”€ label_reader.py
    β”‚   β”œβ”€β”€ compatibility_analyzer.py
    β”‚   β”œβ”€β”€ nutrition_risk_rules.py
    β”‚   └── vision_analyzer.py
    β”‚
    └── nutrition/
        β”œβ”€β”€ meal_rules.py
        β”œβ”€β”€ fallback_plan.py
        └── shopping_list_generator.py

The service-oriented design separates:

retrieval Β· inference Β· validation Β· vision Β· domain logic Β· presentation


πŸ§ͺ Testing & Quality

Automated tests cover critical parts of the AI workflow.

Current coverage

  • βœ… knowledge-base loading
  • βœ… rule serialization
  • βœ… RAG retrieval
  • βœ… low-FODMAP retrieval
  • βœ… gluten-related retrieval
  • βœ… RAG context construction
  • βœ… prompt enrichment
  • βœ… AI output parsing
  • βœ… validation
  • βœ… compatibility analysis
  • βœ… fallback behaviour
  • βœ… structured outputs
  • βœ… shopping generation

Run the complete suite:

python manage.py test

Current status:

Ran 17 tests

OK

βœ… 17 automated tests passing


⚑ Engineering Principles

Principle Approach
🧠 Context before generation
πŸ“š Retrieval before inference
πŸ›‘οΈ Validation over blind trust
πŸ“¦ Structured outputs over free-form text
πŸ”„ Provider abstraction over vendor dependency
🧩 Modular services over monolithic AI functions
πŸ”Ž Observable workflows over black-box experiences
πŸš€ Products over isolated prompts

πŸ’Ό What This Project Demonstrates

From an engineering and product perspective, NutriPrompt demonstrates practical work across:

Generative AI

Prompt design, context construction, structured generation and provider integration.

RAG

Knowledge-base design, retrieval, context injection and modular retrieval architecture.

Software Engineering

Django, service separation, validation, testing, fallback strategies and structured outputs.

AI Product

User workflows, explainability, actionable outputs and public technical demonstration.

Business Logic

Turning domain restrictions and user requirements into deterministic system constraints.


πŸ—ΊοΈ Technical Roadmap

The current implementation intentionally prioritizes a transparent and testable architecture.

Potential next iterations include:

  • semantic retrieval with embeddings
  • vector similarity search
  • configurable Top-K retrieval
  • retrieval evaluation metrics
  • source provenance / attribution
  • richer knowledge ingestion
  • automated RAG quality evaluation
  • enhanced observability
  • CI/CD quality gates
  • API-first deployment
  • agentic tool orchestration where it adds real value

The modular architecture allows retrieval and provider strategies to evolve without rebuilding the complete application.


πŸ› οΈ Local Setup

1 Β· Clone the repository

git clone https://github.com/beatriangu/NutriPrompt.git
cd NutriPrompt

2 Β· Create the environment

python3 -m venv venv
source venv/bin/activate

3 Β· Install dependencies

pip install -r requirements.txt

4 Β· Run Django

python manage.py runserver

5 Β· Run the Streamlit technical demo

streamlit run streamlit_demo/app.py

⚠️ Disclaimer

NutriPrompt is an Applied AI technical demonstration.

It provides informational and organizational guidance only.

It does not replace professional medical, nutritional or healthcare advice.

People with medical conditions, persistent symptoms, allergies or complex dietary requirements should consult qualified healthcare or nutrition professionals.


πŸ‘©β€πŸ’» About the Author

Bea Lamiquiz

I build at the intersection of:

AI Β· Product Β· Data Β· Business Logic Β· Software Engineering

My focus is turning Generative AI capabilities into structured, explainable and useful product workflows.


Portfolio GitHub LinkedIn


Interested in

Applied AI Β· AI Product Β· Generative AI Engineering Β· AI Systems Β· Product & Technology


From prompts to products.

Building AI systems that retrieve, validate and deliver usable outcomes.

Releases

Packages

Contributors

Languages