This guide walks through every single file, function, ML decision, and setup step behind our AI-Based Plant Stress Detection and Early Health Monitoring System ( BAI507P Mini Project). It is written so you can open the code in VS Code , trace every line from the browser to Python and SQLite, run it on Windows , and answer any viva question confidently.
1. End-to-End Architecture: How Everything Connects
Browser (static/index.html) │ 1. Captures / uploads a leaf photo + soil/weather slider values │ 2. Sends multipart FormData via fetch("POST /api/analyze") ▼ FastAPI Server (app.py) │ 3. Reads uploaded image bytes + validates sensor inputs │ 4. Calls analyze_plant_image() in engine.py ▼ OpenCV Computer Vision Pipeline (engine.py) │ 5. Segments plant tissue (HSV) & auto-centers the leaf (_center_plant_frame) │ 6. Quantifies 6 visual symptoms: │ - Healthy Green %, Yellowing %, Browning %, Dark Spots %, Pale %, Wilting Index │ 7.…