How shreya-1831/leafy-chatbot works
Leafy is a plant-health companion whose main journey runs from an authenticated image upload through streamed diagnosis and care advice, with results and scans retained for later use. The React client also provides chat, history, analytics, reports, weather, and theme controls; FastAPI routes connect these capabilities to model, chatbot, and MongoDB services. Relationships reflect the sampled source and README; unsampled route and dashboard details are represented only where documented.
Main entry points: App.tsx App shell · main.py FastAPI app · predict.py Prediction stream · db.py MongoDB
Components 25
Web client
- App shell
frontend/src/App.tsx - Sign-in gate
frontend/src/components/AuthGate.tsx - Auth state
frontend/src/context/AuthContext.tsx - Image upload
frontend/src/components/DragDropUpload.tsx - Chat interface
frontend/src/components/ChatInterface.tsx - API client
frontend/src/services/api.ts
API workflows
- FastAPI app
leafy-backend/main.py - Auth routes
leafy-backend/routes/auth.py - Prediction stream
leafy-backend/routes/predict.py - Chat and sessions
leafy-backend/routes/chat.py - Scan history
leafy-backend/routes/history.py - User analytics
leafy-backend/routes/analytics.py - PDF download
leafy-backend/routes/report.py
Diagnosis and advice
- Disease model
leafy-backend/services/model_service.py - Severity grading
leafy-backend/utils/severity.py - Chat streaming
leafy-backend/services/chatbot_service.py - Plant assistant
leafy-backend/services/chatbot.py
Identity and data
- MongoDB
leafy-backend/db.py
Plant-care features
- Report generator
leafy-backend/services/pdf_service.py - Analytics dashboard
frontend/src/components/Dashboard.tsx - History browser
frontend/src/components/ScanHistory.tsx - Diagnosis summary
frontend/src/components/SummaryCard.tsx - Weather widget
frontend/src/components/WeatherWidget.tsx
Other components
- Gardener
- Weather service
Connections 37
- Gardener → App shell: uses
README.md - App shell → Sign-in gate: shows
frontend/src/App.tsx - App shell → Image upload: shows
frontend/src/App.tsx - App shell → Chat interface: shows
frontend/src/App.tsx - App shell → Analytics dashboard: shows
frontend/src/App.tsx - App shell → History browser: shows
frontend/src/App.tsx - App shell → Diagnosis summary: shows
frontend/src/App.tsx - App shell → Weather widget: shows
frontend/src/App.tsx - Sign-in gate → Auth state: uses
- Sign-in gate → Auth routes: authenticates
README.md - Auth state → Auth routes: restores session
frontend/src/context/AuthContext.tsx - Image upload → API client: requests diagnosis
frontend/src/components/DragDropUpload.tsx - API client → FastAPI app: calls API
README.md - FastAPI app → Auth routes: registers
leafy-backend/main.py - FastAPI app → Prediction stream: registers
leafy-backend/main.py - FastAPI app → Chat and sessions: registers
leafy-backend/main.py - FastAPI app → Scan history: registers
leafy-backend/main.py - FastAPI app → User analytics: registers
leafy-backend/main.py - FastAPI app → PDF download: registers
leafy-backend/main.py - Prediction stream → Disease model: predicts with
leafy-backend/routes/predict.py - Prediction stream → Severity grading: grades confidence
leafy-backend/routes/predict.py - Prediction stream → Chat streaming: streams advice
leafy-backend/routes/predict.py - Chat and sessions → Chat streaming: streams replies
leafy-backend/routes/chat.py - Chat streaming → Plant assistant: delegates
leafy-backend/services/chatbot_service.py - Prediction stream → MongoDB: saves scan
leafy-backend/routes/predict.py - Chat and sessions → MongoDB: stores sessions
leafy-backend/routes/chat.py - Auth routes → MongoDB: stores users
leafy-backend/routes/auth.py - Scan history → MongoDB: reads scans
- User analytics → MongoDB: queries records
- PDF download → Report generator: generates report
leafy-backend/routes/report.py - Image upload → Prediction stream: streams image
README.md - Chat interface → Chat and sessions: streams chat
README.md - Analytics dashboard → User analytics: loads metrics
README.md - History browser → Scan history: loads scans
README.md - Diagnosis summary → Chat interface: shows diagnosis
- Weather widget → Weather service: fetches conditions
README.md - PDF download → Gardener: downloads PDF
README.md