A comprehensive IoT-based plant monitoring application that allows users to track and manage their plants' health in real-time. Monitor pH levels, humidity, and NPK (Nitrogen, Phosphorus, Potassium) values with AI-powered disease detection capabilities.
- Features
- Tech Stack
- Quick Start
- Project Structure
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Documentation
- Frontend Routes
- Screenshots
- Contributing
- License
- User Authentication: Secure login and signup with password encryption
- Plant Management: Add, view, edit, and delete plants
- Real-time Monitoring: Track multiple sensor metrics for each plant
- pH Level monitoring
- Humidity tracking
- NPK (Nitrogen, Phosphorus, Potassium) measurements
- AI Health Diagnosis: Upload plant leaf images for instant AI-powered disease detection
- Interactive Dashboards:
- Visual charts showing 7-day historical data
- Tab-based navigation for different metrics (All, pH Level, Humidity, NPK)
- Measured vs Ideal comparisons with progress bars
- Plant Status Indicators: Visual health status (Healthy, Attention, Critical)
- User Profile Management: Edit user information and theme preferences
- Responsive Design: Mobile-first design with glassmorphism UI
- Dark Mode Support: Toggle between light and dark themes
- React 18.3 - UI library
- TypeScript - Type safety
- Vite - Build tool and dev server
- React Router DOM - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - UI component library
- Recharts - Data visualization
- React Query (TanStack Query) - Data fetching and caching
- Lucide React - Icon library
- Sonner - Toast notifications
- Node.js - Runtime environment
- Express.js 5.1 - Web framework
- MongoDB - Database (via Mongoose)
- bcryptjs - Password hashing
- Multer - File upload handling
- CORS - Cross-origin resource sharing
- Google Generative AI - AI-powered disease detection
- Gradio Client - ML model integration
Get the application up and running in 5 minutes:
-
Clone and Install
git clone <your-repository-url> cd "Agrinova 2.0" # Install backend dependencies cd "Back End" npm install # Install frontend dependencies cd "../Front End/agrinova-plant-pulse-main" npm install
-
Configure Environment
# In Back End directory, create .env file cd "../Back End" echo "MONGODB_DATABASE=mongodb://localhost:27017/Agrinova" > .env echo "PORT=3000" >> .env
-
Start MongoDB (if using local MongoDB)
# Windows net start MongoDB # macOS/Linux sudo systemctl start mongod
-
Run the Application
# Terminal 1: Start Backend cd "Back End" npm start # Terminal 2: Start Frontend cd "Front End/agrinova-plant-pulse-main" npm run dev
-
Access the Application
- Frontend: http://localhost:8080
- Backend API: http://localhost:3000
Agrinova 2.0/
βββ Back End/
β βββ app.js # Main application entry point
β βββ controllers/ # Request handlers
β β βββ loginController.js
β β βββ npkController.js
β β βββ plantController.js
β β βββ plantDataController.js
β β βββ plantDiseaceDectionController.js
β β βββ userController.js
β βββ models/ # MongoDB schemas
β β βββ plantDataModel.js
β β βββ plantModel.js
β β βββ userModel.js
β βββ routers/ # API route definitions
β β βββ loginRouter.js
β β βββ npkRouter.js
β β βββ plantDataRouter.js
β β βββ plantDiseaseDetectionRouter.js
β β βββ plantRouter.js
β β βββ userRouter.js
β βββ middlewares/ # Custom middleware
β β βββ streamToBase64.js
β β βββ upload.js
β βββ services/ # External service integrations
β β βββ geminiPrediction.js
β β βββ gradioClient.js
β βββ package.json
β
βββ Front End/
βββ agrinova-plant-pulse-main/
βββ src/
β βββ components/ # Reusable UI components
β β βββ AddPlantDialog.tsx
β β βββ MobileNav.tsx
β β βββ PlantCard.tsx
β β βββ PlantHealthDiagnosis.tsx
β β βββ SensorChart.tsx
β β βββ ui/ # shadcn/ui components
β βββ pages/ # Route pages
β β βββ Account.tsx
β β βββ NotFound.tsx
β β βββ PlantDashboard.tsx
β β βββ Plants.tsx
β β βββ Welcome.tsx
β βββ lib/ # Utilities and API clients
β β βββ mockData.ts
β β βββ plantAPI.ts
β β βββ userAPI.ts
β β βββ utils.ts
β βββ hooks/ # Custom React hooks
β βββ App.tsx # Main app component
β βββ main.tsx # Entry point
βββ package.json
βββ vite.config.ts
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher) - Download
- npm or yarn - Package manager
- MongoDB - Database (local or Atlas)
- Git - Version control
git clone <your-repository-url>
cd "Agrinova 2.0"cd "Back End"
npm installcd "../Front End/agrinova-plant-pulse-main"
npm installCreate a .env file in the Back End/ directory:
# MongoDB Connection
MONGODB_DATABASE=mongodb://localhost:27017/Agrinova
# Or for MongoDB Atlas:
# MONGODB_DATABASE=mongodb+srv://username:password@cluster.mongodb.net/Agrinova
# Server Port
PORT=3000
# Google AI API Key (for disease detection)
GOOGLE_AI_API_KEY=your_google_ai_api_key_here
# Gradio API URL (for ML model)
GRADIO_API_URL=your_gradio_api_url_hereUpdate the API base URL in Front End/agrinova-plant-pulse-main/src/lib/plantAPI.ts and userAPI.ts:
const API_BASE = "http://localhost:3000"; // Update if backend runs on different portcd "Back End"
npm startThe backend server will run on http://localhost:3000 (or the port specified in your .env file).
Open a new terminal:
cd "Front End/agrinova-plant-pulse-main"
npm run devThe frontend will run on http://localhost:8080 (or the port Vite assigns).
Open your browser and navigate to:
- Frontend:
http://localhost:8080 - Backend API:
http://localhost:3000
http://localhost:3000/api/v1
POST /login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}POST /users
Content-Type: application/json
{
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"password": "password123"
}GET /users/:idPUT /users/:id
Content-Type: application/json
{
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"isDarkMode": true
}DELETE /users/:idPOST /plants
Content-Type: application/json
{
"name": "Tomato Plant",
"type": "Tomato",
"ph": 6.5,
"humidity": 65,
"Nitrogen": 150,
"Phosphorus": 100,
"Potassium": 200,
"userId": "user_id_here"
}GET /plants
GET /plants?userId=user_id_here # Filter by userGET /plants/:idPUT /plants/:id
Content-Type: application/json
{
"ph": 6.8,
"humidity": 70
}DELETE /plants/:idPOST /plant-data
Content-Type: application/json
{
"plantId": "plant_id_here",
"type": "ph",
"value": 6.5,
"timestamp": "2024-01-20T10:00:00Z"
}GET /plant-data
GET /plant-data?type=ph # Filter by typePOST /plant-disease-detection
Content-Type: multipart/form-data
Form Data:
- img: [image file]Response:
{
"prediction": "['Tomato with Leaf Mold (94.0%)', ...]",
"advice": "Disease detected: Tomato with Leaf Mold. Apply targeted treatment."
}POST /npk
Content-Type: application/json
{
"N": 150,
"P": 100,
"K": 200,
"crop": "Tomato"
}| Route | Component | Description |
|---|---|---|
/ |
Welcome | Login/Signup page |
/plants |
Plants | List of all user's plants |
/plant/:id |
PlantDashboard | Individual plant details and analytics |
/account |
Account | User profile and settings |
* |
NotFound | 404 error page |
_id: MongoDB ObjectIdfirstName: StringlastName: Stringemail: String (unique, validated)password: String (hashed)isDarkMode: Booleanplants: Array of Plant ObjectIds
_id: MongoDB ObjectIdname: Stringtype: String (plant category)ph: Numberhumidity: NumberNitrogen: NumberPhosphorus: NumberPotassium: NumberuserId: ObjectId (reference to User)
_id: MongoDB ObjectIdplantId: ObjectId (reference to Plant)type: String (e.g., 'ph', 'humidity', 'n', 'p', 'k')value: Numbertimestamp: Date
- Real-time Metrics: Display current pH, humidity, and NPK values
- Historical Charts: 7-day line charts for all metrics
- Ideal Ranges: Compare measured values against ideal ranges for each plant type
- Progress Indicators: Visual progress bars showing how close values are to ideal
- Tab Navigation: Switch between All, pH Level, Humidity, and NPK views
- AI Health Diagnosis: Upload leaf images for disease detection
- Add Plants: Create new plant entries with sensor data
- View Plants: Card-based layout showing plant status and key metrics
- Delete Plants: Remove plants with confirmation dialogs
- Status Indicators: Color-coded status (Healthy, Attention, Critical)
- Profile Editing: Update first name, last name, and email
- Theme Toggle: Switch between light and dark modes
- Logout: Secure session termination
- Password hashing with bcryptjs
- CORS configuration for secure API access
- Input validation on both client and server
- Environment variable management for sensitive data
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
- Ensure MongoDB is running locally or check Atlas connection string
- Verify
.envfile has correctMONGODB_DATABASEvalue - For local MongoDB: Ensure MongoDB service is running (
net start MongoDBon Windows,sudo systemctl start mongodon Linux/macOS) - For MongoDB Atlas: Check connection string format and IP whitelist settings
- Verify database name matches in connection string and Mongoose configuration
- Check that backend CORS origin matches frontend URL
- Update CORS settings in
Back End/app.jsif needed (default:http://localhost:8080)
- Backend: Change
PORTin.envfile (default: 3000) - Frontend: Update
vite.config.tsor use--portflag (default: 8080) - CORS: Ensure backend CORS origin matches frontend URL
- Verify backend is running before starting frontend
- Check
API_BASEURL in frontend API files (lib/plantAPI.ts,lib/userAPI.ts) matches backend port - Ensure CORS is properly configured in
Back End/app.js - Check browser console for CORS errors
cd "Front End/agrinova-plant-pulse-main"
npm run buildThe production build will be created in the dist/ directory.
The backend can be deployed to platforms like:
- Heroku
- Railway
- Render
- DigitalOcean
- AWS EC2
Make sure to set your environment variables in the deployment platform.
The frontend can be deployed to:
- Vercel
- Netlify
- GitHub Pages
- AWS S3 + CloudFront
Update the API base URL in production to point to your deployed backend.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code formatting
- Use TypeScript for frontend code
- Add comments for complex logic
- Test your changes before submitting
This project is licensed under the ISC License.
- Ahmad Al Khatib
- Lana Fliti
- Charbel Kadi
- shadcn/ui for the amazing component library
- Recharts for data visualization
- Google Generative AI for disease detection capabilities
- All contributors and supporters of this project
Made with π± for plant lovers everywhere