GreenCart is a full-stack farmer marketplace built with Next.js 14 App Router, Tailwind CSS, MongoDB-ready models, NextAuth credentials auth, and a small Express API entry point for standalone backend use.
It is designed for:
- Farmers who want to sell directly to customers, retailers, and wholesalers
- Buyers who need clean product discovery, cart, checkout, orders, and account flows
- Admin teams who need seller verification, operational metrics, and catalog oversight
- White, modern ecommerce UI inspired by Flipkart, Amazon, and Meesho
- Responsive home, catalog, product, cart, checkout, orders, account, farmer, and admin pages
- NextAuth credentials login with role-aware session fields
- MongoDB model layer for
users,farmers,products,categories,carts,orders,reviews,addresses,wishlist, andanalytics data.gov.inintegration helpers with cache + fallback dataset support- Debounced live search suggestions
- Zustand-powered cart, wishlist, and client-side recent order persistence
- SEO basics with metadata,
sitemap.xml, androbots.txt - Vercel-friendly Next.js routes plus optional Express backend at
api/server.ts
- Frontend: Next.js 14, React 18, Tailwind CSS
- Backend: Next.js Route Handlers, Express.js
- Database: MongoDB + Mongoose
- Auth: NextAuth credentials with JWT sessions
- State: Zustand
- Validation: Zod
- Buyer:
buyer@greencart.in/password123 - Farmer:
farmer@greencart.in/password123 - Admin:
admin@greencart.in/password123
- Install dependencies:
npm install- Copy environment variables:
cp .env.example .env.local- Fill in at least:
NEXTAUTH_SECRETNEXTAUTH_URLMONGODB_URIDATA_GOV_API_KEYDATA_GOV_MANDI_RESOURCE_ID
- Start the Next.js app:
npm run dev- Optional: start the standalone Express API:
npm run api:devThe frontend runs on http://localhost:3000. The Express API runs on http://localhost:4000 unless EXPRESS_PORT is set.
- The UI works with fallback mock data when MongoDB or
data.gov.incredentials are not configured. - Route handlers and service functions are organized so you can replace the fallback arrays with real Mongoose queries incrementally.
- The registration route demonstrates password hashing, but the sample project does not persist new users until MongoDB write logic is added.
npm run dev
npm run api:dev
npm run lint
npm run typecheck
npm run buildapp/
components/
lib/
models/
hooks/
context/
utils/
api/
public/
styles//Home page/loginLogin and signup/productsProduct listing/products/[slug]Product detail/cartCart/checkoutCheckout/ordersOrder history/accountAccount center/farmer/dashboardFarmer dashboard/adminAdmin panel
GET /api/productsGET /api/products/[id]GET /api/search?q=...GET /api/marketGET /api/weatherGET /api/ordersPOST /api/ordersGET /api/orders/[id]GET /api/orders/[id]/invoicePOST /api/users/registerGET /api/farmer/productsPOST /api/farmer/productsGET /api/admin/overview
usersfarmersproductscategoriescartsordersreviewsaddresseswishlistanalytics
- Push the repo to GitHub.
- Import it into Vercel.
- Set environment variables from
.env.example. - Deploy.
- Create a cluster.
- Create a database user and allow the Vercel IP range or trusted IPs.
- Copy the connection string into
MONGODB_URI.
- Create an API key.
- Choose the resource IDs you want for mandi, rainfall, or schemes widgets.
- Add those resource IDs to your Vercel and local env files.
- Replace fallback mock arrays with real MongoDB reads and writes
- Add Razorpay or Stripe server-side payment confirmation
- Persist cart and wishlist server-side per user
- Add OTP and social login providers
- Add image uploads via Cloudinary or S3
- Add multilingual content dictionaries beyond the shared nav layer
- Add real shipment tracking and notification delivery