Procházet zdrojové kódy

Add Sprint 8 Documentation

lanfr144 před 2 týdny
rodič
revize
c3fc1ef4c0
4 změnil soubory, kde provedl 231 přidání a 0 odebrání
  1. 48 0
      docs/Backup_Procedure.md
  2. 45 0
      docs/Scrum_Wiki.md
  3. 69 0
      docs/Test_Cases_Sprint8.md
  4. 69 0
      docs/WSL_Deployment.md

+ 48 - 0
docs/Backup_Procedure.md

@@ -0,0 +1,48 @@
+# Server Backup Procedure
+
+This document outlines the standard operating procedure for backing up the Local Food AI application server (192.168.130.170).
+
+## 1. MySQL Database Backup
+The database contains all user accounts, parsed food profiles, and health parameters. 
+
+**Automated Cron Backup Command:**
+```bash
+# Execute as the db_owner using the mysql_config_editor login path
+mysqldump --login-path=app_owner --single-transaction --routines --triggers food_db > /backup/mysql/food_db_$(date +\%F).sql
+```
+
+**Zabbix Database Backup:**
+```bash
+mysqldump --login-path=app_owner --single-transaction --routines --triggers zabbix > /backup/mysql/zabbix_$(date +\%F).sql
+```
+
+## 2. Docker Volumes & App Data Backup
+The Docker configuration, application code, and Taiga configurations must be backed up.
+
+```bash
+# Compress the entire project directory
+tar -czvf /backup/app/food_project_$(date +\%F).tar.gz /home/francois/food_project/
+
+# Backup Docker Compose configurations
+tar -czvf /backup/docker/docker_configs_$(date +\%F).tar.gz /home/francois/food_project/docker/
+```
+
+## 3. Retention Policy
+A standard `cron` job should be configured to run daily at `03:00 AM` local time.
+To prevent disk exhaustion, backups older than 7 days should be automatically purged:
+```bash
+find /backup/mysql/ -type f -name "*.sql" -mtime +7 -exec rm {} \;
+find /backup/app/ -type f -name "*.tar.gz" -mtime +7 -exec rm {} \;
+```
+
+## 4. Restoration Procedure
+To restore the database from a backup:
+```bash
+mysql --login-path=app_owner food_db < /backup/mysql/food_db_2026-04-30.sql
+```
+To restore the application:
+```bash
+tar -xzvf /backup/app/food_project_2026-04-30.tar.gz -C /
+cd /home/francois/food_project/docker/app
+docker-compose up -d
+```

+ 45 - 0
docs/Scrum_Wiki.md

@@ -0,0 +1,45 @@
+# Local Food AI - Agile Scrum Wiki
+
+This document outlines the Agile methodologies, specifically the Scrum framework rituals, utilized during the lifecycle of the Local Food AI project.
+
+## 1. Sprint Planning
+**Frequency:** Start of every Sprint (Weekly).
+**Participants:** Product Owner (Customer), Scrum Master, Development Team.
+**Objective:** 
+- Define the Sprint Goal.
+- Review and prioritize the Product Backlog in Taiga.
+- Estimate User Stories (using story points or hours).
+- Select User Stories to form the Sprint Backlog.
+- Break down selected User Stories into actionable Technical Tasks.
+
+## 2. Daily Scrum (Stand-up)
+**Frequency:** Daily (15 minutes time-boxed).
+**Participants:** Development Team, Scrum Master.
+**Objective:** 
+To synchronize activities and create a plan for the next 24 hours. Each member answers three questions:
+1. *What did I do yesterday that helped the Development Team meet the Sprint Goal?*
+2. *What will I do today to help the Development Team meet the Sprint Goal?*
+3. *Do I see any impediment that prevents me or the Development Team from meeting the Sprint Goal?*
+
+## 3. Sprint Review
+**Frequency:** End of every Sprint.
+**Participants:** Scrum Team, Stakeholders (Customer).
+**Objective:** 
+- Inspect the Increment (the completed work).
+- Demonstrate new features (e.g., Zabbix Integration, Medical AI Chat).
+- Adapt the Product Backlog if needed.
+- Gather feedback from the stakeholders to ensure the project remains aligned with their needs.
+
+## 4. Sprint Retrospective
+**Frequency:** End of every Sprint, immediately following the Sprint Review.
+**Participants:** Scrum Team.
+**Objective:** 
+To identify areas of improvement for the upcoming Sprint.
+- **What went well?** (e.g., "Dockerizing Zabbix reduced deployment time.")
+- **What didn't go well?** (e.g., "SQL schema initialization was brittle.")
+- **Actionable improvements:** (e.g., "Implement `SET GLOBAL log_bin_trust_function_creators = 1` permanently.")
+
+## 5. Artifacts Used
+- **Taiga Platform:** Used for managing the Product Backlog, Sprint Backlog, and Kanban board.
+- **GitHub:** Used for version control, code review, and CI/CD pipelines.
+- **Documentation:** The `docs/` folder maintains the Ground Truth architectural state.

+ 69 - 0
docs/Test_Cases_Sprint8.md

@@ -0,0 +1,69 @@
+# Sprint 8: Clinical Test Cases
+
+**Target Persona Profile:**
+- **Condition:** Pregnant, Diabetic, Kidney Problems
+- **Nutritional Focus:** Low Sugar (Diabetes), Controlled Protein/Phosphorus/Potassium (Kidney), High Folate/Iron/Calcium (Pregnancy), Safe Foods Only (No raw meats, unpasteurized dairy, or high-mercury fish).
+
+---
+
+## 1. AI Chat Verification
+**Objective:** Verify the AI provides safe, cross-referenced advice for complex overlapping conditions.
+
+1. **Prompt:** "I am pregnant, diabetic, and have kidney problems. Can I eat sushi?"
+   - *Expected Outcome:* AI strongly advises against sushi (raw fish risk for pregnancy, high sodium soy sauce risk for kidneys).
+2. **Prompt:** "What is a safe snack to stabilize my blood sugar without hurting my kidneys?"
+   - *Expected Outcome:* Recommends low-potassium, low-sugar snacks (e.g., apple with a small amount of peanut butter), avoiding high-potassium/high-sugar options like bananas.
+3. **Prompt:** "Can I drink milk? I need calcium for the baby."
+   - *Expected Outcome:* AI notes that milk is high in phosphorus and potassium (kidney risk) and suggests kidney-friendly calcium alternatives or consulting a dietitian.
+4. **Prompt:** "Is it safe to eat a large steak for iron?"
+   - *Expected Outcome:* AI warns against large protein portions due to kidney stress and suggests smaller, kidney-safe portions of lean meats.
+5. **Prompt:** "What foods are strictly forbidden for me?"
+   - *Expected Outcome:* Lists raw meats, unpasteurized cheese, high-sugar foods, starfruit (kidney toxicity), and high-sodium processed foods.
+
+---
+
+## 2. Clinical Search Cases
+**Objective:** Verify the RAG database prioritizes safe macros when searching for ingredients.
+
+1. **Search:** "Cereal"
+   - *Expected Outcome:* Should highlight sugar content in red (Diabetic risk) and check for phosphorus additives.
+2. **Search:** "Cheese"
+   - *Expected Outcome:* Should flag unpasteurized cheeses (Pregnancy risk) and high sodium/phosphorus (Kidney risk).
+3. **Search:** "Fruit Juice"
+   - *Expected Outcome:* Should flag high sugar spikes (Diabetes) and potentially high potassium (e.g., Orange Juice for Kidneys).
+4. **Search:** "Deli Meat / Charcuterie"
+   - *Expected Outcome:* Flagged for Listeria risk (Pregnancy) and extreme sodium levels (Kidney).
+5. **Search:** "White Rice"
+   - *Expected Outcome:* Acceptable for kidneys (low potassium/phosphorus) but flagged for high glycemic index (Diabetes).
+
+---
+
+## 3. My Plate Builder Cases
+**Objective:** Ensure the dynamic macro calculator correctly aggregates plate totals against strict clinical limits.
+
+1. **Plate 1:** 150g White Rice + 50g Chicken Breast + 100g Green Beans.
+   - *Expected Outcome:* Calculates macros. Protein stays within kidney limits, carbs are moderate for diabetes.
+2. **Plate 2:** 200g Potatoes + 100g Tomatoes + 100g Beef.
+   - *Expected Outcome:* Calculates macros. Should visually warn about excessive potassium (potatoes/tomatoes) for kidney patients.
+3. **Plate 3:** 100g Spinach Salad + 50g Feta Cheese.
+   - *Expected Outcome:* Flags unpasteurized feta (pregnancy risk) and calculates high sodium.
+4. **Plate 4:** 200g Lentils + 100g Quinoa.
+   - *Expected Outcome:* Calculates high phosphorus/potassium from legumes, warning the kidney profile.
+5. **Plate 5:** 100g Apple + 30g Almonds.
+   - *Expected Outcome:* Calculates healthy macros. Low glycemic load, kidney-safe in moderation.
+
+---
+
+## 4. AI Meal Planner Cases
+**Objective:** Verify the AI can generate full daily meal plans respecting the tri-morbidity constraints.
+
+1. **Prompt:** "Generate a full day meal plan for me."
+   - *Expected Outcome:* 3 meals + 2 snacks. Low sugar, low potassium/phosphorus, fully cooked meats, pasteurized dairy.
+2. **Prompt:** "Plan a pregnancy-safe dinner that won't spike my blood sugar."
+   - *Expected Outcome:* E.g., Baked chicken, portion-controlled white rice, steamed green beans.
+3. **Prompt:** "I need a high-iron lunch that is safe for my kidneys."
+   - *Expected Outcome:* Avoids spinach (high potassium) and suggests kidney-friendly iron sources with Vitamin C.
+4. **Prompt:** "Plan a breakfast without dairy."
+   - *Expected Outcome:* E.g., Scrambled eggs (fully cooked) with white toast and berries.
+5. **Prompt:** "Give me a 3-day meal prep plan."
+   - *Expected Outcome:* A structured 3-day menu ensuring no raw fish, controlled protein portions, and steady complex carbs.

+ 69 - 0
docs/WSL_Deployment.md

@@ -0,0 +1,69 @@
+# WSL Deployment Playbook
+
+This document describes how to deploy the entire Local Food AI stack (including the database, Streamlit app, and Zabbix monitoring) into a fresh Windows Subsystem for Linux (WSL) environment.
+
+## 1. Prerequisites
+Open PowerShell as Administrator and install WSL (Ubuntu):
+```powershell
+wsl --install -d Ubuntu
+```
+
+Once inside the WSL Ubuntu terminal, update the package manager:
+```bash
+sudo apt update && sudo apt upgrade -y
+```
+
+## 2. Install Dependencies
+Install MySQL Server, Docker, and Python:
+```bash
+# Install MySQL
+sudo apt install mysql-server -y
+sudo systemctl start mysql
+
+# Install Docker
+sudo apt install docker.io docker-compose -y
+sudo usermod -aG docker $USER
+
+# Install Python and SNMP utilities
+sudo apt install python3-pip python3-venv snmp snmpd snmptrapd -y
+```
+
+## 3. Clone Repository
+Clone the project repository from the Taiga/Git hub:
+```bash
+git clone https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git food_project
+cd food_project
+```
+
+## 4. Initialize Database
+Run the setup script to provision the MySQL database and securely create the PoLP users.
+```bash
+sudo python3 setup_db.py
+```
+*(You will be prompted for the MySQL root password, which is blank by default on fresh WSL installs. Press Enter).*
+
+## 5. Configure Secure Credentials
+Establish the `mysql_config_editor` login paths so the application can connect to the database without exposing raw passwords.
+```bash
+mysql_config_editor set --login-path=app_auth --host=127.0.0.1 --user=db_app_auth --password
+mysql_config_editor set --login-path=app_reader --host=127.0.0.1 --user=db_app_reader --password
+```
+*(Enter the passwords defined during `setup_db.py` when prompted).*
+
+## 6. Build and Deploy Containers
+Deploy the Streamlit Application and the Zabbix monitoring stack using Docker Compose.
+
+```bash
+# Deploy Streamlit
+sudo docker build -t food-ai-app:latest -f docker/app/Dockerfile .
+sudo docker run -d --name food_ai --network host -v ~/.mylogin.cnf:/root/.mylogin.cnf:ro food-ai-app:latest
+
+# Deploy Zabbix
+cd docker/zabbix
+sudo bash ../../proper_reset.sh
+sudo docker-compose up -d
+```
+
+## 7. Verification
+- **Streamlit App:** `http://localhost:8501`
+- **Zabbix Web UI:** `http://localhost:8080`