A full-stack e-commerce application built with the MERN stack (MongoDB, Express.js, React.js, and Node.js).
- Features
- Technology Stack
- Prerequisites
- Installation
- Running the Application
- Project Structure
- API Endpoints
- Contributing
- License
- Repository
- User authentication and authorization (login, register, role-based access)
- Product catalog with search, filter, and sorting functionality
- Shopping cart management
- Order processing and history
- Payment gateway integration
- User profile management
- Admin panel for product, order, and user management
- React.js
- Redux for state management
- React Router for navigation
- CSS/SCSS for styling
- Node.js
- Express.js
- MongoDB for database
- Mongoose for object modeling
- JWT for authentication
Before you begin, ensure you have the following installed:
git clone <your-repository-url>
cd ecommerce-mernnpm installcd client
npm install
cd ..Create a .env file in the root directory and add the following:
NODE_ENV=development
PORT=5000
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret_key
PAYPAL_CLIENT_ID=your_paypal_client_id_if_using_paypal
To run both the frontend and backend in development mode:
npm run devThis will run the server on port 5000 and the client on port 3000.
To run only the server:
npm run serverTo run only the client:
npm run clientTo build the client for production:
cd client
npm run build
cd ..To start the application in production mode:
npm startecommerce-mern/
├── package.json
├── client/ # Frontend React application
│ ├── package.json
│ ├── public/
│ └── src/
│ ├── App.js
│ ├── app/ # Redux store
│ ├── components/ # UI components
│ ├── features/ # Redux slices for features
│ └── services/ # API services
└── server/ # Backend Node.js application
├── config/ # Configuration files
├── controllers/ # Route controllers
├── middleware/ # Custom middleware
├── models/ # MongoDB models
├── routes/ # API routes
├── utils/ # Utility functions
└── server.js # Server entry point
- POST /api/users/register - Register a new user
- POST /api/users/login - Login user
- GET /api/products - Get all products
- GET /api/products/:id - Get single product by ID
- POST /api/products - Create a new product (admin only)
- PUT /api/products/:id - Update a product (admin only)
- DELETE /api/products/:id - Delete a product (admin only)
- GET /api/cart - Get user cart
- POST /api/cart - Add item to cart
- PUT /api/cart/:itemId - Update cart item
- DELETE /api/cart/:itemId - Remove item from cart
- GET /api/orders - Get user orders
- GET /api/orders/:id - Get single order
- POST /api/orders - Create a new order
- PUT /api/orders/:id/pay - Update order to paid
- PUT /api/orders/:id/deliver - Update order to delivered (admin only)
- GET /api/users - Get all users
- GET /api/users/:id - Get user by ID
- PUT /api/users/:id - Update user
- DELETE /api/users/:id - Delete user
- Fork the repository
- Create your 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
This project is licensed under the MIT License - see the LICENSE file for details.
The source code for this project is available on GitHub: EZCommerce Repository