PROJECT_CONTEXT.md 3.3 KB

Project Context: Local Food AI

🎯 Vision Statement

A strictly local, privacy-first Food AI that acts as a clinical dietitian. It provides complete nutritional analysis, recipe formulation, and menu planning based on dynamic user health profiles (e.g., pregnancy, kidney disease, specific diets). No user data leaves the server.

🏗️ Architecture & Tech Stack

  • Server Environment: Ubuntu 24.04 VM (192.168.130.170).
  • Containerization: Docker & Kubernetes scripts available in docker/ and k8s/.
  • LLM Engine: Ollama running locally (mistral:latest).
  • Database: MySQL 8.0 with mysql_config_editor login paths (app_reader, app_auth).
  • Frontend Web Interface: Streamlit (app.py).

💾 Database Design: Grouped Vertical Partitioning

To bypass InnoDB row limits and optimize for massive data ingestion (~24GB OpenFoodFacts), the database is vertically partitioned:

  1. products_core (Base data, FULLTEXT indexing)
  2. products_allergens
  3. products_macros (Strict DOUBLE datatypes)
  4. products_vitamins
  5. products_minerals

CRITICAL NOTE: The frontend and AI RAG tools interact with a unified VIEW named products that elegantly LEFT JOINs these partitions.

🧠 AI Capabilities & RAG Tools

The Ollama mistral model is fully integrated with Streamlit using Tool Calling:

  • Tool: search_nutrition_db. The AI can autonomously execute SQL queries against the local database to pull exact nutritional macros.
  • Tool: local_web_search. The AI can anonymously search the web if the DB lacks recipe ideas.
  • Dynamic Profiling: The Streamlit app extracts the user's EAV health profile and securely injects it into the AI's sys_prompt. The AI dynamically acts as a specialized dietitian for that precise condition (e.g., automatically flagging raw meats as forbidden for pregnancy).

🚀 Key Features

  1. Dynamic Tabular Analytics: In the Clinical Search tab, users can click "Ask AI to Evaluate This Table" to grade database rows against their specific illnesses/diets.
  2. Plate Builder & Unit Converter: unit_converter.py parses natural language strings (e.g., "1.5 cups") and converts them to metric grams based on product density.
  3. AI Meal Planner: Multi-turn RAG loop where the AI queries the database for verified foods before outputting a strict Markdown menu table.
  4. Enterprise Monitoring (Zabbix & SNMPv3): A Zabbix stack (docker/zabbix) continuously monitors the host, database, and application health. The Python components (app.py, ingest_csv.py) natively emit encrypted SNMPv3 traps on key events (logins, heavy SQL queries, ingestion milestones).

📝 Roadmap History

  • Sprint 1-6 [COMPLETED]: The project evolved from a foundation into a heavily optimized, vertically partitioned, RAG-integrated medical platform. All code is audited and documentation is finalized in the docs/ folder.
  • Sprint 7 [ACTIVE]: SNMPv3 Enterprise Monitoring. Deployed Zabbix Docker containers relying on the host MySQL instance. Injected pysnmp logic into core Streamlit and backend workflows for real-time telemetry alerting.
  • Future Work: The system is in a stable, monitored state. Any future AI agents modifying this project should strictly adhere to the vertical partitioning structure and use search_nutrition_db for data fetching.

Generated by Antigravity.