A full-stack e-commerce application built with modern web technologies, featuring a customer-facing store, admin dashboard, and scalable backend API.
- Project Overview
- Tech Stack
- Architecture
- Prerequisites
- Installation & Setup
- Running the Application
- Project Structure
- API Documentation
- Environment Variables
- Contributing
- License
This is a production-ready e-commerce platform with:
- Frontend Store: Customer-facing React application for browsing and purchasing products
- Admin Dashboard: Management interface for products, orders, and analytics
- Backend API: RESTful API with authentication, payment processing, and database management
- Framework: React 19.x
- Build Tool: Vite
- Styling: Tailwind CSS 4.x
- State Management: React Context API
- HTTP Client: Axios
- Routing: React Router 7.x
- UI Notifications: React Toastify
- Icons: Lucide React
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (JSON Web Tokens)
- Password Security: Bcrypt
- File Upload: Multer
- Image Storage: Cloudinary
- Payment Gateways: Stripe & Razorpay
- Development: Nodemon
- Linting: ESLint
- Validation: Validator.js
- API Testing: Postman (recommended)
E-commerce-/
βββ Frontend/ # Customer-facing React application
βββ admin/ # Admin dashboard
βββ backend/ # Express API server
βββ docs/ # Documentation
Ensure you have the following installed:
- Node.js 16.x or higher
- npm or yarn package manager
- MongoDB (local or cloud instance - MongoDB Atlas recommended)
- Cloudinary account (for image management)
- Stripe account (for payment processing)
- Razorpay account (optional, for alternative payments)
git clone https://github.com/Likhi2005/E-commerce-.git
cd E-commerce-cd backend
npm installCreate a .env file in the backend directory:
# Server Configuration
PORT=4000
NODE_ENV=development
# Database
MONGODB_URI=mongodb+srv://your_username:your_password@your_cluster.mongodb.net/ecommerce
# JWT
JWT_SECRET=your_jwt_secret_key_here
JWT_EXPIRE=7d
# Cloudinary
CLOUDINARY_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
# Stripe
STRIPE_SECRET_KEY=your_stripe_secret_key
# Razorpay
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret
# Admin Email
ADMIN_EMAIL=admin@example.comcd Frontend
npm installCreate a .env file in the Frontend directory:
VITE_API_BASE_URL=http://localhost:4000/api
VITE_STRIPE_PUBLIC_KEY=your_stripe_public_keycd admin
npm installCreate a .env file in the admin directory:
VITE_API_BASE_URL=http://localhost:4000/apiTerminal 1 - Backend:
cd backend
npm run server # Starts with Nodemon for hot-reloadTerminal 2 - Frontend:
cd Frontend
npm run dev # Runs on http://localhost:5173Terminal 3 - Admin Dashboard:
cd admin
npm run dev # Runs on http://localhost:5174Frontend:
cd Frontend
npm run build # Creates optimized build in dist/
npm run preview # Preview production build locallyAdmin:
cd admin
npm run build
npm run previewBackend:
cd backend
npm start # Runs production serversrc/
βββ components/ # Reusable UI components
β βββ BestSeller.jsx
β βββ CartTotal.jsx
β βββ Footer.jsx
β βββ Hero.jsx
β βββ LatestCollection.jsx
β βββ Navbar.jsx
β βββ ...
βββ pages/ # Page components
β βββ Home.jsx
β βββ Product.jsx
β βββ Cart.jsx
β βββ Collection.jsx
β βββ Orders.jsx
β βββ ...
βββ context/ # React Context for state management
β βββ ShopContext.jsx
βββ assets/ # Static assets & constants
βββ App.jsx
src/
βββ components/ # Admin UI components
β βββ Login.jsx
β βββ Navbar.jsx
β βββ Sidebar.jsx
βββ pages/ # Admin pages
β βββ Add.jsx # Add products
β βββ List.jsx # Product list
β βββ Orders.jsx # Order management
βββ App.jsx
βββ config/ # Configuration files
β βββ mongodb.js
β βββ cloudinary.js
βββ models/ # Mongoose schemas
β βββ userModel.js
β βββ productModel.js
β βββ orderModel.js
βββ controllers/ # Business logic
β βββ userController.js
β βββ productController.js
β βββ cartController.js
βββ routes/ # API endpoints
β βββ userRoute.js
β βββ productRouter.js
β βββ cartRoute.js
βββ middleware/ # Custom middleware
β βββ auth.js # JWT authentication
β βββ adminAuth.js # Admin authorization
β βββ multer.js # File upload handling
βββ server.js # Entry point
POST /api/user/register - User registration
POST /api/user/login - User login
POST /api/user/logout - User logout
GET /api/product/list - Get all products
GET /api/product/:id - Get product details
POST /api/product/add - Add product (Admin only)
PUT /api/product/update/:id - Update product (Admin only)
DELETE /api/product/delete/:id - Delete product (Admin only)
GET /api/cart - Get user's cart
POST /api/cart/add - Add item to cart
DELETE /api/cart/remove/:id - Remove item from cart
For detailed API documentation, refer to the Postman collection or generate OpenAPI docs.
MONGODB_URI- MongoDB connection stringJWT_SECRET- Secret key for JWT token generationCLOUDINARY_*- Cloudinary API credentialsSTRIPE_SECRET_KEY- Stripe secret keyRAZORPAY_KEY_*- Razorpay API keys
VITE_API_BASE_URL- Backend API URLVITE_STRIPE_PUBLIC_KEY- Stripe public key
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow ESLint rules (run
npm run lintin each directory) - Use meaningful commit messages
- Add comments for complex logic
- Test features before submitting PR
This project is licensed under the ISC License - see the LICENSE file for details.
For issues and feature requests, please open an issue on GitHub.