# ☕ Coffee Leaf Nutrition Prediction
An advanced AI-powered system designed to identify and diagnose nutrient deficiencies in coffee plants through image analysis of their leaves. This project provides farmers and agricultural experts with instant, actionable insights to ensure optimal crop health.
---
## 📊 System Flowcharts
To better understand how the project works, we have broken down the system into three primary workflows.
### 1. High-Level System Architecture
This chart shows how the user interacts with the frontend and how the frontend communicates with the AI backend.
```mermaid
graph LR
User([User]) --> Frontend[Frontend: HTML/CSS/JS]
Frontend -- "1. Upload Image (POST)" --> Backend[Backend: Flask API]
Backend -- "2. Machine Learning Inference" --> Model[CNN Model: weights.hdf5]
Model -- "3. Return Predicted Class + Confidence" --> Backend
Backend -- "4. Send JSON Response" --> Frontend
Frontend -- "5. Visualize Results & Actions" --> User
```
### 2. Deep Dive: Prediction Logic Flow
This chart explains the exact steps the AI takes to identify whether a leaf is healthy or has a deficiency (N, P, or K).
```mermaid
flowchart TD
Start([Upload Received]) --> Resizing[Resize Image to 224x224]
Resizing --> Preprocessing[Normalize Pixel Values 0-1]
Preprocessing --> Inference[Forward Pass through CNN Layers]
Inference --> Features[Extract Edges, Textures & Leaf Patterns]
Features --> Probabilities[Calculate Probabilities for 4 Classes]
Probabilities --> Decision{Highest Probability?}
Decision -->|N_Deficiency| N_Res[Nitrogen Deficiency Found]
Decision -->|P_Deficiency| P_Res[Phosphorus Deficiency Found]
Decision -->|K_Deficiency| K_Res[Potassium Deficiency Found]
Decision -->|Healthy| H_Res[Healthy Leaf Detected]
N_Res & P_Res & K_Res & H_Res --> Output[Return Result to User]
```
### 3. Application Navigation Flow
This chart displays the different routes available in the web application and what users can do in each section.
```mermaid
graph TD
Root[/] --> H …