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.
- π 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
- π 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)
- π¨βπΌ 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.
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
- Node.js β₯18.x
- MongoDB Atlas account
- Stripe account
- Git
- Clone the repository:
git clone https://github.com/liegen47/smart-agriculture.git
cd smart-agriculture- Install dependencies:
# Frontend
cd frontend && npm install
# Backend
cd ../backend && npm install- 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...- Run the application:
# Backend
cd backend && npm start
# Frontend (in new terminal)
cd frontend && npm run devAccess the application at:
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:5000 - API Docs:
http://localhost:5000/api-docs
- Create a Stripe account at stripe.com
- Configure webhook in Stripe Dashboard:
- Endpoint URL:
http://localhost:5000/api/payments/webhook - Events:
checkout.session.completed
- Endpoint URL:
- Test using Stripe test cards:
- Successful payment:
4242 4242 4242 4242 - Payment failure:
4000 0000 0000 0002
- Successful payment:
- Deploy to Render or Heroku
- Set production environment variables:
NODE_ENV=production MONGO_URI=your_production_mongo_uri
- Configure CORS for frontend domain
- Deploy to Vercel or Netlify
- Set environment variables:
NEXT_PUBLIC_API_URL=https://your-backend-domain.com NEXT_PUBLIC_STRIPE_PUBLIC_KEY=your_live_stripe_key
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
Interactive API documentation available at /api-docs endpoint. Includes:
- Authentication endpoints
- CRUD operations for field management
- Payment processing routes
- AI analysis endpoints
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Vansh Kapoor
- Email: [email protected]
- GitHub: @liegen47
- LinkedIn: vanshkapoor418
- 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.
- 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.
- 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.
- Password Policies: Configure password complexity requirements.
- Session Management: Set session timeout and logout policies.
- Audit Logs: Track changes made by admins and users.
- 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.