A complete E-Commerce platform built with modern web technologies featuring a customer-facing frontend, admin dashboard, and robust backend API.
- Project Overview
- Architecture
- Tech Stack
- Project Structure
- Features
- Workflow
- Installation & Setup
- API Documentation
- Database Schema
- Payment Integration
- File Upload
- Authentication & Authorization
- State Management
- Deployment
- Contributing
This is a full-stack E-Commerce application with three main components:
- Frontend (Customer Portal) - React-based customer interface for browsing products, cart management, and checkout
- Admin Dashboard - React-based admin panel for product management and order processing
- Backend API - Node.js/Express server with MongoDB database and payment integrations
- π User authentication and authorization
- π Shopping cart functionality
- π³ Multiple payment gateways (Stripe, Razorpay, COD)
- π± Responsive design with Tailwind CSS
- πΌοΈ Image upload with Cloudinary
- π Admin dashboard for inventory management
- π Product search and filtering
- π¦ Order management system
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Admin Panel β β Backend β
β (Customer) β β β β (API) β
β β β β β β
β β’ Product Browseβ β β’ Add Products β β β’ REST API β
β β’ Shopping Cart β β β’ Manage Orders β β β’ Authenticationβ
β β’ Checkout β β β’ View Analyticsβ β β’ File Upload β
β β’ User Profile β β β’ User Mgmt β β β’ Payment Proc β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β Database β
β (MongoDB) β
β β
β β’ Users β
β β’ Products β
β β’ Orders β
β β’ Cart Data β
βββββββββββββββββββ
- React 19 - Modern React with hooks and functional components
- React Router DOM - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Vite - Fast build tool and development server
- Axios - HTTP client for API calls
- React Toastify - Toast notifications
- Context API - State management
- Node.js - JavaScript runtime
- Express.js - Web application framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - JSON Web Tokens for authentication
- bcrypt - Password hashing
- Multer - File upload middleware
- CORS - Cross-origin resource sharing
- Cloudinary - Cloud image storage and management
- Stripe - Payment processing
- Razorpay - Payment gateway
- MongoDB Atlas - Cloud database hosting
- ESLint - Code linting
- PostCSS - CSS processing
- Autoprefixer - CSS vendor prefixing
- Nodemon - Development server with auto-restart
E-Commerce/
βββ frontend/ # Customer-facing React app
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ context/ # React Context for state
β β βββ assets/ # Images and static files
β β βββ App.jsx # Main app component
β βββ package.json
β βββ vite.config.js
β
βββ admin/ # Admin dashboard React app
β βββ src/
β β βββ components/ # Admin UI components
β β βββ pages/ # Admin pages
β β βββ assets/ # Admin assets
β βββ package.json
β βββ vite.config.js
β
βββ backend/ # Node.js API server
βββ config/ # Configuration files
βββ controllers/ # Business logic
βββ middleware/ # Custom middleware
βββ models/ # Database schemas
βββ routes/ # API routes
βββ server.js # Main server file
βββ package.json
- User Registration & Login - Secure authentication with JWT
- Product Browsing - View products with images, descriptions, and pricing
- Product Search - Search functionality with filters
- Shopping Cart - Add/remove items with size selection
- Checkout Process - Multiple payment options (Stripe, Razorpay, COD)
- Order History - View past orders and status
- Responsive Design - Mobile-friendly interface
- Product Management - Add, edit, and delete products
- Image Upload - Multiple image upload with Cloudinary
- Order Management - View and update order status
- Inventory Control - Manage product stock and categories
- User Management - View customer data and orders
- RESTful API - Well-structured API endpoints
- File Upload - Secure image upload with validation
- Payment Integration - Multiple payment gateways
- Real-time Updates - Live cart and order updates
- Error Handling - Comprehensive error management
- Security - JWT authentication, password hashing, CORS
- Browse Products β View product catalog with search/filter
- Product Details β Select size and add to cart
- Cart Management β Review items, update quantities
- Checkout β Enter shipping details and payment method
- Payment β Complete payment via Stripe/Razorpay/COD
- Order Confirmation β Receive order confirmation and tracking
- Login β Admin authentication
- Add Products β Upload images, set details, categories
- Manage Inventory β Update stock, prices, descriptions
- Process Orders β View orders, update status
- Analytics β Monitor sales and customer data
- Request β Client sends HTTP request
- Authentication β Verify JWT token (if required)
- Validation β Validate request data
- Business Logic β Process request in controller
- Database β Perform CRUD operations
- Response β Send JSON response to client
- Node.js (v18 or higher)
- MongoDB (local or Atlas)
- npm or yarn package manager
Create .env files in the backend directory:
# Database
MONGO_URI=mongodb://localhost:27017
# or MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net
# JWT
JWT_SECRET=your_jwt_secret_key
# Cloudinary
CLOUDINARY_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_SECRET_KEY=your_cloudinary_secret_key
# Payment Gateways
STRIPE_SECRET_KEY=your_stripe_secret_key
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_secret_key
# Admin Credentials
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=admin_password
# Server
PORT=4000Create .env files in frontend and admin directories:
VITE_BACKEND_URL=http://localhost:4000-
Clone the repository
git clone <repository-url> cd E-Commerce
-
Install backend dependencies
cd backend npm install -
Install frontend dependencies
cd ../frontend npm install -
Install admin dependencies
cd ../admin npm install -
Start the development servers
Backend:
cd backend npm run serverFrontend:
cd frontend npm run devAdmin:
cd admin npm run dev -
Access the applications
- Frontend: http://localhost:5173
- Admin: http://localhost:5174
- Backend API: http://localhost:4000
POST /api/user/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}POST /api/user/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "password123"
}POST /api/user/admin-login
Content-Type: application/json
{
"email": "admin@example.com",
"password": "admin_password"
}GET /api/product/listPOST /api/product/single
Content-Type: application/json
{
"productId": "product_id_here"
}POST /api/product/add
Content-Type: multipart/form-data
Authorization: Bearer <admin_token>
{
"name": "Product Name",
"description": "Product description",
"price": 99.99,
"category": "Men",
"subCategory": "Topwear",
"sizes": ["S", "M", "L", "XL"],
"bestseller": true,
"image1": <file>,
"image2": <file>,
"image3": <file>,
"image4": <file>
}POST /api/product/remove
Content-Type: application/json
Authorization: Bearer <admin_token>
{
"id": "product_id_here"
}POST /api/cart/add
Content-Type: application/json
Authorization: Bearer <user_token>
{
"itemId": "product_id",
"size": "M"
}POST /api/cart/get
Authorization: Bearer <user_token>POST /api/cart/update
Content-Type: application/json
Authorization: Bearer <user_token>
{
"itemId": "product_id",
"size": "M",
"quantity": 2
}POST /api/order/place
Content-Type: application/json
Authorization: Bearer <user_token>
{
"userId": "user_id",
"items": [
{
"id": "product_id",
"name": "Product Name",
"price": 99.99,
"size": "M",
"quantity": 1
}
],
"amount": 109.99,
"address": {
"street": "123 Main St",
"city": "New York",
"state": "NY",
"zipCode": "10001"
}
}POST /api/order/stripe
Content-Type: application/json
Authorization: Bearer <user_token>
{
"userId": "user_id",
"items": [...],
"amount": 109.99,
"address": {...}
}POST /api/order/razorpay
Content-Type: application/json
Authorization: Bearer <user_token>
{
"userId": "user_id",
"items": [...],
"amount": 109.99,
"address": {...}
}POST /api/order/user-orders
Content-Type: application/json
Authorization: Bearer <user_token>
{
"userId": "user_id"
}POST /api/order/all-orders
Authorization: Bearer <admin_token>POST /api/order/update-status
Content-Type: application/json
Authorization: Bearer <admin_token>
{
"orderId": "order_id",
"status": "Shipped"
}{
name: String (required),
email: String (required, unique),
password: String (required, hashed),
cartData: Object (default: {})
}{
name: String (required),
description: String (required),
price: Number (required),
image: Array (required), // Cloudinary URLs
category: String (required), // e.g., "Men", "Women"
subCategory: String (required), // e.g., "Topwear", "Bottomwear"
sizes: Array (required), // e.g., ["S", "M", "L", "XL"]
bestseller: Boolean,
date: Number (required) // Timestamp
}{
userId: String (required),
items: Array (required), // Product details with quantities
amount: Number (required),
address: Object (required), // Shipping address
status: String (required, default: "Order Placed"),
paymentMethod: String (required), // "COD", "Stripe", "Razorpay"
payment: Boolean (required, default: false),
date: Number (required) // Timestamp
}-
Cash on Delivery (COD)
- No payment processing required
- Order placed immediately
- Payment collected on delivery
-
Stripe
- Secure online payment processing
- Supports major credit cards
- Automatic payment verification
- Redirect to Stripe checkout
-
Razorpay
- Indian payment gateway
- Supports UPI, cards, net banking
- Order creation and verification
- Payment status tracking
- Order Creation β Create order in database
- Payment Gateway β Redirect to payment provider
- Payment Processing β Customer completes payment
- Verification β Verify payment with gateway
- Order Update β Update order status and clear cart
- Confirmation β Send confirmation to customer
- Multiple Images β Up to 4 images per product
- Automatic Optimization β Cloudinary handles image optimization
- Secure URLs β HTTPS image URLs
- CDN Delivery β Fast global image delivery
- File Selection β Admin selects images
- Form Data β Images sent as multipart/form-data
- Multer Processing β Server processes uploaded files
- Cloudinary Upload β Images uploaded to Cloudinary
- URL Storage β Image URLs stored in database
- Product Creation β Product saved with image URLs
- Token Generation β JWT created on login/register
- Token Storage β Stored in localStorage
- Token Validation β Middleware validates tokens
- Token Refresh β New token on successful requests
-
Customers
- Register/login with email/password
- Access to shopping features
- Personal cart and order history
-
Admins
- Special admin credentials
- Access to admin dashboard
- Product and order management
- Password Hashing β bcrypt for secure password storage
- Input Validation β Server-side validation
- CORS Protection β Cross-origin request handling
- Error Handling β Secure error responses
The application uses React Context for global state management:
// ShopContext provides:
- products: Array of all products
- cartItems: Current cart state
- token: Authentication token
- search: Search functionality
- currency: Price formatting
- delivery_fee: Shipping cost- Add to Cart β Update cart state and sync with backend
- Update Quantity β Modify cart items
- Remove Items β Remove from cart
- Search Products β Filter products based on search
- Authentication β Manage login state
- Context Provider β Wraps entire app
- State Updates β Functions update context state
- API Calls β Sync state with backend
- Component Updates β Components re-render on state changes
-
Build Configuration
{ "version": 2, "builds": [ { "src": "server.js", "use": "@vercel/node" } ], "routes": [ { "src": "/(.*)", "dest": "server.js" } ] } -
Environment Variables β Set in Vercel dashboard
-
Database β Use MongoDB Atlas
-
Deploy β Connect GitHub repository
- Build Command β
npm run build - Output Directory β
dist - Environment Variables β Set backend URL
- Deploy β Automatic deployment on push
- Same as Frontend β Separate deployment
- Environment Variables β Set backend URL
- Custom Domain β Optional custom domain
- Code Style β Follow ESLint configuration
- Commit Messages β Use conventional commits
- Testing β Test all features before pushing
- Documentation β Update docs for new features
- Fork Repository β Create your fork
- Create Branch β Feature branch from main
- Make Changes β Implement your feature
- Test Thoroughly β Ensure everything works
- Submit PR β Create pull request with description
- Components β Reusable UI components
- Pages β Route-specific components
- Controllers β Business logic
- Models β Database schemas
- Routes β API endpoints
- Middleware β Request processing
This project is licensed under the ISC License.
- React Team β For the amazing React framework
- Tailwind CSS β For the utility-first CSS framework
- MongoDB β For the flexible NoSQL database
- Cloudinary β For image management services
- Stripe & Razorpay β For payment processing
If you encounter any issues or have questions:
- Check Documentation β Review this README thoroughly
- Environment Variables β Ensure all required variables are set
- Database Connection β Verify MongoDB connection
- Payment Keys β Check payment gateway credentials
- File Upload β Verify Cloudinary configuration
For additional help, please create an issue in the repository with:
- Detailed error description
- Steps to reproduce
- Environment information
- Screenshots (if applicable)
Happy Coding! π