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.
- Problem Statement
- Features
- Tech Stack
- System Architecture
- API Documentation
- Installation
- Environment Variables
- Deployment
- Screenshots
- Contributing
- License
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
- User registration and login with JWT
- Role-based access control (Admin/User/Seller)
- Secure logout functionality
- Full CRUD operations for products
- Product categorization and inventory management
- Stock availability toggle for sellers
- Advanced product search functionality
- Multi-parameter filtering system
- Product sorting options
- Pagination for better performance
- Real-time cart management
- Multiple address support
- Dual payment options:
- Cash on Delivery (COD)
- Online payment via Stripe
- Order tracking for users
- Seller dashboard for order fulfillment
- Order history and status updates
- Responsive design with Tailwind CSS
- Intuitive navigation with React Router
- Fast and interactive user interface
| 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 |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| 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 |
| 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 |
| 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) |
| Endpoint | Method | Description | Access |
|---|---|---|---|
/api/cart/update |
POST | Update cart items | Authenticated |
| Endpoint | Method | Description | Access |
|---|---|---|---|
/api/address/add |
POST | Add new address | Authenticated |
/api/address/get |
GET | Get all addresses | Authenticated |
| 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) |
- Node.js (v14 or higher)
- MongoDB Atlas account
- Stripe account for payment integration
git clone https://github.com/yourusername/greencart.git
cd greencartcd backend
npm installCreate 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:3000Start the backend server:
npm startcd frontend
npm installCreate a .env file in the frontend directory:
REACT_APP_API_URL=http://localhost:5000
REACT_APP_STRIPE_PUBLIC_KEY=your_stripe_public_keyStart the frontend:
npm startThe application will be available at http://localhost:3000
| 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 |
| Variable | Description |
|---|---|
REACT_APP_API_URL |
Backend API base URL |
REACT_APP_STRIPE_PUBLIC_KEY |
Stripe publishable key |
- Push your code to GitHub
- Connect your repository to Vercel
- Configure environment variables
- Deploy
-
Push your code to GitHub
-
Make account on Render and deploy as Web Service
-
Configure environment variables
-
Deploy
-
Deploy to Vercel following the same steps as frontend
- Create a cluster on MongoDB Atlas
- 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
- For Render: Add
- Create database user with read/write permissions
- Get connection string and add to environment variables
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/YourFeature) - Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/YourFeature) - Open a Pull Request
- Aman Bhatnagar - Lead Developer - GitHub
For any queries or suggestions, please reach out:
- Email: aman.2024@nst.rishihood.edu.in
- GitHub: @Aman739-code
- LinkedIn: Aman Bhatnagar
- MongoDB Atlas for database hosting
- Vercel for seamless deployment
- Stripe for payment processing
- The MERN stack community