A multi-version Streamlit app (V1, V2, V3) for plant disease detection, comparison, and history tracking, backed by MongoDB and powered by multi‑agent LLM analysis. Includes secure auth (bcrypt) and data persistence for repeatable diagnostics.
- Three app versions kept for transparency & evolution
- V1 — Plant Disease Detection: Upload a plant image → get symptoms, likely diseases, and care steps.
- V2 — Image Comparison: Compare two images (e.g., before vs. after treatment) → track improvement or spread; results are persisted for future comparisons.
- V3 — Scanned Plants & Details: History view of analyzed plants, detail pages, follow‑up image attachments, and side‑by‑side analysis.
- Secure Auth using bcrypt:
- Passwords are salted + hashed, verified using constant‑time checks.
- Login/Signup state managed via cookies; only minimal identifiers stored client‑side.
- User records persisted in MongoDB.
- Multi‑Agent Analysis for higher accuracy:
- Agents collaborate: Vision Analyzer → Symptom Summarizer → Differential Diagnosis → Consistency Checker.
- Modular provider layer (supports multiple APIs) to ensemble or fallback.
- MongoDB Persistence:
- Image binaries, analyses, and comparisons saved per‑user (owner scoping).
- Queryable history enables longitudinal tracking and re‑evaluation.
- Streamlit UX with caching:
st.cache_resourcefor long‑lived resources (DB clients, model clients).st.cache_datafor deterministic, recomputable results (lookups, small transforms).
- Passwords: hashed with bcrypt (salted), verified with
bcrypt.checkpw. - Cookies/Sessions: store only minimal identifiers (e.g.,
uid), preferHttpOnly,Secure,SameSite=Lax/Strict. - Input validation: accept only JPEG/PNG, enforce size limits, verify magic bytes.
- Secrets: never commit real keys; use
config/secrets.example.tomltemplate and local.streamlit/secrets.toml. - Least privilege: use a scoped MongoDB user (RBAC) and IP allow‑listing where possible.
- Python 3.10+
- MongoDB Atlas (or local Mongo) connection string
git clone https://github.com/aymenhmaidiwastaken/AgroCare.git
cd AgroCare
python -m venv .venv && source .venv/bin/activate # Windows: .venv\\Scripts\\activate
pip install -r requirements.txt# copy the example template
mkdir -p .streamlit
cp config/secrets.example.toml .streamlit/secrets.toml
# then edit .streamlit/secrets.toml with your values
[mongodb]
uri = "your-mongodb-uri"
[api_keys]
openai = "sk-..."
# optional providers, if configured
# groq = "..."
# toolhouse = "..."streamlit run app.pyUse the sidebar to switch between V1 / V2 / V3.
- Vision Analyzer extracts salient features from the image (spots, color changes, leaf curl).
- Symptom Summarizer condenses features into a structured list.
- Differential Diagnosis proposes 1–2 likely diseases with confidence levels.
- Consistency Checker verifies plausibility and flags contradictions.
- Persistence writes final analysis/trace to MongoDB for future review.
Each step can target different APIs/models and ensemble results for robustness.
AgroCareApp/
├─ app.py # main Streamlit entry (routes to V1/V2/V3)
├─ V1/ # Plant Disease Detection
│ └─ app1.py
├─ V2/ # Image Comparison
│ └─ app2.py
├─ V3/ # Scanned Plants / Details
│ └─ app3.py
├─ assets/
│ ├─ demo.gif # your showcase GIF
│ └─ icons/ # tech logos (svg/png)
├─ config/
│ └─ secrets.example.toml
├─ requirements.txt
├─ .gitignore
└─ README.md
- Role‑based access (admin/user)
- GridFS for large images
- Structured JSON outputs for analyses (Pydantic)
- Model confidence calibration & uncertainty display
- Batch comparisons and alerts ("notify me if worsening")
Pull requests welcome. If you find a bug or security issue, please open an issue or email us (see SECURITY.md for responsible disclosure).
