Status: β Full Stack Complete | π¦ Ready for Deployment | π Production-Grade Code
A production-grade MERN eCommerce application built with industry best practices:
- β 32 API Endpoints - Complete CRUD operations
- β 4 Core Modules - Auth, Products, Cart, Orders
- β Modern React Frontend - Redux, React Router, Responsive UI
- β Enterprise Security - JWT, bcrypt, rate limiting, CORS
- β Advanced Admin Panel - Analytics, inventory, user management
- β Production Ready - Error handling, logging, validation
- β Scalable Architecture - MVC pattern, service layer, middleware stack
Node.js v14+
MongoDB (local or Atlas)
npm or yarncd backend
npm install
cp .env.example .env
# Update MONGO_URI in .env
npm run seed # Seed sample data
npm run dev # Development servercd frontend
npm install
npm start # Development server on http://localhost:3000
npm run build # Production build# Backend
cd backend
npm run build # If using build script
npm start
# Frontend (serve build folder)
cd frontend
npm run build
npx serve -s build -l 3000POST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- User loginGET /api/v1/auth/me- Get current userPOST /api/v1/auth/logout- Logout
GET /api/v1/products- Get all products (with filters)GET /api/v1/products/featured- Get featured productsGET /api/v1/products/:id- Get product by IDGET /api/v1/products/categories- Get categories
GET /api/v1/cart- Get user cartPOST /api/v1/cart/add- Add item to cartPUT /api/v1/cart/update/:itemId- Update cart itemDELETE /api/v1/cart/remove/:itemId- Remove from cart
POST /api/v1/orders/create- Create orderGET /api/v1/orders/my-orders- Get user ordersGET /api/v1/orders/:orderId- Get order details
Backend:
- Node.js + Express.js
- MongoDB + Mongoose
- JWT Authentication
- bcrypt Password Hashing
- Express Rate Limiting
- CORS + Helmet Security
- Morgan Logging
- Joi Validation
Frontend:
- React 18 + React Router
- Redux Toolkit + Redux Persist
- Axios for API calls
- React Toastify
- React Icons
- CSS Modules
eCommerce-Website/
βββ backend/
β βββ controllers/ # Business logic
β βββ models/ # MongoDB schemas
β βββ routes/ # API routes
β βββ middleware/ # Custom middleware
β βββ services/ # Business services
β βββ utils/ # Helper functions
β βββ scripts/ # Database seeding
βββ frontend/
β βββ src/
β β βββ components/ # Reusable components
β β βββ pages/ # Page components
β β βββ store/ # Redux store
β β βββ services/ # API services
β βββ public/ # Static assets
βββ README.md
- JWT token authentication
- Password hashing with bcrypt
- Rate limiting on all routes
- CORS protection
- Helmet security headers
- Input validation and sanitization
- SQL injection prevention
- XSS protection
- User registration and login
- Product browsing with filters
- Shopping cart functionality
- Order placement and tracking
- User profile management
- Wishlist functionality
- User management
- Product CRUD operations
- Order management
- Analytics dashboard
- Inventory management
The application is production-ready and can be deployed to:
- Backend: Heroku, DigitalOcean, AWS, Vercel
- Frontend: Netlify, Vercel, AWS S3
- Database: MongoDB Atlas
Create .env file in backend root:
MONGO_URI=mongodb://localhost:27017/ecommerce
PORT=5001
NODE_ENV=production
JWT_SECRET=your_super_secret_key
JWT_EXPIRE=7d
REFRESH_TOKEN_SECRET=your_refresh_secret
REFRESH_TOKEN_EXPIRE=30d
CORS_ORIGIN=https://yourdomain.comMIT License - feel free to use this project for learning and commercial purposes.
- Fork the repository
- Create feature branch
- Commit changes
- Push to branch
- Create Pull Request
Happy Coding! π
Server runs at: **http://localhost:5000**
### Test an Endpoint
```bash
curl http://localhost:5000/api/v1/products
backend/
βββ controllers/ # Request handlers (32 functions)
βββ services/ # Business logic layer
βββ routes/v1/ # API endpoints (v1 versioning)
βββ models/ # MongoDB schemas (4 models)
βββ middleware/ # Auth, errors, rate limiting
βββ config/ # Database connection
βββ utils/ # Logger, JWT, password, validation
βββ server.js # Express app entry
βββ package.json # Dependencies
βββ .env # Environment variables
POST /api/v1/auth/register
POST /api/v1/auth/login
GET /api/v1/auth/me
POST /api/v1/auth/logout
POST /api/v1/auth/refresh-token
PUT /api/v1/auth/update-profile
POST /api/v1/auth/change-password
GET /api/v1/auth/users/all (Admin)
PUT /api/v1/auth/users/:userId/role (Admin)
DELETE /api/v1/auth/users/:userId (Admin)
GET /api/v1/products (Search, Filter, Sort, Paginate)
GET /api/v1/products/:id
GET /api/v1/products/categories
GET /api/v1/products/brands
GET /api/v1/products/category/:category
POST /api/v1/products (Admin)
PUT /api/v1/products/:id (Admin)
DELETE /api/v1/products/:id (Admin)
GET /api/v1/cart
GET /api/v1/cart/summary
POST /api/v1/cart/add
PUT /api/v1/cart/:itemId
DELETE /api/v1/cart/:itemId
DELETE /api/v1/cart (Clear)
POST /api/v1/orders
POST /api/v1/orders/verify-payment
GET /api/v1/orders
GET /api/v1/orders/:orderId
GET /api/v1/orders/track/:orderId
DELETE /api/v1/orders/:orderId/cancel
GET /api/v1/orders/admin/all (Admin)
PUT /api/v1/orders/admin/:orderId/status (Admin)
β JWT Authentication - Stateless, token-based β Password Security - bcryptjs hashing (10 rounds) β Rate Limiting - 5 auth/15min, 100 global/15min β Account Lockout - 5 failed attempts β 30min lock β Role-Based Access - Admin/User permissions β Input Validation - Sanitized with express-validator β CORS Protection - Configurable origins β Helmet Security - Sets secure HTTP headers β Stock Validation - Prevents overselling β User Isolation - Can't access others' data
{
name, email, password (hashed),
role: 'user' | 'admin',
phone, address, city, state, zipCode,
loginAttempts, accountLocked, lockUntil,
refreshTokens: [],
createdAt, updatedAt
}{
name, description, price, discount,
brand, category,
sizes: [], colors: [],
images: [{url, public_id}],
ratings, numReviews, stock,
createdBy: ObjectId (admin),
createdAt, updatedAt
}{
user: ObjectId (unique),
items: [{
product: ObjectId,
quantity, size, color,
price (with discount),
addedAt
}],
totalPrice (auto-calculated),
createdAt, updatedAt
}{
user: ObjectId,
items: [{product, quantity, price}],
totalPrice,
shippingAddress: {street, city, state, zipCode, country, phone},
paymentInfo: {method, transactionId, status},
orderStatus: 'pending'|'confirmed'|'shipped'|'delivered'|'cancelled',
trackingNumber, estimatedDelivery,
createdAt, updatedAt
}| File | Purpose |
|---|---|
| BACKEND_READY.md | Quick start guide |
| MASTER_SUMMARY.md | Complete overview |
| INDUSTRIAL_LEARNING_GUIDE.md | 5-year dev perspective |
| AUTH_API_DOCS.md | Auth endpoints |
| PRODUCT_API_DOCS.md | Product endpoints |
| CART_API_DOCS.md | Cart endpoints |
| ORDER_API_DOCS.md | Order endpoints |
| DOCUMENTATION_INDEX.md | Navigation guide |
Backend Framework
- Node.js - Runtime
- Express.js - Web framework
- Mongoose - MongoDB ODM
Authentication
- JWT - Token-based auth
- bcryptjs - Password hashing
- jsonwebtoken - Token generation
Security
- Helmet - Security headers
- CORS - Cross-origin handling
- express-rate-limit - Rate limiting
- express-validator - Input validation
Development
- Nodemon - Auto-reload
- Morgan - HTTP logging
- Dotenv - Environment variables
Database
- MongoDB - NoSQL database
- MongoDB Atlas - Cloud option
1. Push to GitHub
2. Connect Render to GitHub
3. Configure environment variables
4. Deploy automatically1. Install Railway CLI
2. Connect to GitHub
3. Deploy with: railway up1. Install Heroku CLI
2. heroku login
3. git push heroku main1. Create droplet/instance
2. Install Node.js, MongoDB
3. Clone repo & npm install
4. Set up systemd service
5. Configure domain & SSL# Database
MONGO_URI=mongodb://localhost:27017/ecommerce
# Or MongoDB Atlas: mongodb+srv://user:pass@cluster.mongodb.net/ecommerce
# Server
PORT=5000
NODE_ENV=development
# JWT
JWT_SECRET=your_super_secret_jwt_key_min_32_chars
JWT_EXPIRE=7d
REFRESH_TOKEN_SECRET=your_super_secret_refresh_key_min_32_chars
REFRESH_TOKEN_EXPIRE=30d
# Security
CORS_ORIGIN=http://localhost:3000,http://localhost:5173
# Payment (Mock)
RAZORPAY_KEY_ID=test_key
RAZORPAY_KEY_SECRET=test_secret
# Redis (Optional)
REDIS_URL=redis://localhost:6379
# Cloudinary (Optional)
CLOUDINARY_CLOUD_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secretcurl http://localhost:5000/healthcurl -X POST http://localhost:5000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"password": "SecurePass123",
"confirmPassword": "SecurePass123"
}'curl "http://localhost:5000/api/v1/products?category=electronics&sortBy=price-low&limit=20"- Import API examples from documentation files
- Set
BASE_URLenvironment variable - Use provided curl commands
- Read BACKEND_READY.md
- Follow quick start
- Test endpoints with curl
- Read API documentation
- Study INDUSTRIAL_LEARNING_GUIDE.md
- Review code in
/backend - Understand design patterns
- Extend with new endpoints
- Study architecture from MASTER_SUMMARY.md
- Implement Redis caching
- Add unit & integration tests
- Deploy to production
BACKEND
β
Authentication System 100% Complete
β
Product Management 100% Complete
β
Shopping Cart 100% Complete
β
Order Processing 100% Complete
β
Payment Integration (Mock) 100% Complete
β
Admin Analytics 100% Complete
β
User Management 100% Complete
β
Inventory Management 100% Complete
β
Error Handling 100% Complete
β
Security (all layers) 100% Complete
FRONTEND (Coming)
β³ React Setup
β³ Redux State Management
β³ Product Listing UI
β³ Shopping Experience
β³ Admin Dashboard
DEPLOYMENT (Coming)
β³ Docker Setup
β³ CI/CD Pipeline
β³ Production Checklist
β³ Scaling Guide
All endpoints follow consistent format:
// Success (200, 201, etc.)
{
"status": true,
"message": "Operation successful",
"data": {
/* endpoint-specific data */
}
}
// Error (400, 404, 500, etc.)
{
"status": false,
"message": "Error description",
"data": null
}Server automatically sets:
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
- β‘ Query Optimization - Lean queries, pagination, indexing
- π Caching Ready - Redis integration prepared
- π Database - Indexed searches, optimized joins
- π Scalability - Service layer architecture
- π Monitoring - Logging system in place
- Fork repository
- Create feature branch
- Commit changes
- Push and create PR
MIT License - See LICENSE file
- Authentication System
- Product Module
- Cart System
- Order Processing
- Admin Panel
- Analytics Dashboard
- React App Setup
- Redux Store
- Product Listing UI
- Shopping Cart UI
- Checkout Flow
- Admin Dashboard
- Redis Caching
- Image Optimization
- Performance Tuning
- Load Testing
- Production Deployment
- CI/CD Pipeline
For questions or issues:
- Check documentation files
- Review API examples
- Check error logs
- Create GitHub issue
# 1. Clone repo
git clone <your-repo>
# 2. Install dependencies
cd backend && npm install
# 3. Configure environment
cp .env.example .env
# Edit .env with your MongoDB URI
# 4. Start server
npm start
# 5. Read documentation
open BACKEND_READY.md
# 6. Test endpoints
curl http://localhost:5000/healthThis project is built following practices used by:
- Flipkart - India's largest e-commerce
- Amazon - Global e-commerce leader
- Myntra - Fashion e-commerce
- Uber - Real-time ordering
- Airbnb - Complex filtering
β MVC Architecture β Service Layer Pattern β Async/Await Error Handling β Input Validation & Sanitization β JWT Authentication β Role-Based Authorization β Rate Limiting β Database Indexing β Pagination & Lean Queries β Error Logging β CORS & Security Headers β Environment Configuration
After setting up, explore:
- INDUSTRIAL_LEARNING_GUIDE.md - Architecture & design patterns
- API Documentation - How each endpoint works
- Code Structure - Why organized this way
- Security - How it protects against attacks
- Performance - Optimization techniques
Ready to build the future of e-commerce? Let's code! π
Made with β€οΈ for MERN developers