FarmFresh is a full-stack marketplace that connects customers with local farmers. It includes product browsing, farmer profiles, ordering, reviews, favorites, messaging, and a farmer dashboard experience, all powered by Next.js, MongoDB, and Tailwind CSS.
- Customer and farmer authentication with NextAuth.
- Product catalog with categories, reviews, and ratings.
- Farmer profiles with listings and performance insights.
- Cart, checkout, and order management flows.
- Favorites and saved items.
- Messaging between customers and farmers.
- Analytics and dashboards for farmer operations.
- Framework: Next.js (App Router), React 18
- Styling: Tailwind CSS
- Data: MongoDB + Mongoose
- Auth: NextAuth
- Data fetching: React Query (@tanstack/react-query)
- Email: Resend
- Charts: Chart.js, Recharts, Nivo
Install dependencies and run the dev server:
npm install
npm run devThen open http://localhost:3000.
npm run dev
npm run build
npm run start
npm run lintCreate a .env.local file in the project root and provide the following values:
NEXTAUTH_URLNEXTAUTH_SECRETGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETMONGODB_URIJWT_SECRETRESEND_API_KEY
Keep
.env.localprivate and rotate any exposed secrets.
For testing purposes, you can use the following sample accounts:
- Farmer:
kazi@gmail.com| Password:123456 - Customer:
shakila@gmail.com| Password:123456
app/ # App Router pages and API routes
api/ # REST endpoints (auth, products, orders, etc.)
components/ # Shared UI components
contexts/ # React context providers
hooks/ # React Query and domain hooks
lib/ # API helpers, DB, cache, utils
models/ # Mongoose models
providers/ # App-wide providers
utils/ # Small utilities
/Home page with highlights, featured products, and top farmer./productsProduct listing with search and filters./farmersFarmer listing and profiles./cartCart and checkout flow./ordersOrders management./messagesMessaging inbox./profileUser profile./dashboardFarmer dashboard and analytics.
GET /api/homeAggregated data for the home page.GET/POST /api/productsProduct search and creation.GET/POST /api/farmersFarmer listing and updates.GET/POST /api/ordersOrder creation and status updates.GET/POST /api/reviewsReviews and rating updates.GET /api/categoriesCategory counts for the home and filters.GET/POST /api/cartCart operations.GET/POST /api/favoritesFavorites management.GET/POST /api/messagesMessaging endpoints.GET/POST /api/auth/*Auth handlers (NextAuth).
UserFarmerProductOrderReviewCartFavoriteConversationMessage
- Some API routes use lightweight in-memory caching for repeated requests.
- Linting uses
next lintwith the project ESLint config.
Build and start the app:
npm run build
npm run startDeploy to any Node.js hosting that supports Next.js. Vercel provides first-class support.