How shukur-alom/leaf-diseases-detect works
Project type and purpose
• This is a full-stack AI-powered leaf disease detection system.
• Purpose: Provide dual interfaces (FastAPI REST API + Streamlit web UI) that accept leaf images, forward them to an AI core (Meta Llama Vision via Groq API) for disease detection, and return structured analysis (disease type, severity, confidence, treatment recommendations).
File structure
• Top-level:
• app.py → FastAPI backend
• main.py → Streamlit frontend
• utils.py → shared image-processing helpers
• test_api.py → API integration tests
• requirements.txt
• vercel.json → cloud deployment config
• .streamlit/config.toml → Streamlit settings
• Subdirectory “Leaf Disease/”:
• config.py → AI model & environment configuration
• main.py → Core AI detection engine (LeafDiseaseDetector, dataclasses, Groq API integration)
• Media/ → Example images for testing
README for additional insights
• Clearly states a three-tier logical architecture:
a. Streamlit Web Application (UI/UX)
b. FastAPI Backend (REST endpoints)
c. Core AI Engine (Groq-powered Llama Vision)
• External dependency: Groq API
• No persistent database—stateless image processing
a. Main components to represent:
1. Client Layer:
– Web browser (Streamlit UI)
– API client (cURL/requests)
2. Presentation Layer:
– Streamlit App (main.py)
– FastAPI Service (app.py)
3. Business Logic Layer:
– LeafDiseaseDetector (Leaf Disease/main.py)
– utils.py (image preprocessing, base64 encoding)
4. External Service:
– Groq API (Meta Llama Vision inference)
5. Supporting:
– Test suite (test_api.py)
– Deployment config (vercel.json, .streamlit)
b. Relationships & interactions:
• Streamlit UI → POST multipart/form-data → FastAPI endpoint /disease-detection-file
• FastAPI handler → calls utils.py to preprocess → encodes as base64 → invokes LeafDiseaseDetector.analyze_leaf_image_base64()
• LeafDiseaseDetector → sends REST/gRPC call to Groq API → receives JSON response → parses into DiseaseAnalysisResult → returns to FastAPI
• FastAPI → transforms dataclass to JSON → returns to Streamlit UI (or other API client)
• Streamlit → renders results (confidence, severity, treatment)
• All components stateless—horizontal scaling via Vercel or other cloud
c. Architectural patterns & design principles:
– Layered architecture (Presentation / API / Core AI)
– Separation of concerns (UI vs. API vs. AI engine vs. utilities)
– Stateless, horizontally scalable micro-service style
– Dependency injection via config.py and .env variables
– Automated testing (test_api.py) for contract validation
d. Key technologies/frameworks:
– Python 3.8+
– FastAPI (REST, OpenAPI docs)
– Streamlit (web UI)
– Groq API & Meta Llama Vision models
– Pydantic/dataclasses for structured responses
– Vercel & Streamlit Cloud for deployment
Diagramming conventions
• Blue rectangles for UI components (Streamlit, Browser)
• Green rectangles for API services (FastAPI)
• Orange rectangles for core engine (LeafDiseaseDetector, utils)
• UI → API (HTTP POST)
• API → Core Engine (method call)
• Core Engine → Groq API (HTTPS request)
• “Presentation Layer” containing Streamlit/UI
• “Application Layer” containing FastAPI
• “AI Layer” containing LeafDiseaseDetector & external Groq
Detail level
– Capture utility module’s role (image pre-processing).
– Show test suite and deployment config as side artifacts.