The current version is #ident "@(#)$Format:LocalFoodAI:app.py:%an:%ae:%ad:%cn:%ce:%cd:%H:%D:%N$"
This document describes the technical architecture, database schema design, AI RAG data flows, and dual-mode deployment topology for the Local Food AI clinical dietitian platform.
The platform is designed around a strictly local, privacy-first microservice topology. The components integrate seamlessly to provide nutritional search, RAG-augmented clinical diet evaluations, and DevSecOps observability.
graph TD
subgraph "Client Layer"
User["User Browser"]
end
subgraph "Application & Gateway Layer"
Nginx["Nginx Reverse Proxy\n(Port 80)"]
Streamlit["Streamlit Web App\n(Port 8502)"]
end
subgraph "Intelligence & RAG Layer"
Ollama["Ollama Engine\n(Mistral / Llama 3.2)\n(Port 11434)"]
SearXNG["SearXNG Anonymous Search\n(Port 8080)"]
end
subgraph "Database & Storage Layer"
MySQL["MySQL Database Server\n(Port 3307)"]
Alembic["Alembic Migrations"]
end
subgraph "Observability & Telemetry"
Zabbix["Zabbix Server & Web Dashboard\n(Ports 8081 / 10051)"]
SNMP["SNMPv3 Trap Agent"]
end
%% Connections
User -->|HTTP| Nginx
Nginx -->|Proxy Pass| Streamlit
Streamlit -->|Vector / Chat Queries| Ollama
Streamlit -->|Fallback Search| SearXNG
Streamlit -->|EAV & Core Queries| MySQL
Alembic -->|Database Schema| MySQL
Streamlit -->|Encrypted Telemetry Traps| SNMP
SNMP -->|SNMPv3 Traps| Zabbix
MySQL -->|Performance telemetry| Zabbix
To optimize massive dataset ingestion (~24GB OpenFoodFacts dataset) and completely bypass InnoDB row size limits while maintaining sub-second RAG response times, the database utilizes a vertically partitioned structure:
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Unified SQL View โ
โ "products" โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โproducts_core โ โ allergens โ โ macros โ
โ(Base/FULLTEXTโ โ(Ingredients) โ โ (Precision) โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
products_core: Contains product base information (barcode, name, brand, primary category) optimized with FULLTEXT indexing.products_allergens: Isolates complex ingredient list arrays and allergen keywords.products_macros: Implements double-precision floats (DOUBLE) for protein, carbs, fats, and energy metrics.products_vitamins: Stores micronutrient vitamin profiles.products_minerals: Stores trace mineral concentrations.[!NOTE] All application search queries, RAG data tools, and ingestion processes interact with a unified database
VIEWnamedproductswhich uses a series of high-performanceLEFT JOINoperations across the primary key (barcode), shielding the frontend from database complexity.
To ensure 100% resilience under network restrictions, the Local Food AI system is architected to operate under two distinct networking modes:
Services are distributed across specialized local hypervisors and Windows subsystems using bridged networking:
192.168.130.170.192.168.130.161 for syncing deliverables.When the remote VM host network or Taiga server is completely unreachable:
docker-compose.yml).localhost / custom Docker networks) rather than unreachable remote IPs, avoiding timeout hangs or crashes.Documented by Antigravity.