Tran - Thi Thu Hien
Tran - Thi Thu Hien
2022
THE DEVELOPMENT OF AN E-
COMMERCE WEB
APPLICATION USING MERN
STACK
Bachelor’s Thesis | Abstract
2022 | 77 pages
E-commerce has exponentially risen over the last decade, offering more
benefits and conveniences than traditional businesses. Furthermore, the
COVID-19 era has irreversibly changed the way businesses interact with
customers, allowing merchants to approach clients more promptly. By
recognizing this need, an E-commerce web application is created in the form of
an online bookshop.
This thesis will demonstrate and comprehend each MERN stack technology's
essential concept before building a functional E-commerce web application to
help small companies formulate their business strategy.
The functionality and browser capabilities tests were all conducted on various
platforms. The outcome was satisfactory since the web application fulfilled all of
the objectives.
List of abbreviations 8
1 Introduction 10
2 Theoretical background 12
2.1 The MERN stack 12
2.1.1 MongoDB 13
2.1.2 Express 15
2.1.3 React 16
2.1.4 NodeJS 21
2.2 Mongoose 22
4 Project implementation 36
4.1Backend implementation 36
4.2.1 Mongoose models 36
4.2.2 Authentication and authorization 40
4.2.3 Routes and APIs implementation 45
4.2.4 API Testing with REST Client 47
4.2 Frontend implementation 48
4.2.1 Routing 48
4.2.2 Homepage 51
4.2.3 User Authentication 53
4.2.4 Products Page 56
4.2.5 Product Detail Page 59
4.2.6 Cart page 61
4.2.7 Administrator pages 62
5 Deployment 65
6 Testing 67
7 Discussion 71
7.1 Results 71
7.2 Further improvements 71
8 Conclusion 73
References 74
Figures
Tables
B2C Business-to-Consumer
E2E End-to-End
UI User Interface
1 Introduction
The main objective of this thesis is to demonstrate and comprehend the core
concept of each technology in the MERN stack. As a result, an E-commerce
web application has been developed to facilitate the small companies in
formulating their business strategy by taking advantage of the MERN stack as
well as its relevant technologies. Both frontend and backend development will
be explained in detail to assist readers in understanding the whole process of
constructing this application.
This thesis consists of eight chapters. The first chapter contains the primary
objective of the thesis and the technologies used. The second chapter explains
the theoretical background of each technology in the mentioned stack used for
2 Theoretical background
The thesis application is constructed based on the MERN stack as the primary
fullstack technology. This chapter will briefly discuss each technology in the
MERN stack as well as its third-party support library Mongoose to develop the
project.
MERN is one of the notable variants based on the MEAN stack. Basically, the
MEAN stack was initially established in 2013 by a MongoDB engineering team
as a JavaScript-based stack in order to aid in the development (MongoDB Inc.,
2013). MEAN comprises four open-source components: MongoDB acts as the
database, Express serves as the server framework, Angular as the client
framework, and Node works as the environment for running JavaScript. By
substituting the popular framework Angular with React – a client-side library –
and combining them as the MERN stack, React can become a companion to
the other technologies for developing JavaScript and JSON-oriented
applications. Figure 1 below illustrates the architecture of the MERN stack
technology:
2.1.1 MongoDB
2.1.2 Express
Representing the letter “E” in the MERN stack, Express is a lightweight and
versatile web application framework built on top of NodeJS (OpenJS
Foundation, 2022). Thanks to the large community of support, it includes a rich
collection of functionality for developing web and mobile applications. Even
though a large number of support packages along with the functionality for
better software creation, Express does not affect the performance of NodeJS.
Based on the GitHub repository, Express was established on May 22, 2010, by
T.J. Holowaychuk. After that, StrongLoop acquired the project management
rights in June 2014 until IBM owned the company in September 2015. Then, in
January 2016, the NodeJS Foundation took over the management of Express,
and Express is now the primary function of the NodeJS platform (Wikipedia,
2022a).
2.1.3 React
React, representing the letter ‘R’ in the MERN stack, focuses on creating the
View Layer, which is well-known for all visible parts of the page of an
application. React is a multi-purposed, open-source JavaScript library used for
building user interfaces based on UI components (Facebook Inc., 2022d).
Along with offering reusable component code, which reduces development time
and the likelihood of bugs and errors, Reacts introduced many essential
JSX
Virtual DOM
While regular DOM manipulation is slow due to the re-rendering of both the
updated element and its children after getting new data, the Virtual DOM re-
renders only the components that need updating, which fastens the rendering
process and increases the performance.
In order to further understand why Virtual DOM is fast and practical, the
functionality of Virtual DOM must be discussed. The state of the DOM tree
hierarchy is stored when Virtual DOM is utilized to render a page. Instead of
constructing a new tree, a diffing approach is employed when UI modifications
are necessary. At that point, the React library employs the Virtual DOM, which
allows it to do the calculations inside this domain without involving the actual
DOM. Therefore, whenever a component's state changes, React keeps track of
it and updates the Virtual DOM tree by comparing the current version to the
prior one (Facebook Inc., 2022h). This comparison employs a diffing algorithm
to reduce the number of DOM operations/refreshes, leading to considerable
boosting speed. The whole procedure is titled Reconciliation (Facebook Inc.,
2022e).
Figure 5 below demonstrates DOM and the Virtual DOM update process
differences.
Figure 5. The difference between Virtual DOM and real DOM update process
(Hamedani, 2018).
Components
Components can refer to one another, which means one component can be a
parent component containing several child components with no restriction on
Hooks
There are two built-in React hooks that should be discussed. First, the State
hook, commonly known as the useState hook, enables the component-level
state management. It hooks into React's state by creating a state variable that
React maintains. useState hook accepts and returns two results: the current
state and a function to alter it. The component state can be efficiently initialized,
utilized, and modified using the useState hook (Facebook Inc., 2022g). The
second hook is the Effect hook, also known as useEffect hook. useEffect hook
assists programmers in managing component life cycles. The difficulty of
separating related functionality and data into several class life cycles, such as
componentDidUpdate, componentDidMount, and componentWillUnmount, has
been thoroughly addressed by Effect Hook. A React component can support
multiple effects to isolate data manipulation issues (Facebook Inc., 2022f).
2.1.4 NodeJS
Node package manager (NPM) is the NodeJS default package manager for
applications, and it is utilized to maintain all of the NodeJS packages and
modules along with the command line client npm. Therefore, it facilitates time-
consuming manual tasks by automated managing third-party packages,
allowing developers to spend more time on the development process.
NPM was first published on January 12, 2010, by Isaac Z. Schlueter (Wikipedia,
2022c). It is installed alongside NodeJS and is utilized to install the required
packages and modules in the NodeJS project.
It is currently the world's largest software registry, with approximately two million
packages at the end of March 2022.
2.2 Mongoose
The first step in getting started with Mongoose, like with other ODM libraries, is
to create a schema. As Mongoose's documentation page described, a schema
specifies the data structure and property casting, along with the following
techniques: instance methods, compound indexes, static Model methods, and
middlewares (Mongoose, n.d. (b)). Once the first stage is finished, the
developed schemas will be utilized to map to MongoDB collections and shape
the data documents included inside each collection. The second stage required
by programmers is to construct a Mongoose model. Models are composed of
builders of schemas, with the primary responsibility of producing and scanning
documents in the Mongo database. Querying, deleting, and updating
documents in the database are additional capabilities of models worth
mentioning (Mongoose, n.d. (a)).
The project was based on the B2C E-commerce web application, which
contains two types of users: administrator and user. Administrators are
accountable for a variety of management tasks, including creating, modifying,
and deleting products from the databases. On the other hand, the user can
navigate and explore the information of the product and purchase the product
by adding to the shopping cart and completing the transaction for that product.
Some certain pages and web routes are visible to the public, whilst others are
restricted to administrators and logged-in users.
The user behaviors are demonstrated in Table 1 below, illustrating some of the
essential features of an E-commerce web application.
Customers Administrators
Create a new account Not valid
Sort the product list by price, newest Sort the product list by price, newest
added date, sold number and category added date, sold number and category
View the product list View the product list
View product information with images View product information with images
Add products to the shopping cart Not valid
Modify the number of products inside Not valid
the shopping cart
(continue)
Table 1. (continued).
Customers Administrators
Pay the added products inside the Not valid
shopping cart
Not valid Add new products to the database
Not valid Remove products from the database
Not valid Update products to the database
Not valid Add category to the database
View own orders View all user orders
C/C++, C#, and Go. Thanks to the enormous support community, developers
can have multiple options to customize the theme, write code, install extensions
to provide more capabilities, and manage their projects with version control
systems such as Git or GitHub. VSCode is developed and managed by
Microsoft, and it is compatible with Windows, Linux, and macOS. (Microsoft,
2022).
The first thing to start the server-side is creating the package.json file to
maintain required dependencies and devDependencies and perform different
tasks by running commands. Before generating the command in Figure 9
below, NodeJS version 16.13.0 was installed.
By running the command in Figure 9 above from the server directory, the
package.json would automatically be generated the default settings without
going through an interactive process.
The index.js and app.js files are then added to the root of the server application
folder, including the installation of “dotenv” and ”express” packages as
dependencies. The logger.js and config.js files are also comprised inside the
utils folder.
The app.js file is created to be the actual application, which includes all the
tasks as well as some of the node packages to get the server to work properly.
Figure 11 below depicts the content of the initial app.js file created at the start of
the backend configuration.
• cookie-parser, on line 6, populates all the cookies in the request (or req)
property with an object keyed by cookie names after decoding the
Cookie header.
The index.js file merely imports the actual application from the app.js file and
later launches the application, as depicted in Figure 12 below.
On line 4, the logger is separated into its own so that all the log messages can
be managed in one place for writing logs to a file or sending them to external
log management services such as Graylog and Papertrail (FullStackOpen,
2022). The logger module’s function info is utilized for the console printout,
indicating that the application is currently executing on port 3003 from the
config.PORT of config-module. The response ’Running…’ from the application
came from the root URL loaded from app.js.
As Figure 13 depicts, the server folder contains six sub-folders, whereas the
main ones are controllers, middleware, models, and routes. The models folder
consists of all required mongoose schemas for the application. Meanwhile, all
the logical event handlers are stored in the “controllers” folder to execute
incoming requests that match the corresponding API routes defined in the
routes folder.
After setting the client, the connection between the server and client needs to
be implemented. By adding the proxy field as the following declaration in
package.json of the client folder, as shown in Figure 15 below, the server can
recognize the fetching on the client-side and then proxy the request to the
corresponding API request of the server in the development mode.
Since the client-side and server-side of the application are hosted on different
domains, the same-policy error will occur when fetching APIs from the client to
the server.
In order to mitigate the risks of cross-origin HTTP requests, the cors package is
installed. Then, by running the command ”npm install cors” in the server
directory and importing the module in the app.js file, as illustrated in Figure 16
below, the middleware is provided to enable CORS and customizable succinct
settings regarding the MERN stack application particularly.
TailwindCSS integration
For this thesis application, TailwindCSS was chosen to design the web
application's layout. According to TailwindCSS's official website, using the
PostCSS plugin while installing Tailwind CSS is selected as the most
frictionless method to integrate with Create React App. Since the application
uses TailwindCSS combined with SASS preprocessor to add custom style
components in the future, the process is quite different from regular CSS
integration. Instead of adding”@tailwind” directives for each of Tailwind’s layers
to CSS, it will be included in the global.scss file in the styles folder created in
the client directory, which indicates in Figure 17 below.
4 Project implementation
This chapter explains the implementation process of the web application. There
are two stages of the process: backend and frontend. The backend
implementation will demonstrate the Mongoose models, authentication and
authorization, routes and APIs construction, and the testing API process. On the
other hand, the frontend implementation will illustrate the process of handling
routes and implementing different pages to accomplish the desired user
behaviors specified in the project requirements in chapter 3.1.
User model
As depicted in Figure 18, there are three required fields: name, email, and
password, while the email is also set to unique because no two emails
simultaneously exist. The default value for the role field is 0, indicating the
typical user. By altering the value to 1 manually, the user becomes an
administrator. The cart field displays an array of added product items, whilst the
property ”timestamps” is enabled by setting to true to monitor the time when
updating the data by assigning createAt and updateAt properties to the schema.
Product model
As exhibited in Figure 19, the product model contains all of the fields, such as
title, price, description, content, images and category, that most e-commerce
products require. In addition, the product_id field allows the administrator to
customize the product’s id without affecting the generated _id in MongoDB. The
checked field, on line 12, is set for deleting multiple products function. The sold
field has 0 as the default value, and it is increased after each successful
purchase from a user.
Payment model
As seen in Figure 20, the payment model has the fields of user_id, name, email,
paymentID, address and cart. The payment schema also has the status field, on
line 11, indicating whether the cart is paid.
Category model
While all the aforementioned models seem complicated, the category model is
clear and precise, with simply name and timestamps fields, as indicated in
Figure 21.
User authentication
As seen on line 5 in Figure 22, the JWT token is extracted from the
Authorization request header and assigned as token variable. If no token is
present or the token is invalid, an error message along with status 401 will be
thrown. If yes, the verify() from jsonwebtoken package will be loaded. The
method takes the token and ACCESS_TOKEN secret key stored in the .env file,
and then the callback function is called to decode the token. When the token is
valid, the decoded payload user is assigned to the user request, and the control
is sent to the next() middleware function, or else the error is thrown, and the
request will be left hanging.
Admin authorization
Figure 23 above indicates the process of authorizing the admin user in detail.
Firstly, the user information is retrieved based on the id of the user model.
Then, the user role is evaluated whether it is admin or not. If the test passes,
the user is an admin and can access the routes.
A JWT token can be stored in two main methods: localStorage and cookies.
LocalStorage is the most used thanks to its convenience and access to third-
party APIs without setting a backend. However, it is vulnerable to XSS attacks.
By running any Javascript script inside the page, an attacker can have
permission to take the access token stored in localStorage. Therefore, to secure
the JWT token from XSS, storing it in the httpOnly cookie is recommended.
httpOnly cookie is a unique type of cookie that is only transmitted to the server
in HTTP requests, so it is impossible to access via JavaScript and is not
vulnerable to XSS attack as localStorage. Even though the cookie can still be
vulnerable to CSRF attacks, it can simply be mitigated by setting the
”sameSite=true” flag in the cookie and an anti-CSRF token (Michelle Wirantono,
2020).
Therefore, the best option to securely store JWT is to store the refresh token in
the httpOnly cookie and the secure and sameSite flags to prevent XSS and
CSRF attacks. The process is included in the register and login controllers of
the user model. Figure 24 below shows the logic of token implementation in the
register controller:
The access token is then obtained and sent to the Response object as a JSON
string.
After that, the access token should be stored as a variable in the client site to
remain invisible when switching tabs or reloading the website.
Figure 25. Get refresh token logic controller for user model.
As Figure 25 depicts above, the refresh token is obtained from req.cookie when
logging or registering successfully and saved as rfToken. After verifying the
refresh token with verify() method from jwt and REFRESH_TOKEN secret key,
a unique access token is generated and sent to the Response object as JSON.
Distribution and exchange of data across two or more systems have long been
vital elements of software development, so REST API is considered. API,
abbreviated for Application Programming Interface, is a collection of rules that
enable the interaction of two applications or systems, whereas REST
(Representational State Transfer) dictates the appearance of the API. REST is
a set of architectural constraints that enables two computer systems to interact
through HTTP, similar to the communication between web browsers and
servers (Gupta, 2022). Therefore, it is a set of guidelines that developers must
adhere to while developing APIs. Figure 26 below illustrates all of the product-
related API routes with their associated method and actions as well as the
usage of router-level middlewares.
During the process of server development, testing is also taken into account to
assure the logic of handling the requests works appropriately. Therefore, a
third-party tool or extension is preferable to writing test code in the server folder.
Therefore, Postman is a popular choice for this situation. However, it has plenty
of drawbacks. Firstly, it is a separate application, and thus it needs to be
downloaded and installed. Therefore, it requires switching context since it
separates from IDE used for development, which can cause RAM consumption
and slow down the computer. Secondly, the version control is not well-
supported in the free tier, and it depends strongly on the Postman GUI, which is
different from Git for the version control on the project. (Baron, 2021)
REST Client – a VSCode extension for sending HTTP requests and viewing the
response directly in VSCode – is considered to solve these problems. By
creating a directory named requests at the root of the server application after
installing the plugin, all the REST client requests can be stored in the directory
as files with the ”.rest” suffix. Figures 27 and 28 indicate the product deletion
testing using REST Client.
Figure 28. The result of product deletion testing with REST Client.
In Figure 27, the HTTP DELETE request fetches the product with the relevant id
defined on the left window. The Authorization header is also included with the
token verifying the user based on role. After clicking the ”Send request” text, the
HTTP request is executed, and the server response in detail is opened as a
new tab, which indicates in Figure 28. The result throws the status ”204 No
Content”, indicating that the product is no longer in the database and the
deletion is successful.
4.2.1 Routing
The <Routes> and <Route> are the primary methods to render in React Router,
depending on the current location. <Routes> searches through its children
<Route> components for the best match and displays that branch of the UI
when the location changes. Figure 30 below indicates all of the route paths that
render based on the different types of users:
As depicted above, <Routes> will search for the route corresponding to the
URL; if the route "/products" is found, it will cease searching and present just
the ProductList component. Alternatively, if <Routes> is not intended to be
utilized, as seen in Figure 30 above, it will continue to check for matching routes
until the end. As a result, it will display all the imported components mentioned
from line 5 to line 15 in Figure 30, as all routes beginning with "/" will match the
URL.
4.2.2 Homepage
The Homepage is set as default when a visitor or a user first navigates to the
web application. The user interface of the Homepage is shown in Figure 31
below.
As Figure 32 shows above, the best-selling products will be fetched from the
server to the client using the Axios package inside the useProducts hook and
saved as bestSellers, and the product list is formed by using the map and slice
methods from JavaScript to get the four highest selling items and then construct
the ProductItem components. The ProductItem contains the title, category and
“Add to cart” button with the addCart function imported from the useUser hook.
When clicking Add to cart button on a particular product, the error message will
be shown if the user does not sign in. This function will check to see whether
the product has already been added to the cart. If not, the product is added to
the cart and subsequently sent to the database using the PATCH method.
Figure 33 below illustrates the functionality of adding the product to the
shopping cart.
Register Page
The Register page allows visitors to sign up for a user account and log in so as
to purchase products on the site. Regarding the user experience enhancement,
it is sufficient to access certain pages of the application as a visitor, such as
Homepage and Product page, without requiring logging into the platform. Figure
34 below illustrates the user interface of the Register page:
The Register page contains the share navigation bar with the Homepage based
on the layout. It also includes a form right below the navigation bar with input
fields such as name, email, and password. After entering valid data and
pressing the Register button to confirm the account creation process, the POST
request will be fetched to the “user/register” route from the backend with user
data under JSON format. If the input email already exists or the input password
is shorter than six characters, an error asserting the following issues will be sent
back from the backend and displayed on the page as an alert window.
Conversely, a new model user instance is generated and saved into the
database. Finally, the page will sign the user in as the registration process is
successful.
Login page
The Login page is similar to the Register page, except that only email and
password fields are displayed. In addition, the Login page allows users to
perform tasks such as checking the order history or purchasing products. Figure
35 below is the code implementation of logic for the login functionality.
As Figure 35 depicts, the user variable is initially declared with an empty object
containing email and password by using the useState hook. When the email
and password are entered, the onChangeInput function is triggered to
immediately update the user variable's state. After the user info is submitted by
clicking the Login button, the loginSubmit function is generated by fetching the
“user/login” using the POST method and then sending the user to the server.
illustrated in Figure 36 below. In addition, the user login status in Local Storage
is updated to true to confirm the user successfully login to the application.
Logout functionality
After users log in, the navigation bar will be modified to include the logout icon.
When the user selects the “Logout” icon, the logout function, indicated in Figure
37 below, is generated by fetching the ‘/user/logout’ route using the GET
method. The login status is then removed from the Local Storage, and the user
will be redirected to the Homepage as a successful confirmation.
The Products page is one of the essential pages of the application, which
demonstrates all the products of the shop. Figure 38 below demonstrates the
user interface of the Products page:
As shown in Figure 38, there are four components portraited on this page: filter,
search, product list and product card. The filter component is on the left side,
containing two sorting features. The ‘Filter’ sorts product list based on category,
while the ‘Sort’ one is based on product price, highest sales, and time, which
depends on createAt property. The Search component renders the search
engine on top of the page and below the shared navigation bar. The product list
component renders eight products each time, along with an arrow down button
for loading more products. Figure 39 below is the data fetching for the product
list using the GET method:
The Product Detail page allows users to learn more about a product in greater
depth. Figure 41 denotes the codebase of the DetailProduct component.
As depicted in Figure 41, from line 4 to line 17, the product name, image,
category, description, price, and the number of product that has been sold are
rendered on the Product Detail page. Below the product information, two
buttons with equivalent functionality dependent on user role are then performed.
Additionally, the products in the same category as the current item are
presented below. The ProductCard component for rendering products is once
again deployed. In addition, the logged-in users are able to add the product to
the cart by clicking the “Buy Now” button, which will send the product to the user
information.
The Cart page is regarded as the final page on which users can complete their
purchase. It displays the items that have been added to the cart. By clicking the
Cart icon in the navigation bar, the user will be redirected to the Cart page.
Below is the UI demonstration of the Cart page:
In Figure 42, the order items are displayed, and the user can update the
quantity of each product or remove it from the shopping cart while examining
the total price of each product depending on its quantity. Although the
All administrator pages are password-protected, and users must have the
administrator role to access them. After signing in as an administrator, the
navigation bar will be changed to correspond with the administrators’ actions,
with the Administrator Homepage, Create Product page, and Categories page
being titled accordingly.
Administrator Homepage
The Create Product page contains a form to fill out the product information and
the image uploader to provide the visualization of the product. To establish a
new product, an administrator must complete all of the required fields in the
form and provide a proper image. Then, the new product will be generated and
added to the database. Figure 44 below illustrates the user interface of the
Create Product page.
Categories Page
5 Deployment
After building the application on the local machine is complete, the deployment
stage should be considered to bring the application to the users as well as
assure a better user experience. Therefore, Heroku cloud hosting was utilized
to host this thesis application. Heroku is a supplier of cloud-based application
hosting services, and it is well-known due to its straightforwardness,
accessibility, and profitability. Initially, the “client/build” folder is generated by
running the command “npm run build” to create the production build for the
frontend, and the build directory containing static files is then copied to the root
of the server repository. Additionally, the middleware declaration demonstrated
in Figure 46 below is added in the “server/app.js” file in order to make the server
display the files with static content.
Finally, environment variables are added to the Heroku platform, and the
application is successfully built and deployed instantly. By running the
command on line 5 in Figure 47 above, the application can be rebuilt and
redeployed whenever an updated version is released, and the “logs:prod”
command on line 6 demonstrates the Heroku logs with the real-time session.
6 Testing
Testing is essential for quality assurance since it verifies that the application is
functional and compatible with the majority of contemporary browsers such as
Chrome, Microsoft Edge, Safari, and Firefox. Therefore, the browser
compatibility test conducted in the aforementioned browsers was successful.
The functionality test is taken into account, including verifying all the links,
observing products with images, sorting the product list ascendingly and
descendingly based on added date and price, and filtering the products by
category and best seller. Furthermore, the add cart functionality modifying the
products in the shopping cart, completing the payment using Paypal, and
checking their own order history were examined for the logged-in user. On the
other hand, the product information was updated for the administrator, adding
new products, modifying the category list, and all users’ order reviews were
analyzed. As a result, all functions operate correctly. Therefore, as per the
criteria, the test was successful.
Figure 48. Products are sorted based on category and ascending price.
Figure 49. Product Detail Page with Related Products based on category.
Figure 54. The order details include the customer name, delivery address, and
order info.
7 Discussion
7.1 Results
In the end, the E-commerce web application was successfully constructed and
deployed by utilizing the MERN stack as the primary fullstack technology,
demonstrating that the MERN stack has the ability to develop the complicated
fullstack application. The final version of the application was built using
MongoDB, Express, React, and NodeJS in combination with various tools and
libraries, and the deployed web application can be accessed at
https://bookaholic-shop.herokuapp.com/.
Throughout the thesis, the technologies and techniques utilized were thoroughly
discussed. Consequently, the completed application achieves all the criteria
specified in the project requirements. Any visitor can browse the products and
select an individual item to access its details. Users can log in to the system,
add products to the shopping cart, manage the cart, complete the transaction
and review their purchase history. Users with the administrative role, on the
other hand, can add products, update product information and check the detail
of all users’ orders. The application is approachable, straightforward, and
practical since it only requires a few steps for any visitor to transition from being
an anonymous user to completing the transaction on the platform.
the responsive design device for accessing various devices, including tablets
and mobile phones, can be implemented in the future to provide a better user
experience. Furthermore, since Paypal is the sole payment mechanism of the
application at the moment, additional payment options, such as Stripe, Visa,
and MasterCard, can be installed. Additionally, registration and logging
functionality using third-party mailing services or social media platforms such as
Gmail, Outlook, and Facebook can be constructed to accelerate the sign-in
process as well as enhance the user experience. Moreover, email notifications
can be considered to verify the sign-in accounts and confirm successful
payment. The order status is also considered to monitor the shipping or delivery
process, allowing administrators to control the process and users to track the
orders. Finally, the product rating and review feature can be implemented to
enable users to evaluate products and compare product ratings and reviews
before making a purchase.
8 Conclusion
The aim of the thesis was to study and understand the fundamental concepts of
each technology in the MERN stack and, as a result, build an E-commerce web
application for the online shop based on it. The thesis conducted an in-depth
examination of the MERN stack fundamental principles as well as libraries and
tools that supplement the MERN stack utilized to construct the application.
The thesis can be utilized to reference the MERN stack, assisting people
interested in learning more about the MERN stack development. As a result, the
MERN stack demonstrated its ability to construct complicated full-stack
applications. However, the final application might be further enhanced by
including new features such as responsive web design for various devices,
other payment options, third-party mailing services and social network login,
sign-in email notifications, and product rating and review capabilities.
Furthermore, additional sophisticated principles, such as server-side rendering,
and testing, might be included to enhance various elements of the application.
References
Facebook Inc., 2022d. React – A JavaScript library for building user interfaces.
[online] Available at: https://reactjs.org/ [Accessed 24 April 2022].
Facebook Inc., 2022f. Using the Effect Hook – React. [online] Available at:
https://reactjs.org/docs/hooks-effect.html [Accessed 12 May 2022].
Facebook Inc., 2022g. Using the State Hook – React. [online] Available at:
https://reactjs.org/docs/hooks-state.html [Accessed 12 May 2022].
Facebook Inc., 2022h. Virtual DOM and Internals. [online] Available at:
https://reactjs.org/docs/faq-internals.html [Accessed 09 April 2022].
Gupta, L., 2022. What is REST. [online] REST API Tutorial. Available at:
https://restfulapi.net/ [Accessed 24 April 2022].
MDN Web Docs. 2022b. Introduction to the DOM - Web APIs | MDN. [online]
Available at: https://developer.mozilla.org/en-
US/docs/Web/API/Document_Object_Model/Introduction [Accessed 24 April
2022].
MDN Web Docs. 2022c. Using HTTP cookies - HTTP | MDN. [online] Available
at: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies [Accessed 09
February 2022].
MongoDB Inc., 2013. The MEAN Stack: MongoDB, ExpressJS, AngularJS and
Node.js | MongoDB Blog. [online] MongoDB. Available at:
https://www.mongodb.com/blog/post/the-mean-stack-mongodb-expressjs-
angularjs-and [Accessed 29 April 2022].
MongoDB Inc. n.d. What Is The MERN Stack? Introduction & Examples. [online]
Available at: https://www.mongodb.com/mern-stack [Accessed 24 April 2022].
Tailwind Labs Inc., 2022. Install Tailwind CSS with Create React App. [online]
Tailwindcss. Available at: https://tailwindcss.com/docs/guides/create-react-app
[Accessed 15 March 2022].
UNCTAD, 2021. How COVID-19 triggered the digital and e-commerce turning
point. [online] UNCTAD. Available at: https://unctad.org/news/how-covid-19-
triggered-digital-and-e-commerce-turning-point [Accessed 29 April 2022].
Visual Studio Code. n.d. Documentation for Visual Studio Code. [online]
Available at: https://code.visualstudio.com/docs [Accessed 24 April 2022].
Wirantono, M., 2020. LocalStorage vs. Cookies: All You Need to Know About
Storing JWT Tokens Securely in the Frontend - JavaScript inDepth. [online]
inDepthDev. Available at: https://indepth.dev/posts/1382/localstorage-vs-
cookies [Accessed 10 March 2022].