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.
The application is deployed live on Vercel. You can access it at the following URL: Fusion Electronics.
The backend server is deployed on Render and can be accessed at the following URL: Fusion Electronics API.
Please note that the backend server may take a few seconds to wake up if it has been inactive for a while.
react-credit-cards-2
for credit card visualizationreact-router-dom
for routingreact-hook-form
for form validationreact-toastify
for toast notificationsThe 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:
git clone https://github.com/hoangsonww/MERN-Stack-Ecommerce-App.git
cd MERN-Stack-Ecommerce-App # Fix the path if necessary
# Install server (backend) 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 variable (replace the URI with your MongoDB connection string):
MONGO_URI=mongodb://localhost:27017/Ecommerce-Products
JWT_SECRET=your_secret_key
For your information, I am using MongoDB Atlas for this project. You can create a free account and get your connection string from there if you want to deploy the application to the cloud.
brew services start mongodb-community
cd backend/seed
node productSeeds.js dev
cd
into the backend directory)
cd ..
npm start
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! π