A full-featured e-commerce platform built with the MERN stack (MongoDB, Express, React, Node.js). This application provides a complete online shopping experience with separate dashboards for customers, merchants, and administrators.
- Product Browsing: Browse products by category, brand, and price.
- Product Search: Search for specific products.
- Product Details: View detailed information about each product, including reviews.
- Shopping Cart: Add products to a shopping cart and manage cart items.
- Wishlist: Save products to a wishlist for future purchase.
- Checkout: Secure checkout process with address management.
- Order History: View past orders and their status.
- Account Management: Manage personal information and security settings.
- Product Management: Add, edit, and delete products.
- Brand Management: Add and manage product brands.
- Category Management: Add and manage product categories.
- Order Management: View and manage incoming orders.
- Dashboard: View sales and performance metrics.
- User Management: Manage all users (customers and merchants).
- Merchant Management: Approve or disable merchant accounts.
- Product Management: Oversee all products on the platform.
- Order Management: Access and manage all orders.
- Support: Handle support tickets and messages.
- Dashboard: Comprehensive overview of the entire platform.
-
Frontend:
- React
- Redux for state management
- Reactstrap for UI components
- SCSS for styling
- Webpack for bundling
-
Backend:
- Node.js
- Express.js for the server framework
- MongoDB for the database
- Mongoose for object data modeling
- JWT for authentication
- Passport.js for authentication strategies
-
Deployment:
- Docker
- Nginx (for client-side routing)
/client
├── app/
│ ├── actions.js
│ ├── components/
│ │ ├── Common/
│ │ ├── Manager/
│ │ └── Store/
│ ├── constants/
│ ├── containers/
│ │ ├── Account/
│ │ ├── Authentication/
│ │ ├── Brand/
│ │ ├── Cart/
│ │ ├── Category/
│ │ ├── Contact/
│ │ ├── Dashboard/
│ │ ├── Homepage/
│ │ ├── Login/
│ │ ├── Merchant/
│ │ ├── Navigation/
│ │ ├── Order/
│ │ ├── Product/
│ │ ├── Review/
│ │ ├── Shop/
│ │ └── Support/
│ ├── contexts/
│ ├── reducers.js
│ ├── store.js
│ └── utils/
├── public/
│ ├── images/
│ └── index.html
├── styles/
├── webpack/
├── Dockerfile
├── nginx.conf
└── package.json
/server
├── config/
├── enums/
├── helpers/
├── index.js
├── models/
│ ├── address.js
│ ├── brand.js
│ ├── cart.js
│ ├── category.js
│ ├── contact.js
│ ├── newsletter.js
│ ├── order.js
│ ├── product.js
│ ├── review.js
│ ├── user.js
│ └── wishlist.js
├── routes/
│ └── api/
│ ├── address.js
│ ├── auth.js
│ ├── brand.js
│ ├── cart.js
│ ├── category.js
│ ├── contact.js
│ ├── merchant.js
│ ├── newsletter.js
│ ├── order.js
│ ├── product.js
│ ├── review.js
│ ├── user.js
│ └── wishlist.js
├── services/
├── socket/
├── utils/
└── package.json
- Node.js (v14 or later)
- npm
- MongoDB
- Docker (optional, for containerized deployment)
-
Clone the repository:
git clone https://github.com/your-username/mern-ecommerce.git cd mern-ecommerce -
Install server dependencies:
cd server npm install -
Install client dependencies:
cd ../client npm install -
Set up environment variables:
- In the
/serverdirectory, create a.envfile by copying.env.example. - Fill in the required environment variables, such as your MongoDB connection string and JWT secret.
- In the
-
Seed the database (optional):
- To populate the database with initial data, run the seeder script:
cd ../server npm run seed
- To populate the database with initial data, run the seeder script:
-
Start the server:
cd server npm startThe server will run on
http://localhost:3000. -
Start the client:
cd ../client npm startThe client development server will run on
http://localhost:8080.
The backend API provides the following RESTful endpoints:
POST /api/auth/login- User loginPOST /api/auth/register- User registrationGET /api/products- Get all productsGET /api/products/:slug- Get a single product by slugPOST /api/products- Create a new product (merchant/admin only)PUT /api/products/:id- Update a product (merchant/admin only)DELETE /api/products/:id- Delete a product (merchant/admin only)GET /api/brands- Get all brandsGET /api/categories- Get all categoriesPOST /api/cart- Add an item to the cartGET /api/cart- Get cart itemsDELETE /api/cart/:id- Remove an item from the cartPOST /api/wishlist- Add an item to the wishlistGET /api/wishlist- Get wishlist itemsPOST /api/orders- Place a new orderGET /api/orders- Get user's ordersGET /api/users- Get all users (admin only)GET /api/users/:id- Get a single user (admin only)PUT /api/users/:id- Update a user (admin only)
...and many more. Refer to the route files in /server/routes/api/ for a complete list.
The following environment variables are required for the server to run:
MONGO_URI: Your MongoDB connection string.JWT_SECRET: A secret key for signing JWTs.JWT_EXPIRATION: JWT expiration time (e.g.,1h).MAILGUN_KEY: Your Mailgun API key (for sending emails).MAILGUN_DOMAIN: Your Mailgun domain.MAILCHIMP_KEY: Your Mailchimp API key (for newsletter subscriptions).MAILCHIMP_LIST_ID: Your Mailchimp list ID.STRIPE_SECRET_KEY: Your Stripe secret key (for payments).
This application is configured for deployment with Docker.
-
Build the Docker images:
docker-compose build
-
Run the containers:
docker-compose up
The application will be available at http://localhost:8080.
This project is licensed under the MIT License. See the LICENSE file for details.