Prompt Engineering Β· RAG Β· OCR Β· Multi-Provider LLM Orchestration Β· Validation Β· Structured Outputs
NutriPrompt is an Applied AI system designed to transform structured user context into retrieved, validated, explainable and actionable workflows.
π TRY THE LIVE DEMO
Free Β· No login Β· No registration
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.
π 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.
A product-oriented dashboard exposes the different layers involved in the workflow.
The pipeline makes the orchestration visible instead of hiding everything behind a single generation call.
Structured AI output is transformed into a usable weekly plan rather than being returned as free-form model text.
Unstructured information from labels and documents can be transformed into structured signals for downstream analysis.
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.
| 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 |
ββββββββββββββββββββββ
β 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.
NutriPrompt implements a lightweight, domain-specific RAG pipeline over a curated nutrition knowledge base.
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:
- extracts relevant profile information;
- builds a retrieval query;
- scores nutrition rules against that query;
- retrieves the most relevant rules;
- constructs the RAG context;
- injects that context into the final prompt;
- generates a structured response.
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.
nutrition_rules.json
β
βΌ
knowledge_base.py
β
βΌ
retriever.py
β
βΌ
rag_context_builder.py
β
βΌ
prompt_builder.py
β
βΌ
Gemini / OpenAI
NutriPrompt does not blindly trust the first model response.
Three complementary layers help control generation.
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
Relevant rules are retrieved from the knowledge base and included in the model context.
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.
NutriPrompt abstracts generation from a single AI provider.
GEMINI
β
βΌ
GENERATE
β
βΌ
VALIDATE
β
ββββββββββ΄βββββββββ
β β
VALID INVALID
β β
β βΌ
β RETRY
β
β Provider failure
β β
β βΌ
β OPENAI FALLBACK
β β
β βΌ
ββββββββββββΊ VALIDATE
| Role | Provider |
|---|---|
| Primary LLM | Gemini 2.5 Flash |
| Fallback LLM | GPT-5 mini |
- 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.
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.
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.
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.
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?
| 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 |
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
Automated tests cover critical parts of the AI workflow.
- β 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 testCurrent status:
Ran 17 tests
OK
| 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 |
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.
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.
git clone https://github.com/beatriangu/NutriPrompt.git
cd NutriPromptpython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtpython manage.py runserverstreamlit run streamlit_demo/app.pyNutriPrompt 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.
I build at the intersection of:
My focus is turning Generative AI capabilities into structured, explainable and useful product workflows.
Applied AI Β· AI Product Β· Generative AI Engineering Β· AI Systems Β· Product & Technology
Building AI systems that retrieve, validate and deliver usable outcomes.



