Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌾 SmartFarm - Intelligent Agriculture Management System

A modern MERN stack application for precision farming, featuring real-time sensor monitoring, automated irrigation control, and weather integration.

πŸ“‹ Overview

SmartFarm is a comprehensive farm management platform that enables farmers to monitor soil conditions, manage multiple fields, track sensor readings in real-time, and make data-driven decisions for optimal crop yields.

✨ Features

Core Functionality

  • Multi-Field Management: Monitor and manage multiple farm fields from a single dashboard
  • Real-Time Sensor Monitoring: Track soil moisture, temperature, pH levels, and more
  • Automated Irrigation Control: Smart irrigation system based on soil moisture thresholds
  • Weather Integration: Live weather data for informed decision-making
  • Interactive Data Visualization: Charts and graphs powered by Recharts
  • Geospatial Mapping: Location-based field visualization using Leaflet maps
  • Alert System: Automated alerts for critical sensor readings

User Experience

  • Modern UI/UX: Clean, responsive design with custom theme system
  • Secure Authentication: JWT-based login and registration
  • Real-Time Updates: Live sensor data with automatic refresh
  • Mobile Responsive: Works seamlessly across devices

πŸ› οΈ Technology Stack

Backend

  • Node.js & Express: RESTful API server
  • MongoDB Atlas: Cloud database for scalable data storage
  • Mongoose: ODM for MongoDB
  • JWT: Secure authentication
  • Node-Cron: Automated task scheduling
  • OpenWeatherMap API: Weather data integration

Frontend

  • React 19: Modern UI framework
  • Vite: Fast build tool and dev server
  • React Router: Client-side routing
  • Axios: HTTP client
  • Recharts: Data visualization
  • Leaflet: Interactive maps
  • CSS Variables: Custom theme system

πŸ“ Project Structure

SmartFarm/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── db.js                 # MongoDB Atlas connection
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ User.js               # User schema
β”‚   β”‚   β”œβ”€β”€ Field.js              # Field/Farm schema
β”‚   β”‚   β”œβ”€β”€ Sensor.js             # Sensor schema
β”‚   β”‚   β”œβ”€β”€ Reading.js            # Sensor reading schema
β”‚   β”‚   └── Alert.js              # Alert schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js         # Authentication endpoints
β”‚   β”‚   β”œβ”€β”€ fieldRoutes.js        # Field management
β”‚   β”‚   β”œβ”€β”€ sensorRoutes.js       # Sensor operations
β”‚   β”‚   β”œβ”€β”€ readingRoutes.js      # Sensor data retrieval
β”‚   β”‚   β”œβ”€β”€ alertRoutes.js        # Alert management
β”‚   β”‚   └── weatherRoutes.js      # Weather API integration
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ cronJobs.js           # Automated irrigation logic
β”‚   β”‚   └── sensorSimulator.js   # Development data simulation
β”‚   β”œβ”€β”€ seedDatabase.js           # Database seeding script
β”‚   β”œβ”€β”€ server.js                 # Express server entry point
β”‚   └── package.json
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── axios.js          # Axios configuration
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx        # Navigation component
β”‚   β”‚   β”‚   β”œβ”€β”€ AlertBanner.jsx   # Alert notifications
β”‚   β”‚   β”‚   β”œβ”€β”€ SensorChart.jsx   # Data visualization
β”‚   β”‚   β”‚   β”œβ”€β”€ SensorMap.jsx     # Leaflet map component
β”‚   β”‚   β”‚   └── WeatherCard.jsx   # Weather display
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx          # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx         # Login page
β”‚   β”‚   β”‚   β”œβ”€β”€ Signup.jsx        # Registration page
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx     # Main dashboard
β”‚   β”‚   β”‚   └── FieldDetails.jsx  # Field detail view
β”‚   β”‚   β”œβ”€β”€ themes/
β”‚   β”‚   β”‚   └── theme.css         # Custom theme variables
β”‚   β”‚   β”œβ”€β”€ App.jsx               # Main app component
β”‚   β”‚   └── main.jsx              # React entry point
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ start.sh                      # Startup script
β”œβ”€β”€ stop.sh                       # Cleanup script
└── package.json                  # Root package configuration

πŸš€ Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • MongoDB Atlas account (or local MongoDB)

Installation

  1. Clone the repository
git clone <repository-url>
cd SmartFarm
  1. Install dependencies
npm install

This will install dependencies for both backend and frontend.

  1. Configure environment variables

Create a .env file in the backend/ directory:

PORT=5001
MONGO_URI=your_mongodb_atlas_connection_string
JWT_SECRET=your_jwt_secret_key
WEATHER_API_KEY=your_openweathermap_api_key
  1. Seed the database (Optional)
cd backend
node seedDatabase.js
cd ..

This creates sample farms, sensors, and initial data.

  1. Start the application
npm start

This runs both backend (port 5001) and frontend (port 5173) concurrently.

Default Login Credentials

πŸ“Š Database Schema

Collections

Users

  • Email, password (hashed), name, role
  • JWT authentication

Fields

  • Farm ID, name, location, area
  • Moisture thresholds for irrigation
  • Sensor associations

Sensors

  • Type (moisture, temperature, pH, etc.)
  • Field assignment
  • Status and calibration data

Readings

  • Sensor ID, timestamp, value, unit
  • Historical data tracking

Alerts

  • Sensor triggers, severity levels
  • Automatic notifications

πŸ”§ API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login

Fields

  • GET /api/fields - Get all fields
  • POST /api/fields - Create new field
  • GET /api/fields/:id - Get field details
  • PUT /api/fields/:id - Update field
  • DELETE /api/fields/:id - Delete field

Sensors

  • GET /api/sensors - Get all sensors
  • POST /api/sensors - Create sensor
  • GET /api/sensors/field/:fieldId - Get field sensors

Readings

  • GET /api/readings/sensor/:sensorId - Get sensor readings
  • POST /api/readings - Add new reading

Weather

  • GET /api/weather/:location - Get weather data

🎨 Theme System

The application uses CSS variables for consistent theming:

--primary-green: #2d5016
--accent-green: #4a7c2c
--bg-white: #ffffff
--text-dark: #2c3e50

All colors, spacing, shadows, and transitions are centralized in /frontend/src/themes/theme.css.

πŸ”„ Automated Features

Irrigation Control

  • Monitors soil moisture every minute
  • Triggers irrigation when below threshold
  • Automatic system deactivation at safe levels

Sensor Simulation

  • Generates realistic sensor data during development
  • Simulates moisture, temperature, and pH variations

πŸ“± Screenshots

The application features:

  • Responsive landing page with hero section
  • Interactive dashboard with farm cards
  • Detailed field view with sensor charts
  • Real-time alerts and notifications
  • Weather integration panel

πŸ› Development

Running in Development Mode

Backend:

cd backend
npm run dev

Frontend:

cd frontend
npm run dev

Building for Production

cd frontend
npm run build

🀝 Contributing

This is an educational project. Feel free to fork and enhance!

πŸ“„ License

This project is created for educational purposes.

πŸ‘¨β€πŸ’» Author

Developed as a college project demonstrating full-stack MERN development skills.

πŸ™ Acknowledgments

  • OpenWeatherMap for weather API
  • MongoDB Atlas for cloud database
  • React and Vite communities
  • Leaflet for mapping capabilities

Note: This application demonstrates modern web development practices including RESTful API design, responsive UI, real-time data handling, and cloud database integration.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages