Chat.App.Using.Reactjs.Report
Chat.App.Using.Reactjs.Report
MINI PROJECT
Report
on
“CHAT APPLICATION
USING REACT.JS”
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING
2020-21
SUBMITTED
BY
DIVAKAR D G SUHAS
1DA18CS047 1DA18CS049
CERTIFICATE
This is to certify that the Project work entitled “CHAT APPLICATION USING
REACT.JS” submitted in the partial fulfilment of the 6th semester Mini-Project curriculum
during the year 2020-21, is a result of bonafied work carried out by
DIVAKAR D G SUHAS
1DA18CS047 1DA18CS049
Signature of Guide:
Mr. Harish G
Assoc,Prof , Dept of CSE
Dr.AIT
1. Internal examiners
2. External examiners
Dr. Siddaraju,
H.O.D
Department of CSE,
Dr.AIT
ACKNOWLEDGEMENT
The satisfaction that accompanies to this project would be incomplete without the mention of
the people who made it possible, without whose constant guidance and encouragement would have
made our efforts go in vain
We consider ourselves privileged to express our gratitude and respect towards all those who
guided us through the project, “Chat Application using react.js”.
We would like to express our gratitude to Dr. M. Menakshi, Principal Dr. AIT, for providing
us the congenial environment to work in.
We would like to express our profuse gratitude to Dr. Siddaraju, HOD, Dept. of Computer
Science & Engineering, Dr. AIT, for giving us the support, encouragement and providing us the
required lab facilities that was necessary for the completion of this project.
As a token of gratitude, we would like to acknowledge our sincere gratefulness to the internal
guide Mr. Harish G, Associate Professor, Dept. of CSE, Dr.AIT, for her unlimited support and
encouragement provided throughout the process.
We also express our gratitude and sincere thanks to all the teaching and non-teaching staff of
Computer Science & Engineering Department.
Finally, yet importantly, we would like to express our heartfelt thanks to our beloved Parents
for their blessings and our Friends for their help and wishes for the successful completion of this
project report
DIVAKAR D
G SUHAS
ABSTRACT
The web app that allows the users to create account and login safely either by Google
Auth or Email & password login with the help of firebase Authentication. The main goal is to
allow the users to share the information remotely and safely, Firebase embedded with firebase
authentication, firebase storage, firebase firestore realtime database for managing users data
safe and secure.
Our web chat app allows the users to send various types information like “text, video’s, image,
emoji” it handles any unexpected error or exceptions by giving a pop up notification to users.
The web app allows the users to create a room and chat with mass group of people at once
Table of Contents
Chapter 1 Introduction 1
Chapter 2 Literature Survey 2
Chapter 5 Testing 29
Chapter 6 Snapshots 33
Conclusion 37
Future Enhancement 38
Bibliography 39
Chat Application using reactjs Page No:1
CHAPTER 1
INTRODUCTION
Communication is a mean for people to exchange messages. It has started since the
beginning of human creation. Distant communication began as early as 1800 century with the
introduction of television, telegraph and then telephony. Interestingly enough, telephone
communication stands out as the fastest growing technology, from fifixed line to mobile
wireless, from voice call to data transfer. The emergence of computer network and
telecommunication technologies bears the same objective that is to allow people to
communicate. All this while, much efforts has been drawn towards consolidating the device
into one and therefore indiscriminate the services. Chatting is a method of using technology to
bring people and ideas together despite of the geographical barriers.
Messaging apps are great way to share information in direct messages, from yahoo
chat that started in those early days of internet to snapchat, whatsApp and Facebook’s highly
sophisticated chat messenger, online Chat application have evolved dramatically over last
decade. At the heart of these chat app innovation lies fascinating for web technology that was
earlier seen as a fleeting fad. As now more than 70% of total visits on top digital news websites,
the need for developing web-specific chat apps has escalated.
In an attempt to simulate the functions of realtime chat and providing the users with rich and
easy UserInterface(UI), allowing them to connect with their surroundings by just a simple
signup a web based chat application been built.
Our Web based chat application created with the help of react, react is built around
components, and to manage our user related data google’s Firebase technology been used,
frontend of the chat application is built using reactjs UI components, connecting with people
is very much essential in today’s world, and allow them to share information fast, safe and
secure, we managed to develop web based chat application that allow the user to share the
information like text, images, videos and emoji’s to express their thoughts and feelings to
opposite user.
Users can get messages in realtime with fraction of second with the help of firebase firestore
NoSql database to store any amount of data & retrieve it as often as we like. Safe, secure and
flexible storage with great set of development tools. Users are authenticated using Google
OAuth and with their Email and Password authentication. Users data are safe with strong
firebase firestore security rules. In our web chat application users can make sure that their
friend is in online or not database is quick to update the state of users to all users in realtime.
Combined these two powers to provide the basic chat app facilities to users and allow them to
stay connected.
CHAPTER 2
LITERATURE SURVEY
2.1 REACTJS
React(also known as React.js or ReactJS) is a free and open source front-end JavaScript
library for building user interface or UI components. It is maintained by Facebook and a
community of individual developers and companies. React can be used as a base in the
development of single page or mobile applications. React’s popularity today has eclipsed that
of all other front end development frameworks
Features of React
2. Virtual DOM
3. Performance
4. Extensions
React goes beyond simple UI design and has many extensions that offers complete
application architecture support. It provides server-side rendering, which entails rendering a
normally client-side only web application on the server.
React’s one-way data binding keeps everything modular and fast. A unidirectional data
flow means that when developer designs a react app, they often nest child components.
This way a developer knows where error accurs.
2.2. FIREBASE
Firebase is a toolset to “build, improve, and grow your app”, and the tools it gives you cover a
large portion of the services that developers would normally have to build themselves, but don’t
really want to build, because they’d rather be focusing on the app experience itself. This
includes things like analytics, authentication, databases, configuration, file storage, push
messaging, and the list goes on. The services are hosted in the cloud, and scale with little to no
effort on the part of the developer.
a. Cloud Firestore
NoSql database built for global apps, Cloud Firestore is a NoSql document database
that lets you easily store, sync, and query data for your mobile and web apps-at global
scale
b. Authentication
Firebase Authentication provides backend services, easy-to-use SDKs, and ready-
made UI libraries to authenticate users to your app. Normally, it would take you months
to set up your own authentication system. And even after that, you would need to keep
a dedicated team to maintain that system. But if you use Firebase, you can set up the
entire system in under 10 lines of code that will handle everything for you, including
complex operations like account merging.
CHAPTER 3
Requirement analysis is a software engineering technique that is composed of the various tasks
that determine the needs or conditions that are to be met for a new or altered product, taking
into consideration that the possible conflicting requirement of various users.
3.1 Hardware & Software Requirement
3.1.1 Hardware Requirements
The hardware requirement specifies the necessary hardware which provides us the
platform to implement our programs.
The software requirement specifies the pre-installed software needed to run the code
being implemented in this project.
Functional requirements are those requirements that are used to illustrate the internal
working nature of the system, the description of the system, and explanation of each subsystem.
It consists of what task the system should perform, the process involved, which data should the
system holds and the interfaces with the user. The functional requirements identified are:
The web chat app should provide a state update of all the users in realtime.
It describes aspects of the system that are concerned with how the system provide
the functional requirements They are:
Security: Only the authorized users allowed to participate in chatting a make new
friends, database is secured and accessed only by the authorized users who logged in.
The database security rules built to provide the high security to the users data.
Performance and Response time: The system should have high performance rate
when executing user’s input and should be able to provide response within a short time
span
CHAPTER 4
App.js
Sidebar.js
Authorized
User
Main_Container.js
Chat_Message.js
Figure 4.1
Chat_Input.js
The System Design is based on web application design which is compact for mobile browser
which allows users to chat remotely and get connected with others. This system design contains
main modules such as app.js which includes login module signup module and Home module
where users are landed once they login securely. We briefly explain these modules below.
Login
The login module gives a measure for user to login with email and password. If the person is
new user then he/she can create account with his email in the signup page or he/she can login
directly using Google account. If user forgot his/her password, he/she can reset the password
with the link sent to their verified email ID.
Home
Main_Conatiner Sidebar
Chat_Message
Chat_Input
Figure 4.1 (b)
Home module is the main module where users are landed once they login, Home module
contains sidebar where the users friends list is visible, Main_Container includes
Chat_Messages which retrieves messages data from database and shows to the user and also
includes the Chat_Input which takes the input from user and stores in database.
User Login
Figure 4.2
4.3 Use Case Diagram
Figure 4.4
CODING
App.js
50 <Container>
51 <Online>
52 <Router>
53 <Switch>
{
54
loading ?
55 <ClipLoader
56 size={100}
57 color={'#7335dd'}
58 loading={loading}
59 />
60 :
61 <Route exact={true} path="/">
62 <div className="front">
63 <FrontPage />
</div>
64
</Route>
65
}
66 {
67 loading ?
68 <center>
69 <div
70 className="shadow p-3"
71 style={{ backgroundColor: "#E7E7E7", justifyContent: "center"}}
72 >
73 <Loading type="bars" color="black" height={100} width={100} />
74
<h3>Processing...</h3>
75
</div>
76 </center>:
77 <Route exact={true} path="/forget">
78 <Forget />
79 </Route>
80 }
81
82 {!user && signUp ? (
83 <Route exact={true} path="/login">
84 <SignUp setSignUp={setSignUp} />
</Route>
85
) : !user && !signUp ? (
86 <Route exact={true} path="/login">
87 <Login setUser={setUser} setSignUp={setSignUp} />
88 </Route>
89 ) : (
90 <Switch>
91 <Route path="/login">
92 <Home signOut={signOut} user={user}/>
93 </Route>
94 <Route path="/:userId" exact>
<div className="chatDisplaysmall">
95
<MainContainer userName={user.fullname}/>
96
</div>
97 <div className="chatDisplay">
98 <SideBar signOut={signOut} user={user} />
99 <MainContainer userName={user.fullname} />
100 </div>
101 </Route>
102 <Route path="/signup">
103 <SignUp />
104 </Route>
105 </Switch>
)}
106
107 </Switch>
108 {/*<Route path="\*" component={Notfound}/>*/}
109 </Router>
110 </Online>
<Offline >
111
<PermScanWifiIcon className="wifi"/>
112 <span style={{fontSize: "20px"}}>Please check your connection</span>
113 </Offline>
114 </Container>
115 );
116 }
117
118 export default App;
119
120 const Container = styled.div`
margin:0;
121
padding:0;
122
display: flex;
123 width: 100vw;
124 min-height: 100vh;
125 height: fit-content;
126 justify-content: center;
127 align-items: center;
128 background: linear-gradient(to bottom, #7335dd 20%,#dbdbdb 0%,#dbdbdb 50%,#dbdbdb 80%);
129 `;
Pages:
Login.js
28 isOnline: true
29 };
30 setUser(newUser);
31 localStorage.setItem("user", JSON.stringify(newUser));
db.collection("users").doc(result.user.uid).set(newUser,{merge: true});
32
// db.collection('users')
33 // .doc(auth.currentUser.uid)
34 // .update({
35 // isOnline: true,
36 // lastOnline: firebase.firestore.Timestamp.now(),
37 // })
38 })
39 .catch((err) => toast.error(err.message,{position: toast.POSITION.TOP_CENTER, autoClose:
40 2000,hideProgressBar: true}));
41 };
42
const signInWithEmail =async (e) => {
43
e.preventDefault();
44 setLoading(true);
45
46 auth
47 .signInWithEmailAndPassword(email, password)
48 .then((auth) => {
49 if (auth.user.emailVerified) {
50 dispatch({
51 type: "SET_USER",
52 user: auth.user,
});
53
const newUser = {
54 name: auth.user.displayName,
55 photo: auth.user.photoURL,
56 isOnline: true
57 };
58
59 setUser(newUser);
60 localStorage.setItem("user", JSON.stringify(newUser));
61
62 db.collection('users')
.doc(auth.user.uid)
63
.update({
64 isOnline: true
65 })
66
67 } else {
68 toast.error("Please Verify Your Account",{position: toast.POSITION.TOP_CENTER,
69 autoClose:3000,hideProgressBar: true});
70 }
71
72 setLoading(false);
})
73
.catch((error) => (toast.error((error.message),{position: toast.POSITION.TOP_CENTER,
74
autoClose: 2000,hideProgressBar: true}),setLoading(false)));
75 };
76
77 console.log(loading)
78
79 return (
80 <Container style={{backgroundImage:"linear-gradient(to bottom, rgba(230, 230, 255, 0.8),
81 rgba(230, 230, 255, 0.7)),url("+back+")",
82 backgroundRepeat:"repeat"}}>
83 <Header>
<div className="header__logo">
84
Signup.js
76 })
77 .catch((error) => (toast.error(error.message,{position: toast.POSITION.BOTTOM_CENTER,
78 autoClose: 2000, hideProgressBar:true}),setLoading(false)));
79 };
80
const setPicture = async (e) => {
81 setDisable(true);
82 const file = e.target.files[0];
83 console.log(file);
84
85 const fileRef = storageRef.child(file.name);
86 await fileRef.put(file);
87 const link = await fileRef.getDownloadURL();
88 setProfile(link);
89 console.log(profile);
setDisable(false);
90
};
91
92 return (
93 <Container style={{backgroundImage:"linear-gradient(to bottom, rgba(230, 230, 255, 0.8),
94 rgba(230, 230, 255, 0.7)),url("+back+")",backgroundRepeat:"repeat"}}>
95 <Header>
96 <div className="header__logo">
97 <Link to="/">
98 <img src={Logo} alt="logo" />
99 </Link>
100 </div>
101
<div className="header__title">
102 <Link to="/" style={{textDecoration:"none", color:"#000"}}>
103 <p>Connect</p>
104 </Link>
105 </div>
106 </Header>
107 <SignUpComponent >
108 <h3>Create an Account<PersonAddIcon className="icon"/></h3>
109
110 <SignUpForm onSubmit={signUp}>
<Name>
111
<input
112 type="text"
113 name="name"
114 placeholder="Enter FullName"
115 value={fullname}
116 onChange={(e) => setFullname(e.target.value)}
117 required
118 />
119 <PersonIcon className="icon"/>
120 </Name>
<Email>
121
<input
122
type="email"
123 name="email"
124 placeholder="Enter email"
125 value={email}
126 required
127 onChange={(e) => setEmail(e.target.value)}
128 />
129 <EmailIcon className="icon"/>
130 </Email>
131 <Password>
<input
132
133 onPaste={(e)=>{
134 e.preventDefault()
135 return false;
136 }} onCopy={(e)=>{
e.preventDefault()
137
return false;
138 }}
139 required
140 type={isRevealPwd ? "text" : "password"}
141 name="password"
142 placeholder="Enter Password"
143 value={password}
144 onChange={(e) => {validate(e.target.value); setPassword(e.target.value);}}
145 />
146 <LockIcon className="icon"/>
<img
147
title={isRevealPwd ? "Hide password" : "Show password"}
148
src={isRevealPwd ? hidePwdImg : showPwdImg}
149 onClick={() => setIsRevealPwd(prevState => !prevState)}
150 />
151 <br />
152 <span style={{color: 'gray', fontSize: '14px'}}>
153 <ul>
154 <li>Lenght of password should be 6</li>
155 <li>Lowercase atleast 1</li>
156 <li>Uppercase atleast 1</li>
157 <li>Numbers(0-9) atleast 1</li>
<li>atleast one Special Character(@,$,%,^)</li>
158
</ul>
159 </span>
160 <span style={errorMessage ==='Strong Password'?{fontWeight: 'bold', color: 'green'}:
161 {fontWeight: 'bold', color: 'red'}}>{errorMessage}</span>
162 </Password>
163
164 <RePassword>
165 <input
166 onPaste={(e)=>{
167 e.preventDefault()
return false;
168
}} onCopy={(e)=>{
169 e.preventDefault()
170 return false;
171 }}
172 required
173 type="password"
174 name="repassword"
175 placeholder="Re-Enter password"
176 value={repassword}
177 onChange={(e) => {CheckMatching(e.target.value); setRepassword(e.target.value);}}
178 /><br />
179 <span style={{fontWeight: 'bold', color: 'red', fontSize: '13px'}}>{matchError}</span>
180 </RePassword>
181
182 <ProfilePicture>
183 <p>Profile Picture</p>
184
185 {disable && <Default color="blue" size={16}/>}
186 <input accept="image/*" type="file" onChange={setPicture} disabled={disable||loading}
187 />
189 </ProfilePicture>
190 {loading && <Default color="blue" size={16}/>}
191 <button type="submit" disabled={disable||loading}>
Home.js
27 height: 100vh;
28 // min-height: 600px;
29 // max-height: 1400px;
30 // background-color: red;
position: relative;
31
@media (max-width: 1366px) {
32 justify-content: flex-start;
33 }
34 @media (min-width: 1000px) {
35 width: 95vw;
36 height: 90vh;
37 min-height: 600px;
38 box-shadow: -4px 10px 40px -6px rgba(0, 0, 0, 0.80);
39 }
40 `;
Main Container.js
Sidebar.js
Chat Message.js
TESTING
Divakar D & G
DEVELOPED BY Divakar D & G Suhas EXECUTED BY
Suhas
DEVELOPED EXECUTED
10-7-2021 10-7-2021
DATE DATE
In this test case verifies that once user created an account using email and password the user
gets an instant verification link by clicking create account button.
On trying to log in without verifying the mail, the website alerts the user to verify before
logging in.
The chat application won’t be able to update the database when internet connectivity is
disabled
SNAPSHOTS
Desktop/Laptop View Mobile View
Login Page
Add Attachments
CONCLUSION
The project Chat application using react js was completed successfully. There is always a room
for improvements in any web based app. We achieved in connecting two individuals, one-to-
one communication. There are several web based app which serves similar purpose as this
project, but these web based apps were rather difficult to use and may provide complicated user
interface which leads to difficult in figuring out, users interface should be easy and effective.
This project main goal was to create a simple, secure web based chat application which can
accessed on any device using browser and without having to install any application externally.
FUTURE ENHANCEMENT
Our Chat application is made for connecting two individuals and allow them to chat personally
share information we say that there’s some limitations which we have to follow inorder to
achieve, with this note we can say that our chat application will not allow users to create groups
or adding participants into a single group and sending a mass message to all users at a time
future enhancement would be allowing users to create a group and chat also making a video
call chats.
BIBLIOGRAPHY
To Learn Visual Studio Code
https://code.visualstudio.com/learn
Learn Nodejs
https://nodejs.dev/learn/
Learn reactjs
https://reactjs.org/docs/getting-started.html