A production-ready, full-stack e-commerce application for plant retailers built with the MERN stack. Features secure authentication, real-time cart management, order processing, and product reviews with a modern, responsive interface.
Live Application: https://green-garden-mern.vercel.app
Green Garden delivers a complete e-commerce solution with JWT authentication, RESTful API architecture, and MongoDB data persistence. Built following industry best practices with microservices deployment architecture.
- Secure Authentication: JWT-based authentication with bcrypt password encryption
- Product Catalog: Browse and search plant inventory with detailed product pages
- Shopping Cart: Real-time cart management with quantity updates and price calculation
- Order Management: Complete checkout flow with order tracking and history
- Review System: Customer reviews with star ratings and average score calculation
- Admin Dashboard: Product and order management for administrators
- Responsive Design: Mobile-first UI optimized for all device sizes
Frontend
- React.js 18.x with functional components and hooks
- Redux Toolkit for state management
- React Router v6 for client-side routing
- Axios for HTTP requests with interceptors
- React Hook Form for validation
- Lucide React for icons
Backend
- Node.js with Express.js framework
- MongoDB with Mongoose ODM
- JWT for authentication
- bcrypt for password hashing
- CORS middleware
Deployment
- Frontend: Vercel (serverless)
- Backend: Render (Node.js container)
- Database: MongoDB Atlas (managed cloud)
┌──────────────────────────────────────────────────────┐ │ Client Layer (React SPA) │ │ Redux Store │ React Router │ Axios Client │ └────────────────────────┬─────────────────────────────┘ │ HTTPS/REST ┌────────────────────────▼─────────────────────────────┐ │ API Layer (Express.js) │ │ Routes │ Controllers │ Middleware │ Auth │ └────────────────────────┬─────────────────────────────┘ │ ┌────────────────────────▼─────────────────────────────┐ │ Data Layer (MongoDB Atlas) │ │ Users │ Plants │ Orders │ Reviews │ └──────────────────────────────────────────────────────┘
green-garden-mern/ │ ├── reactapp/ # Frontend │ ├── src/ │ │ ├── components/ # React components │ │ ├── pages/ # Page components │ │ ├── redux/ # Redux store & slices │ │ ├── apiConfig.js # API configuration │ │ └── App.js │ └── package.json │ ├── nodeapp/ # Backend │ ├── controllers/ # Business logic │ ├── models/ # Mongoose schemas │ │ ├── User.js │ │ ├── Plant.js │ │ ├── Order.js │ │ └── Review.js │ ├── routes/ # API routes │ │ ├── userRoutes.js │ │ ├── plantRoutes.js │ │ ├── orderRoutes.js │ │ └── reviewRoutes.js │ ├── middleware/ # Auth & validation │ └── index.js │ └── README.md
- User registration with email validation
- JWT token-based authentication
- Password encryption with bcrypt (10 salt rounds)
- Protected routes with authentication middleware
- Role-based access control (user/admin)
- Complete product catalog with search and filtering
- Detailed product pages with images and descriptions
- Admin CRUD operations for inventory
- Image upload and storage
- Category-based organization
- Add/remove items with real-time updates
- Quantity management
- Automatic price calculation
- Cart persistence across sessions
- Complete checkout workflow
- Order confirmation and tracking
- Order history for users
- Status management (pending, processing, shipped, delivered)
- Admin order management interface
- Star-based rating system (1-5 stars)
- Written reviews for purchased products
- Average rating calculation per product
- User-specific review management
- Node.js >= 14.0.0
- npm >= 6.0.0
- MongoDB Atlas account
- Git
1. Clone Repository
git clone https://github.com/manishpxl/green-garden-mern.git
cd green-garden-mern2. Backend Setup
cd nodeapp
npm installCreate .env file in nodeapp/:
PORT=8080
MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/greenGarden
JWT_SECRET=<your-secure-secret-key>
CLIENT_URL=http://localhost:3000Start backend:
npm startBackend runs at http://localhost:8080
3. Frontend Setup
cd reactapp
npm installUpdate src/apiConfig.js if needed:
const apiConfig = {
baseUrl: process.env.REACT_APP_DB_API_URL || 'http://localhost:8080/api/db',
fsBaseUrl: process.env.REACT_APP_FS_API_URL || 'http://localhost:8080/api/fs'
};Start frontend:
npm startFrontend runs at http://localhost:3000
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/db/users/register |
Register new user | No |
| POST | /api/db/users/login |
User login | No |
| GET | /api/db/users/profile |
Get user profile | Yes |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/db/plants |
Get all plants | No |
| GET | /api/db/plants/:id |
Get plant details | No |
| POST | /api/db/plants |
Create plant | Admin |
| PUT | /api/db/plants/:id |
Update plant | Admin |
| DELETE | /api/db/plants/:id |
Delete plant | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/db/orders |
Get user orders | Yes |
| POST | /api/db/orders |
Create order | Yes |
| GET | /api/db/orders/:id |
Get order details | Yes |
| PUT | /api/db/orders/:id |
Update order status | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/db/reviews/:plantId |
Get product reviews | No |
| POST | /api/db/reviews |
Create review | Yes |
| DELETE | /api/db/reviews/:id |
Delete review | Yes |
| Variable | Description | Required |
|---|---|---|
PORT |
Server port number | Yes |
MONGODB_URI |
MongoDB connection string | Yes |
JWT_SECRET |
JWT signing secret key | Yes |
CLIENT_URL |
Frontend URL for CORS | Yes |
| Variable | Description | Required |
|---|---|---|
REACT_APP_DB_API_URL |
Backend API URL | Optional |
REACT_APP_FS_API_URL |
File system API URL | Optional |
- Frontend: https://green-garden-mern.vercel.app
- Backend: https://green-garden-mern.onrender.com
Vercel (Frontend)
- Connect GitHub repository to Vercel
- Configure build settings:
- Root Directory:
reactapp - Build Command:
npm run build - Output Directory:
build
- Root Directory:
- Add environment variables
- Deploy
Render (Backend)
- Create Web Service on Render
- Connect repository
- Configure:
- Root Directory:
nodeapp - Build Command:
npm install - Start Command:
npm start
- Root Directory:
- Add environment variables
- Deploy
MongoDB Atlas (Database)
- Create MongoDB Atlas cluster
- Configure network access (0.0.0.0/0)
- Create database user
- Copy connection string to backend env
- Password hashing with bcrypt (10 salt rounds)
- JWT tokens with secure secret keys
- CORS configuration with origin whitelist
- Environment variable protection
- Input validation and sanitization
- Protected API routes
- MongoDB injection prevention via Mongoose
- React code splitting and lazy loading
- MongoDB indexing on frequently queried fields
- Database connection pooling
- CDN delivery via Vercel Edge Network
- Optimized bundle sizes
Frontend
npm start # Development server
npm run build # Production build
npm test # Run testsBackend
npm start # Start server
npm run dev # Development mode with nodemonContributions are welcome. Follow these steps:
- Fork the repository
- Create feature branch (
git checkout -b feature/enhancement) - Commit changes (
git commit -m "Add feature") - Push to branch (
git push origin feature/enhancement) - Open Pull Request
- Backend on Render free tier may experience cold starts (10-15 seconds)
- Image uploads limited to 50MB
This project is open source under the MIT License.
Manish Kumar
- Portfolio: https://manish-kumar-portfolio-website.netlify.app
- GitHub: https://github.com/manishpxl
- LinkedIn: https://linkedin.com/in/manish-kumar-7b0535229
- Twitter: https://x.com/manishpxl
Last Updated: May 2026