How manikumar-dodla/agriguard works
Project Type and Purpose
• AgriGuard is a full-stack, data-driven web application that empowers farmers with crop recommendations, irrigation guidance, flood alerts, and AI-powered chat assistance.
• It was built for the NASA Space Apps Challenge 2024 and integrates multiple external data sources (NASA POWER, Open Meteo, OpenWeather) and an AI model (Hugging Face Mistral).
File Structure
• Top-level directories:
• backend/ – Node.js server (server.js, package.json), Python service (app.py) hosting a Keras disease model (plant_disease_model.keras), .env for secrets
• public/ – Static assets for the front end
• src/ – React code (App.jsx, pages/, components/, context/)
• Configuration: vite.config.js, tailwind.config.js, eslint.config.js
• Key patterns: Single React SPA with Vite build, Node as API gateway, Python microservice for ML inference, context/provider pattern for user state, API integration layers in components/pages.
README for Insights
• Frontend uses React + Tailwind + Recharts
• Backend APIs call NASA POWER, Open Meteo, OpenWeather, Hugging Face
• Firebase is used (src/pages/firebase.js) for authentication/data storage
Main Components
a. User & UI Layer
• Browser / Mobile App (HTTP/HTTPS)
• React SPA (src/)
b. API Layer (Backend)
• Node.js Server (server.js) – Express routes for weather, crop suggestions, flood alerts, chatbot proxy
• Python ML Service (app.py) – Loads plant_disease_model.keras for disease predictions
c. Data Stores & Auth
• Firebase (Auth + Firestore/Realtime DB)
• Environment variables (.env) for API keys
d. External Services
• NASA POWER API (precipitation, groundwater)
• Open Meteo River Discharge API (flood alerts)
• OpenWeather API (weather data)
• Hugging Face Mistral AI API (chatbot)
e. Third-Party Libraries
• Recharts for data visualization
• Tailwind CSS for styling
Relationships & Interactions
• The React SPA initiates HTTP requests to the Node.js server.
• Node.js routes forward or aggregate data from:
• NASA POWER (crop & irrigation data)
• Open Meteo (flood alerts)
• OpenWeather (weather snapshots)
• Hugging Face (chatbot queries)
• Python ML Service (disease detection inference)
• Node.js may read/write to Firebase for user profiles, favorites, expert consultations.
• Python ML Service returns JSON predictions to Node.js.
• Data flows back to React, where Recharts renders graphs and components display results.
Architectural Patterns & Principles
• Separation of concerns: React UI vs. Node API vs. Python microservice
• API Gateway pattern: Node.js aggregates external API calls and internal services
• Microservice for ML inference: isolates heavy model loading and prediction logic
• Context API for global user state in React
• Environment-driven configuration for keys and endpoints
What
• Clear, descriptive labels for each component and service
• Notes on protocols (HTTP/HTTPS, REST) and authentication (Firebase tokens, API keys)
Detail
• Environment (.env) feeding API keys into Node.js and Python services
• Separate the AI Chatbot flow from the data-visualization flow for clarity