Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

The Smart Agriculture Management System is a modern, full-stack application designed to streamline agricultural operations, provide AI-driven insights, and facilitate seamless payment processing. Built with Next.js (TypeScript) for the frontend and Node.js/Express.js for the backend, this system empowers farmers and administrators with powerful too

Notifications You must be signed in to change notification settings

liegen47/smart-agriculture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

44 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NatureSense - Smart Agriculture Management System 🌾

Next.js React TypeScript MongoDB

A modern full-stack application for agricultural management, AI analysis, and payment processing. Built with Next.js (TypeScript) frontend and Node.js/Express.js backend.

System Overview

✨ Features

Frontend

  • πŸŒ“ Light/Dark mode toggle
  • πŸ“Š Interactive data visualization with Recharts
  • πŸ” Command menu interface (CMDK)
  • πŸ“± Responsive mobile-first design
  • πŸ›’ Stripe payment integration
  • πŸ“ Form validation with Zod & React Hook Form
  • πŸš€ Server-side rendering (SSR) with Next.js
  • 🧩 Component library with Radix UI & Tailwind CSS

Backend

  • πŸ” JWT Authentication & Authorization
  • 🧠 AI-powered crop health analysis
  • πŸ’³ Stripe payment processing with webhooks
  • πŸ“ˆ REST API with Swagger documentation
  • πŸ—ƒοΈ MongoDB database management
  • πŸ“‘ WebSocket support for real-time updates
  • βš™οΈ Role-based access control (Admin/Farmer)

Admin Panel

  • πŸ‘¨β€πŸ’Ό User Management: Approve/disapprove farmers, manage roles, and view user activity.
  • πŸ“Š Analytics Dashboard: Monitor system-wide metrics, including crop health, subscription status, and revenue.
  • πŸ’Ό Subscription Management: View and manage user subscriptions, including upgrades, downgrades, and cancellations.
  • πŸ”’ Security Settings: Configure system-wide security policies, including password requirements and session management.
  • πŸ“ Logs & Audits: Access detailed logs for user actions, system events, and API requests.

πŸ› οΈ Tech Stack

Frontend:

  • Next.js 15 (App Router)
  • React 19 + TypeScript
  • Tailwind CSS + tailwind-merge
  • Radix UI Primitives
  • TanStack Table v8
  • react-hook-form + Zod
  • Stripe Elements
  • Axios for API calls

Backend:

  • Node.js 20 + Express.js
  • MongoDB + Mongoose
  • JSON Web Tokens (JWT)
  • Stripe Node SDK
  • Swagger UI for API docs
  • Date-fns for date handling

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯18.x
  • MongoDB Atlas account
  • Stripe account
  • Git

Installation

  1. Clone the repository:
git clone https://github.com/liegen47/smart-agriculture.git
cd smart-agriculture
  1. Install dependencies:
# Frontend
cd frontend && npm install

# Backend
cd ../backend && npm install
  1. Environment Setup

Create .env files with these variables: or else check respective repos for .env.example file Backend (backend/.env):

PORT=5000
MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/agriculture
JWT_SECRET=your_jwt_secret_key
STRIPE_SECRET_KEY=sk_test_51...
STRIPE_WEBHOOK_SECRET=whsec_...

Frontend (frontend/.env.local):

NEXT_PUBLIC_API_URL=http://localhost:5000
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_51...
  1. Run the application:
# Backend
cd backend && npm start

# Frontend (in new terminal)
cd frontend && npm run dev

Access the application at:

  • Frontend: http://localhost:3000
  • Backend API: http://localhost:5000
  • API Docs: http://localhost:5000/api-docs

πŸ’³ Stripe Integration

  1. Create a Stripe account at stripe.com
  2. Configure webhook in Stripe Dashboard:
    • Endpoint URL: http://localhost:5000/api/payments/webhook
    • Events: checkout.session.completed
  3. Test using Stripe test cards:
    • Successful payment: 4242 4242 4242 4242
    • Payment failure: 4000 0000 0000 0002

πŸ“¦ Deployment

Backend (Node.js)

  1. Deploy to Render or Heroku
  2. Set production environment variables:
    NODE_ENV=production
    MONGO_URI=your_production_mongo_uri
  3. Configure CORS for frontend domain

Frontend (Next.js)

  1. Deploy to Vercel or Netlify
  2. Set environment variables:
    NEXT_PUBLIC_API_URL=https://your-backend-domain.com
    NEXT_PUBLIC_STRIPE_PUBLIC_KEY=your_live_stripe_key

πŸ“‚ Project Structure

smart-agriculture/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/               # Next.js app router
β”‚   β”œβ”€β”€ components/        # Reusable UI components
β”‚   β”œβ”€β”€ lib/               # API clients, configs
β”‚   β”œβ”€β”€ styles/            # Global CSS & Tailwind
β”‚   └── types/             # TypeScript definitions
β”‚
└── backend/
    β”œβ”€β”€ config/            # DB & environment setup
    β”œβ”€β”€ controllers/       # Business logic
    β”œβ”€β”€ models/            # Mongoose schemas
    β”œβ”€β”€ routes/            # API endpoints
    β”œβ”€β”€ middleware/        # Auth & error handling
    └── utils/             # Helper functions

πŸ“„ API Documentation

Swagger

Interactive API documentation available at /api-docs endpoint. Includes:

  • Authentication endpoints
  • CRUD operations for field management
  • Payment processing routes
  • AI analysis endpoints

🀝 Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“œ License

Distributed under the MIT License. See LICENSE for more information.

πŸ“§ Contact

Vansh Kapoor


Admin Panel Features

User Management

  • Approve/Disapprove Farmers: Admins can approve or disapprove farmer accounts.
  • Role Management: Assign roles (Admin, Farmer) to users.
  • Activity Tracking: View user login history and activity logs.

Analytics Dashboard

  • System Metrics: Monitor total users, active subscriptions, and revenue.
  • Crop Health: View AI-generated crop health reports.
  • Subscription Trends: Track subscription growth and churn rates.

Subscription Management

  • View Subscriptions: List all active, inactive, and trialing subscriptions.
  • Modify Plans: Upgrade or downgrade user subscription plans.
  • Cancel Subscriptions: Cancel subscriptions on behalf of users.

Security Settings

  • Password Policies: Configure password complexity requirements.
  • Session Management: Set session timeout and logout policies.
  • Audit Logs: Track changes made by admins and users.

Logs & Audits

  • User Actions: Log all user actions, including login attempts and profile updates.
  • System Events: Track system events, such as API requests and errors.
  • Audit Trails: Maintain a detailed audit trail for compliance and troubleshooting.

Admin Panel Screenshots

User Management

User Management

Analytics Dashboard

Analytics Dashboard

Subscription Management

Subscription Management


About

The Smart Agriculture Management System is a modern, full-stack application designed to streamline agricultural operations, provide AI-driven insights, and facilitate seamless payment processing. Built with Next.js (TypeScript) for the frontend and Node.js/Express.js for the backend, this system empowers farmers and administrators with powerful too

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published