Revolutionizing the farm-to-table ecosystem by connecting local producers, grocers, and consumers through a unified, high-performance digital marketplace.
- οΏ½ Table of Contents
- π Overview
- β¨ Key Features
- π οΈ Tech Stack & Architecture
- π Project Structure
- π Environment Variables
- π Getting Started
- π§ Usage
- π€ Contributing
- How to Contribute
- Development Guidelines
- π License
- What this means:
Nerthus is a sophisticated, full-stack digital marketplace designed to bridge the gap between agricultural producers and the modern consumer. Built with a focus on local economy and supply chain transparency, it provides a robust platform where farmers can list produce, grocers can manage inventory, and buyers can access fresh, high-quality goods with the convenience of modern e-commerce.
The agricultural supply chain is often plagued by fragmentation, where local farmers struggle to reach a wider audience and consumers lack direct access to fresh produce. Traditional systems are bogged down by intermediaries, leading to increased costs and decreased freshness. Nerthus solves this by providing a direct, transparent, and secure digital channel that empowers producers and simplifies the procurement process for everyone involved.
By leveraging a Component-based Architecture and Micro-services-inspired API routing, Nerthus ensures a scalable environment that can handle complex multi-user interactions. Whether it is a farmer updating their seasonal harvest or a buyer tracking a real-time order, the platform provides a seamless, high-integrity user experience.
Nerthus is built around four primary pillars: Discovery, Transaction, Management, and Security.
- Dynamic Produce Discovery: Utilize the
ExploreandCategoryFiltercomponents to find exactly what you need, from seasonal vegetables to organic staples. - Integrated Shopping Cart: A persistent cart experience powered by
useCartandCartContext, allowing users to manage selections effortlessly across sessions. - Real-time Order Tracking: Stay informed with a dedicated tracking system (
/api/payments/track-order) that monitors the journey of your produce from the farm to your doorstep.
- Dedicated Professional Profiles: Specific features for Farmers (
app/features/farmer) and Grocers (app/features/grocer) to showcase their offerings and build brand trust. - Inventory Control: Sophisticated models (
produce.model.ts) allow producers to manage stock levels, pricing, and produce details with granular control. - Engagement Tools: Built-in "Follow" functionality (
useFollow.ts) enables buyers to stay connected with their favorite local producers for updates on new harvests.
- Razorpay Integration: Professional-grade payment processing via
PaymentButton.tsxandrazorpaydependency, ensuring all transactions are encrypted and compliant. - Automated Order Lifecycle: From
create-ordertoverifyand evenreturn-orderorcancel-order, the API handles the entire financial lifecycle securely. - JWT-Based Security: Multi-layered authentication using JSON Web Tokens and
better-authto protect user data and transaction history.
- Responsive Visuals: A "Mobile-First" approach using Tailwind CSS and
framer-motionfor smooth, cinematic transitions and layouts. - Optimized Data Fetching: Utilizes
@tanstack/react-queryto ensure that produce listings and profile data are always fresh without unnecessary server load.
Nerthus utilizes a modern, industry-standard stack selected for performance, type safety, and scalability.
| Technology | Purpose | Why it was Chosen |
|---|---|---|
| React 19 / Next.js 16 | Frontend Framework | Provides Server-Side Rendering (SSR) and efficient client-side navigation. |
| TypeScript | Programming Language | Ensures type safety and reduces runtime errors in complex data models. |
| MongoDB / Mongoose | Database & ODM | Flexible schema design for varied produce types and rapid iteration. |
| Redux Toolkit | State Management | Manages complex global states like cart contents, user auth, and follows. |
| Razorpay | Payment Gateway | Industry-leading payment infrastructure for secure, localized transactions. |
| Cloudinary | Image Management | High-performance CDN for serving optimized images of fresh produce. |
| Tailwind CSS | Styling | Utility-first CSS for rapid, consistent, and responsive UI development. |
| Docker | Containerization | Ensures consistent environment across development, staging, and production. |
The project follows a modular, feature-based structure to separate concerns and improve maintainability.
Nerthus-App/
βββ π app/ # Next.js App Router (Pages & API)
β βββ π api/ # Serverless API endpoints
β β βββ π auth/ # Login, Register, Logout, Refresh
β β βββ π produce/ # Produce details and listings
β β βββ π payments/ # Razorpay integration & Order tracking
β β βββ π buyer/farmer/grocer/ # Role-specific profile routes
β βββ π features/ # Domain-specific UI logic
β β βββ π auth/ # Authentication screens
β β βββ π checkout/ # Payment and shipping flows
β β βββ π orders/ # Order history and success pages
β βββ π layout.tsx # Main application wrapper
βββ π components/ # Reusable UI building blocks
β βββ π Navbar.tsx # Global navigation
β βββ π ProduceCard.tsx # Individual product display
β βββ π CheckoutForm.tsx # Payment input handling
β βββ π ProtectedRoute.tsx # Auth-guarded component wrapper
βββ π hooks/ # Custom React hooks
β βββ π useCart.ts # Cart logic and persistence
β βββ π useProduceList.ts # Data fetching for produce
β βββ π useAuthForm.ts # Form handling for auth
βββ π model/ # Mongoose Database Schemas
β βββ π user.model.ts # Base user identity
β βββ π produce.model.ts # Produce metadata and pricing
β βββ π order.model.ts # Transaction and shipping records
βββ π store/ # Redux Toolkit slices and store config
βββ π lib/ # Shared utilities (DB, Auth, API)
βββ π services/ # External service integrations (Cloudinary)
βββ π docker-compose.yml # Multi-container orchestration
βββ π Dockerfile # Environment containerization
βββ π next.config.ts # Next.js framework configuration
βββ π package.json # Dependency and script definitions
To run Nerthus locally or in production, the following environment variables are required. Refer to .env.example for the template.
| Variable | Description |
|---|---|
NODE_ENV |
Current environment (development/production). |
PORT |
The port on which the server will run. |
MONGODB_URI |
Connection string for the MongoDB instance. |
JWT_ACC_SECRECT |
Secret key for generating Access Tokens. |
JWT_REF_SECRECT |
Secret key for generating Refresh Tokens. |
JWT_ACC_EXPIRES_IN |
Expiration time for Access Tokens. |
CLOUDINARY_CLOUD_NAME |
Cloudinary account identifier for media. |
CLOUDINARY_API_KEY |
API Key for authenticated media uploads. |
CLOUDINARY_API_SECRET |
Secret key for Cloudinary API. |
- Node.js: v20 or higher
- NPM: v10 or higher
- MongoDB: A running instance (Local or Atlas)
- Docker: (Optional) For containerized deployment
-
Clone the Repository
git clone https://github.com/Bharatdwaj3/Nerthus-The-Grocery-App.git cd Nerthus-The-Grocery-App -
Install Dependencies
npm install
-
Configure Environment Create a
.envfile in the root directory and populate it with the variables listed in the Environment Variables section. -
Database Migration (Prisma)
npx prisma generate
-
Run Development Server
npm run dev
The application will be available at
http://localhost:3000. -
Build for Production
npm run build npm run start
If you prefer containerization, use the provided Docker configuration:
docker-compose up --build- Buyers: Can browse the
Explorepage, add items to theCart, and proceed through theCheckoutflow. - Farmers/Grocers: Can access their specific dashboards to list new produce or manage existing inventory through the
profileAPI endpoints.
Individual produce items are displayed using the ProduceGrid. Clicking on a ProduceCard navigates to the dynamic route app/features/produce/[id]/page.tsx, where detailed information is fetched via useProduceDetail.
- Add items to the cart using the
useCarthook. - Navigate to
/features/checkout. - The
PaymentButtoninitiates the Razorpay checkout modal. - Upon successful payment, the user is redirected to the
order-successpage.
We welcome contributions to improve Nerthus! Your input helps make this project better for everyone in the agricultural community.
- Fork the repository - Click the 'Fork' button at the top right of this page.
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes - Improve code, documentation, or design.
- Test thoroughly - Ensure all functionality works as expected.
npm run lint
- Commit your changes - Write clear, descriptive commit messages.
git commit -m 'Add: Amazing new feature that does X' - Push to your branch
git push origin feature/amazing-feature
- Open a Pull Request - Submit your changes for review.
- β Follow the existing TypeScript conventions and ESLint rules.
- π Document all new hooks and components in the
README.mdif necessary. - π§ͺ Ensure all API routes handle errors gracefully using the custom error components in
errors/. - π― Keep components modular and reusable within the
components/directory.
This project is licensed under the MIT License - see the LICENSE file for complete details.
- β Commercial use: You can use this project commercially.
- β Modification: You can modify the code for your own needs.
- β Distribution: You can distribute this software freely.
- β Private use: You can use this project privately.
β οΈ Liability: The software is provided "as is", without warranty of any kind.
Made with β€οΈ for a Greener Future by the Nerthus Team