Skip to content

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ GreenCart – Grocery Delivery Platform

A full-stack grocery delivery web application built with the MERN stack that connects customers with local stores for seamless online shopping and doorstep delivery.

MERN Stack Status


πŸ“‹ Table of Contents


🎯 Problem Statement

The project aims to develop a Grocery Delivery Web Application using the MERN stack to simplify online grocery shopping. The platform connects customers with local stores for easy ordering and doorstep delivery, featuring:

  • Convenience: Shop from home with doorstep delivery
  • Time-Saving: Quick ordering process with smart search and filters
  • Secure Payments: Integrated Stripe payment gateway and COD options
  • Local Vendor Support: Digital access for neighborhood stores

✨ Features

πŸ” Authentication & Authorization

  • User registration and login with JWT
  • Role-based access control (Admin/User/Seller)
  • Secure logout functionality

πŸ›οΈ Product Management

  • Full CRUD operations for products
  • Product categorization and inventory management
  • Stock availability toggle for sellers

πŸ” Enhanced Shopping Experience

  • Advanced product search functionality
  • Multi-parameter filtering system
  • Product sorting options
  • Pagination for better performance

πŸ›’ Cart & Checkout

  • Real-time cart management
  • Multiple address support
  • Dual payment options:
    • Cash on Delivery (COD)
    • Online payment via Stripe

πŸ“¦ Order Management

  • Order tracking for users
  • Seller dashboard for order fulfillment
  • Order history and status updates

🎨 Modern UI/UX

  • Responsive design with Tailwind CSS
  • Intuitive navigation with React Router
  • Fast and interactive user interface

πŸ› οΈ Tech Stack

Layer Technologies
Frontend React.js, React Router, Axios, Tailwind CSS
Backend Node.js, Express.js
Database MongoDB
Authentication JWT (JSON Web Tokens)
Payment Stripe Payment Gateway
Hosting Vercel (Frontend), Render (Backend), MongoDB Atlas

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Frontend                            β”‚
β”‚                  (React.js + React Router)                  β”‚
β”‚                    Hosted on Vercel                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β”‚ HTTP Requests (Axios)
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Backend                             β”‚
β”‚                   (Node.js + Express.js)                    β”‚
β”‚                    Hosted on Render                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β”‚ MongoDB Driver
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Database                             β”‚
β”‚                         MongoDB                             β”‚
β”‚                   Hosted on MongoDB Atlas                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“š API Documentation

πŸ‘€ User Endpoints

Endpoint Method Description Access
/api/user/register POST Register new user Public
/api/user/login POST User login Public
/api/user/is-auth GET Authenticate user Authenticated
/api/user/logout GET Logout user Authenticated

πŸͺ Seller Endpoints

Endpoint Method Description Access
/api/seller/login POST Seller login Public
/api/seller/is-auth GET Authenticate seller Authenticated
/api/seller/logout GET Logout seller Authenticated

πŸ“¦ Product Endpoints

Endpoint Method Description Access
/api/product/add POST Add new product Authenticated (Seller)
/api/product/list GET Get all products Public
/api/product/:id GET Get product by ID Public
/api/product/stock POST Toggle stock availability Authenticated (Seller)

πŸ›’ Cart Endpoints

Endpoint Method Description Access
/api/cart/update POST Update cart items Authenticated

πŸ“ Address Endpoints

Endpoint Method Description Access
/api/address/add POST Add new address Authenticated
/api/address/get GET Get all addresses Authenticated

πŸ’³ Order Endpoints

Endpoint Method Description Access
/api/order/cod POST Place COD order Authenticated
/api/order/stripe POST Process Stripe payment Authenticated
/api/order/user GET Get user orders Authenticated
/api/order/seller GET Get seller orders Authenticated (Seller)

πŸš€ Installation

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB Atlas account
  • Stripe account for payment integration

Clone the Repository

git clone https://github.com/yourusername/greencart.git
cd greencart

Backend Setup

cd backend
npm install

Create a .env file in the backend directory:

PORT=5000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
STRIPE_SECRET_KEY=your_stripe_secret_key
FRONTEND_URL=http://localhost:3000

Start the backend server:

npm start

Frontend Setup

cd frontend
npm install

Create a .env file in the frontend directory:

REACT_APP_API_URL=http://localhost:5000
REACT_APP_STRIPE_PUBLIC_KEY=your_stripe_public_key

Start the frontend:

npm start

The application will be available at http://localhost:3000


πŸ” Environment Variables

Backend Variables

Variable Description
PORT Server port number
MONGODB_URI MongoDB connection string
JWT_SECRET Secret key for JWT tokens
STRIPE_SECRET_KEY Stripe secret API key
FRONTEND_URL Frontend application URL

Frontend Variables

Variable Description
REACT_APP_API_URL Backend API base URL
REACT_APP_STRIPE_PUBLIC_KEY Stripe publishable key

🌐 Deployment

Frontend Deployment (Vercel)

  1. Push your code to GitHub
  2. Connect your repository to Vercel
  3. Configure environment variables
  4. Deploy

Backend Deployment (Render)

  1. Push your code to GitHub

  2. Make account on Render and deploy as Web Service

  3. Configure environment variables

  4. Deploy

  5. Deploy to Vercel following the same steps as frontend

Database (MongoDB Atlas)

  1. Create a cluster on MongoDB Atlas
  2. Whitelist IP addresses:
    • For Render: Add 0.0.0.0/0 (allow access from anywhere)
    • Or find Render's outbound IP addresses and whitelist them
  3. Create database user with read/write permissions
  4. Get connection string and add to environment variables

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

πŸ‘₯ Team

  • Aman Bhatnagar - Lead Developer - GitHub

πŸ“ž Contact

For any queries or suggestions, please reach out:


πŸ™ Acknowledgments

  • MongoDB Atlas for database hosting
  • Vercel for seamless deployment
  • Stripe for payment processing
  • The MERN stack community

Made with ❀️ by Aman Bhatnagar

About

A full-stack MERN grocery delivery app with JWT auth, Stripe payments, and role-based access for users and sellers. Deployed live on Vercel and Render with MongoDB Atlas.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages