Welcome to Fusion Electronics, a MERN-Stack E-commerce Application! This project is a working demo of a full-stack web application that was built using the MERN stack (MongoDB, Express.js, React.js, Node.js). It aims to provide a comprehensive example of building a modern e-commerce platform, covering frontend user interface, backend server logic, database management, and integration with third-party libraries.
This project is a demonstration of building an e-commerce application using the MERN stack, which consists of MongoDB (database), Express.js (server), React.js (frontend), and Node.js (runtime environment). The application allows users to browse products, add them to a shopping cart, proceed to checkout, and simulate the order processing. It includes basic validations for user inputs and simulates the checkout process on the backend.
Product Management:
Shopping Cart:
Checkout Process:
Frontend:
react-credit-cards-2
for credit card visualizationBackend:
Development Tools:
The project is organized into two main “stacks”: The backend is in the backend
directory that hosts all product & order data and the frontend is in the root
directory. Here is an overview of the project structure:
fullstack-ecommerce/
├── backend/ # Node.js server files
│ ├── config/ # Configuration files
│ │ └── db.js # Database connection
│ ├── models/ # Mongoose models
│ │ └── product.js # Product schema
│ ├── routes/ # Route handlers
│ │ ├── products.js # Product routes
│ │ ├── search.js # Search routes
│ │ └── checkout.js # Checkout routes
│ ├── seed/ # Database seed data
│ │ └── products.js # Product seed data
│ ├── .env # Environment variables
│ └── index.js # Server entry point
├── public/ # Frontend public assets
│ ├── index.html # HTML template
│ ├── manifest.json # Web app manifest
│ └── favicon.ico # Favicon
├── src/ # React.js frontend files
│ ├── components/ # Reusable components
│ │ ├── CheckoutForm.jsx # Checkout form component
│ │ ├── ProductCard.jsx # Product card component
│ │ ├── NavigationBar.jsx # Navigation bar component
│ │ ├── OrderConfirmation.jsx # Order confirmation component
│ │ ├── ProductListing.jsx # Product listing component
│ │ ├── SearchResults.jsx # Search results component
│ │ └── ShoppingCart.jsx # Shopping cart component
│ ├── dev/ # Development utilities
│ │ ├── index.js # Development entry point
│ │ ├── palette.jsx # Color palette
│ │ ├── preview.jsx # Component preview
│ │ └── useInitials.js # Initials hook
│ ├── pages/ # Page components
│ │ ├── Cart.jsx # Cart page component
│ │ ├── Checkout.jsx # Checkout page component
│ │ ├── Home.jsx # Home page component
│ │ ├── ProductDetails.jsx # Product details page component
│ │ ├── OrderSuccess.jsx # Order success page component
│ │ ├── ProductDetails.jsx # Product details page component
│ │ └── Shop.jsx # Shop page component
│ ├── App.jsx # Main application component
│ ├── App.css # Main application styles
│ └── index.js # React entry point
├── build/ # Frontend production build files
├── tests/ # Test files
├── .gitignore # Git ignore file
├── package.json # NPM package file
├── jsconfig.json # JS config file
└── setupProxy.js # Proxy configuration
Before running this project, ensure you have the following installed:
Clone the repository:
git clone https://github.com/Ankit7rma/Mern-Stack_Ecommerce
cd fullstack-ecommerce
Install project dependencies:
# Install server dependencies
cd backend
npm install
# Install client (frontend) dependencies
cd ..
npm install
Set up the backend:
.env
file in the backend/
directory and add the following environment variables:
MONGO_URI=mongodb://localhost:27017/Ecommerce-Products
brew services start mongodb-community
cd backend/seed
node productSeeds.js dev
cd
into the backend directory)
cd ..
npm start
Set up the frontend:
cd
into the root
directory if you are not already there:
cd ..
Or
cd fullstack-ecommerce
npm start
http://localhost:3000
by default. If you encounter any errors when starting related to the react-credit-cards-2
package, it is OK to just ignore them as the application will still run correctly.http://localhost:3000
to view the application.http://localhost:5000/api/products
to view the list of products.backend/seed/productSeeds.js
and modifying the data there.http://localhost:5000/api-docs
.
To deploy the application:
This project can be containerized using Docker. First, ensure that Docker Desktop is running on your system. Then, to create a Docker image, run the following command:
docker compose up --build
This command will create a Docker image for the frontend and backend, and run the application in a containerized environment.
Contributions to this project are welcome! Here are some ways you can contribute:
This project is licensed under the MIT License - see the LICENSE file for details.
Thank you for exploring Fusion Electronics - a MERN Stack E-commerce Application! If you have any questions or feedback, feel free to reach out or open an issue.
Happy coding! 🚀