Manav Final Sem Project-1
Manav Final Sem Project-1
On
REAL CHAT APPLICATION
Submitted in partial fulfillment of requirements
for the award of the degree
Bachelor of Technology
In
Computer Science and Engineering
To
IKG Punjab Technical University, Jalandhar
SUBMITTED BY:
Name: Manav Maini
Roll no.: 2003223
Semester:8th
Batch:2020-2024
This is to certify that Mr. Manav Maini has partially completed / completed / not
completed the Semester Training during the period from 10th Jan 2023 to 10th Jun 2023
in our Organization / Industry as a Partial Fulfillment of Degree of Bachelor of
Technology in Computer Science & Engineering.
Date: 20-05-2024
i
CANDIDATE DECLARATION
I hereby declare that the Project Report entitled ("Real Chat Application") is an authentic
record of my own work as requirements of 8th semester academic during the period from
10th January 2023 to 10th June 2023 for the award of degree of B.Tech. (Computer
Science & Engineering, Chandigarh Engineering College- CGC, Landran, Mohali under
the guidance of (Mr. Rajeev Sharma).
(Signature of student)
Certified that the above statement made by the student is correct to the best of our
knowledge and belief.
Signatures
Examined by:
1. 2. 3. 4.
Head of Department
(Signature and Seal)
ii
ACKNOWLEDGMENT
I am highly grateful to the Dr. Sukhpreet Kaur HOD CSE, Chandigarh Engineering
College, Landran (Mohali). I would like to expresses my gratitude to other faculty
members of Computer Science & Engineering department of CEC, Landran for providing
academic inputs, guidance & Encouragement throughout the training period. The help
rendered by Mr. Rajeev Sharma, Supervisor for Experimentation is greatly
acknowledged. Finally, I express my indebtedness to all who have directly or indirectly
contributed to the successful completion of my semester training.
iii
ABOUT COMPANY
As a final semester student pursuing a degree in Computer Science & Engineering, I had
the opportunity to gain valuable industry experience through a Six-month Semester Training
program with Technext Global Education Pvt. Ltd.
Technext Global Education Pvt. Ltd is a leading Software and Web Application
Development Company, based in Fazilka (Punjab), that provides high-quality
comprehensive services to enterprises across a wide range of platforms and technologies.
Our major areas of expertise are in providing quality, cost-effective software, or web
development services. Technext Global Education Pvt. Ltd. is an acclaimed IT service
provider contributing its part in the development of many businesses around the globe. We
socialize with our clients to get a superior cognizance of their business and requirements
and help them in fabricating websites and applications for their business.
iv
ABSTRACT
Real Chat is a modern, real-time chat application built using the MERN (MongoDB, Express.js,
React.js, Node.js) stack, offering users a seamless communication experience. The project aims
to develop a robust, scalable, and feature-rich chat platform that leverages the power of MERN
technologies for both frontend and backend components.
Key features of Real Chat include real-time messaging, user authentication and authorization,
multimedia support, group chats, and a responsive user interface. MongoDB is utilized as the
database to store user information and chat history, while Express.js and Node.js handle the
backend logic and RESTful API endpoints. React.js powers the frontend, providing a dynamic
and interactive user interface.
The project focuses on implementing efficient data synchronization mechanisms to ensure real-
time updates across all connected clients. Additionally, security measures such as encryption
of messages and secure user authentication are integrated to safeguard user privacy and data
integrity.
Real Chat not only serves as a practical chat application but also serves as a learning resource
for developers interested in building real-time web applications using the MERN stack. The
project's modular architecture and clean codebase facilitate easy customization and extension,
making it suitable for various use cases and deployment environments.
Real Chat incorporates a wide range of functionalities to enhance user engagement and
productivity. These include real-time messaging with instant updates, user authentication and
authorization mechanisms for secure access control, multimedia support for sharing images,
videos, and files, group chat functionality for collaborative discussions, and a responsive user
interface optimized for various devices and screen sizes.
MongoDB serves as the primary database for storing user profiles, authentication data, and chat
history, ensuring efficient data management and retrieval. Express.js and Node.js form the
backend infrastructure, handling the business logic, routing, and communication with the
database through RESTful API endpoints. React.js powers the frontend, enabling dynamic
rendering of UI components and seamless interaction with the application.
v
Table of Contents
CONTENT
PAGE NO.
Certificate .............................................................................................................................. i
Abstract ................................................................................................................................ v
List of Tables.......................................................................................................................ix
1.2 Objective…………………………………………………………………………………….2
1.3 Scope…………………………………………………………………………………………3
1.5.1 Hardware…………………………………………………………………………………7
1.5.2 Software………………………………………………………………………………….7
vi
2.2 Project Feasibility Study……………………………………………………………………10
3.4 ER Diagrams………………………………………………………………………………. 17
4.1.1 History………………………………………………………………………………...29
4.2 HTML…………………………………………………………………………………….,,30
4.3 JavaScript…………………………………………………………………………………..32
vii
Chapter 5: Implementation and Testing ........................................................................................... 55
Refrences………………………………………………………………………………………….65
viii
List Of Figures
CONTENT PAGE NO.
I ix
List of Tables
CONTENT PAGE NO.
x
Chapter 1: Introduction
1. Technology Stack: Real Chat leverages the power of the MERN stack, utilizing
MongoDB as the database, Express.js and Node.js for the backend logic and API
development, and React.js for the frontend user interface.
2. Features: The application offers a wide range of features including real-time messaging,
user authentication and authorization, multimedia support for sharing images, videos, and
files, group chat functionality, and a responsive UI.
4. Security: To prioritize user privacy and data security, Real Chat incorporates end-to-end
encryption for messages and robust authentication mechanisms to prevent unauthorized
access.
5. Scalability and Customization: The project's modular architecture and clean codebase
enable easy customization and extension, making it suitable for various deployment
environments and use cases. Developers can leverage Real Chat as a learning resource to
build their own real-time web applications using the MERN stack.
Overall, Real Chat aims to provide developers and businesses with a scalable, feature-
rich, and secure solution for building real-time chat applications tailored to their specific
requirements.
1
1.2 Objective
The primary objective of the Real Chat project is to develop a robust, scalable, and feature-rich
real-time chat application using the MERN (MongoDB, Express.js, React.js, Node.js) stack. The
project aims to achieve the following objectives:
2. Technology Mastery: Provide developers with an opportunity to master the MERN stack by
building a practical application, gaining hands-on experience in database management, backend
development, frontend design, and real-time communication protocols.
3. Security and Privacy: Implement robust security measures, including end-to-end encryption for
messages and secure user authentication, to ensure user privacy and data integrity.
4. Scalability and Performance: Design the application with scalability and performance in mind,
allowing it to handle a large number of users and messages efficiently, while maintaining low
latency and high responsiveness.
5. Customization and Extensibility: Build the project with a modular architecture and clean
codebase, enabling easy customization and extension for developers interested in adapting the
application to their specific requirements or integrating additional features.
Overall, the objective of the RealChat project is to deliver a comprehensive solution for real-time
communication, empowering developers to build innovative chat applications tailored to various
use cases and deployment scenarios.
2
1.3 Scope
As The scope of the Real Chat project encompasses the following key areas:
1. Functional Requirements:
• User Authentication: Implement user authentication mechanisms to allow users to register, login, and
manage their accounts securely.
• Real-time Messaging: Develop features for users to send and receive real-time messages, supporting
text, emojis, and multimedia content.
• Group Chats: Enable users to create, join, and manage group chat conversations for collaborative
communication.
• Multimedia Support: Implement functionality for users to share images, videos, files, and other
multimedia content within chat conversations.
• Search and Navigation: Incorporate search functionality and intuitive navigation to allow users to find
and access conversations efficiently.
• Notifications: Provide real-time notifications to users for new messages, mentions, or other relevant
updates.
• Profile Management: Allow users to customize their profiles, including profile pictures, status
messages, and notification preferences.
• Security Features: Implement end-to-end encryption for messages, secure user authentication
mechanisms, and measures to prevent unauthorized access or data breaches.
3
2. Non-Functional Requirements:
• Scalability: Design the application to handle a large number of concurrent users and messages, ensuring
scalability as user traffic increases.
• Performance: Optimize the application for performance, minimizing latency and maximizing
responsiveness to provide a smooth user experience.
• Reliability: Ensure high availability and reliability of the application through robust error handling, fault
tolerance, and backup mechanisms.
• Security: Implement industry-standard security practices to protect user data, prevent attacks such as
SQL injection or cross-site scripting, and comply with data protection regulations.
• User Experience (UX): Design an intuitive and user-friendly interface, with responsive layouts and
intuitive navigation, to enhance user satisfaction and engagement.
4
3. Development Methodology:
• Use version control systems, such as Git, for source code management and collaboration among team
members.
• Conduct regular testing, including unit tests, integration tests, and user acceptance testing, to ensure the
quality, reliability, and functionality of the application.
4. Future Enhancements:
• Consider future enhancements and features, such as voice and video calling, chatbots, integration with
third-party services, or support for additional platforms (mobile, desktop).
• Plan for ongoing maintenance, updates, and improvements to address user feedback, fix bugs, and
adapt to evolving technologies and user needs.
5
1.4 Project Modules
6
1.5 Project Requirements
1.5.1 Hardware
The system requires the following hardware:
1.5.2 Software
• Database Server: MongoDB server
• Web Server: Internet Information Server
• Technologies: HTML, CSS, JavaScript, Node.js, React.js, MongoDB.
7
Chapter 2: System Analysis
8
6. Scalability and Performance Optimization: Scalability and performance optimization
techniques are essential topics in literature related to web application development. Studies
discuss strategies for horizontal scaling, load balancing, caching, and database
optimization to ensure applications can handle increasing user loads and maintain
responsiveness under heavy traffic.
7. Multimedia Support and File Management: Research on multimedia support and file
management in web applications explores various techniques for handling multimedia
content, including file storage, compression, and delivery optimization. Studies also
discuss best practices for managing file uploads, ensuring security, and providing a
seamless user experience for sharing multimedia content.
9
2.2 Project Feasibility Study
The facility to produce outputs in each time. Our project is a web-based application which
is based on client-server-based application. In this application every page as output is
render from server to client so it is necessary that the page should be rendered in time. For
this I have avoided more and more code in the page- load event.
10
2.4 Project Timeline Chart
11
2.5 Detailed Module Description with all Functionalities
• User Registration: Allow users to create new accounts by providing necessary information
such as username, email, and password.
• User Login: Enable registered users to authenticate themselves securely by entering their
credentials.
• Access Control: Define user roles (e.g., regular user, administrator) and enforce access
control policies to restrict unauthorized access to certain features or resources.
• Message Sending: Allow users to compose and send text messages in real-time to individual
users or groups.
• Message Reception: Instantly deliver incoming messages to recipients and update message
threads in real-time.
• Message Editing and Deletion: Support editing and deleting messages, with real-time
synchronization to reflect changes across all clients.
• Typing Indicators: Display typing indicators to indicate when a user is typing a message in
a conversation.
• Read Receipts: Provide read receipts to indicate when a message has been read by the
recipient.
12
2.5.3 Group Chat Management Module:
• Group Creation: Allow users to create new group chats and define group settings such as
name, description, and privacy settings.
• Group Invitation: Enable users to invite other users to join existing group chats, with options
for accepting or declining invitations.
• Group Archives: Provide access to past messages and chat history within group
conversations for reference and review.
13
Chapter 3: System Design
14
3.2 Data Flow Diagrams
3.2.1 Context-Level (Level 0) DFD
15
3.2.2 Level 2 DFD
16
3.3 Class Diagram
17
3.4 Activity Diagram
3.4.1 Company
18
3.4.2 User
19
3.4.3 Admin
20
Features of Real Chat
21
Figure 3.11- Agents
22
23
24
25
26
Figure 3.12- Example of WhatsApp
27
Figure 3.13- Node.js Server-client
28
Chapter 4: Software Tools
A technology stack can be custom (developers can choose the technologies depending on
their project requirements) or pre-built (where the technologies have been pre-decided).
MERN is a pre-built technology stack based on JavaScript technologies. MERN stands
for MongoDB, Express, React, and Node, after the four key technologies that make up the
stack.
29
4.1 About HTML
World wide HTML stands for Hypertext Markup Language. It is the standard markup
language used to create web pages. HTML is a combination of Hypertext and Markup
language. Hypertext defines the link between web pages. A markup language is used to define
the text document within the tag to define the structure of web pages.
This language is used to annotate (make notes for the computer) text so that a machine can
understand it and manipulate text accordingly. Most markup languages (e.g. HTML) are
human-readable. The language uses tags to define what manipulation has to be done on the
text.
HTML is a very important language as it is widely used in creating websites. Most of the
websites are built using HTML5 (the latest version of HTML). HTML mainly contains tags
and attributes that determine the formatting and structure of a website.
30
4.1.1 Java Virtual Machine
When we compile the code, java compiler creates machine code (byte code) for a
hypothetical machine called java virtual machine (JVM). The JVM will execute the byte
code and overcomes the issue of portability. The code is written and compile for one
machine and interpreted all other machines. This machine is called java virtual machine.
4.2About Html
HTML (hypertext markup language) is a language used to create hypertext documents that
have hyperlinks embedded in them . it consists of tags embedded in the text of a document
with HTML. We can build web pages or web document s. it is basically a formatting
language and not a programming language. The browser reading the document interprets
markup tags to help format the document for subsequent display to a reader. HTML is a
language for describing structured documents. HTML isa platform independent. WWW
(world wide web) pages are written using HTML. HTML tags control in part the
representation of the WWW page when view with web browser.
31
Java Script
Java script is a general purpose prototype based, object oriented scripting language
developed jointly by sun and Netscape and is meant for the WWW . it is designed to be
embedded in diverse applications and systems, without consuming much memory . java
script borrows most of its syntax from java but also inherits from AWK and PERL, with
some indirect influence from self in its object prototype system.
Java scripts dynamically typed that is programs do not declare variable types, and the type
of variable is unrestricted and can change at runtime. source can be generated at run time
and evaluated against an arbitrary scope. Typical implementations compile by translating
source into a specified byte code format, to check syntax and source consistency. Note that
the availability to generate and interpret programs at runtime implies the presence of a
compiler at runtime.
Java script is a high-level scripting language that does not depend on or expose machine
representations or operating system services. It provides automatic storage management,
typically using a garbage collector.
Features:
• Java script is embedded into HTML documents and is executed with in them.
• Java script is browser dependent
• Java script is an interpreted language that can be interpreted by the browser at run time.
• Java script is loosely typed language
• Java script is an object based language.
• Java script is an Event-Driven language and supports event handlers
tospecify the functionality of a button.
Advantages
32
6.3 Introduction to Servlets:
Servlets provide a Java (TM)-based solution used to address the problems currently associated
with doing server-side programming, including inextensible scripting solutions, platform-
specific APIs, and incomplete interfaces. Servlets are objects that conform to a specific
interface that can be plugged into a Java-based server. Servlets are to the server-side what
applets are to the client-side -- object byte codes that can be dynamically loaded off the net.
They differ from applets in that they are faceless objects (without graphics or a GUI
component). They serve as platform-independent, dynamically-loadable, pluggable helper
byte code objects on the server side that can be used to dynamically extend server-side
functionality.
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web
servers. For example, a SERVLET might be responsible for taking data in an HTML order-
entry form and applying the business logic used to update a company's order database servlets
are to servers what applets are to browsers. Unlike applets, however, servlets have no graphical
user interface. Servlets can be embedded in many different servers because the servlet API,
which you use to write servlets, assumes nothing about the server's environment or protocol.
Servlets have become most widely used within HTTP servers; many web servers support the
Servlet API.
SERVLETS are an effective replacement for CGI scripts. They provide a way to generate
dynamic documents that is both easier to write and faster to run. Servlets also address the
problem of doing server-side programming with platform-specific APIs: they are developed
with the Java Servlet API, a standard Java extension.
So use SERVLETS to handle HTTP client requests. For example, have servlets process data
posted over HTTPS using an HTML form, including purchase order or credit card data. A
servlet like this could be part of an order-entry and processing system, working with product
and inventory databases, and perhaps an on-line paymentsystem.
33
Other Uses for Servlets
• Forwarding requests. Servlets can forward requests to other servers and servlets. Thus,
servlets can be used to balance load among several servers that mirror the same content,
and to partition a single logical service over several servers, according to task type or
organizational boundaries.
The javax.servlet package provides interfaces and classes for writing servlets. The
architecture of the package is described below.
The central abstraction in the Servlet API is the Servlet interface. All servlets
implement this interface, either directly or, more commonly, by extending a class that
implements it such as HTTPSERVLET.
The Servlet interface declares, but does not implement, methods that manage the servlet
and its communications with clients. Servlet writers provide some or all of these methods
when developing a servlet.
Client Interaction
• A SERVLETREQUEST, which encapsulates the communication from the client to the server.
• A SERVLETRESPONSE, which encapsulates the communication from the servlet
backto the client.
34
The Servlet Request Interface
• Information such as the names of the parameters passed in by the client, the protocol
(scheme) being used by the client, and the names of the remote host that made the
request and the server that received it.
• The input stream, SERVLETINPUTSTREAM. SERVLETS use the input stream to get data
from clients that use application protocols such as the HTTP POST and PUT methods.
• Interfaces that extend SERVLETREQUEST interface allow the servlet to retrieve more
protocol- specific data. For example, the HTTPSERVLETREQUEST interface contains
methods for accessing HTTP-specific header information.
The SERVLETRESPONSE interface gives the servlet methods for replying to the client.
• It Allows the servlet to set the content length and MIME type of the reply.
• Provides an output stream, SERVLETOUTPUTSTREAM, and a Writer through
which the servlet can send the reply data.
• Interfaces that extend the SERVLETRESPONSE interface give the servlet more protocol-
specific capabilities. For example, the HTTPSERVLETRESPONSE interface contains
methods that allow the servlet to manipulate HTTP-specific header information.
35
Additional Capabilities of HTTP Servlets
The classes and interfaces described above make up a basic Servlet. HTTP servlets have
some additional objects that provide session-tracking capabilities. The servlet writer can
use these APIs to maintain state between the servlet and the client that persists across
multiple connections during some time period. HTTP servlets also have objects that
provide cookies. The servlet writer uses the cookie API to save data with the client and to
retrieve this data.
The classes mentioned in the Architecture of the Servlet Package section are shownin the
example in bold:
• Simple SERVLET overrides the do Get method in the HTTPSERVLET class. The do Get
method is called when a client makes a GET request (the default HTTP request method),
and results in the simple HTML page being returned to theclient.
• Within the do Get method, The user's request is represented by an HTTPSERVLETREQUEST
object.
• The response to the user is represented by an HTTPSERVLETRESPONSE object.
• Because text data is returned to the client, the reply is sent using the Writer object obtained
from the
HTTPSERVLETRESPONSE object.
Servlets Lifecycle
36
Initializing a Servlet
When a server loads a servlet, the server runs the servlet's init method. Initialization
completes before client requests are handled and before the servlet is destroyed.
Even though most servlets are run in multi-threaded servers, servlets have no concurrency
issues during servlet initialization. The server calls the init method once, when the server
loads the servlet, and will not call the init method again unless theserver is reloading
the servlet.
The server can not reload a servlet until after the server has destroyed the SERVLET by
calling the
destroy method.
• The in its method provided by the HTTP servlet class initializes the servlet
andlogs the initialization. To do initialization specific to your servlet, override the in it
() method following these rules:
• If an initialization error occurs that renders the servlet incapable of handling clientrequests,
throw an Unavailable exception.
37
Initialization Parameters
• The second version of the init method calls the GETINITPARAMETER method. This method
takes the parameter name as an argument and returns a String representation of the
parameter's value.
• The specification of initialization parameters is server-specific. In the Java Web Server, the
parameters are specified with a servlet is added then configured in the Administration Tool.
For an explanation of the Administration screen where this setup is performed, see the
Administration Tool: Adding Servlets online help document. If, for some reason, you need
to get the parameter names, use the getparameternames method.
Destroying a Servlet
Servlets run until the server are destroys them, for example at the request of a system
administrator. When a server destroys a servlet, the server runs the servlet's destroy
method. The method is run once; the server will not run that servlet again untilafter the
server reloads and reinitializes the servlet.
When the destroy method runs, another thread might be running a service request. The
Handling Service Threads at Servlet Termination section shows you howto provide a clean
shutdown when there could be long-running threads still running servicerequests.
38
CSS
The Cascading Style Sheets is a simply designed language intended to simplify the
process of making web pages presentable. CSS allows you to apply styles to HTML
documents. It describes how a webpage should look. It prescribes colors, fonts, spacing,
etc. In short, you can make your website look however you want.
CSS lets developers and designers define how it behaves, including how elements are
positioned in the browser.
HTML uses tags and CSS uses rulesets. CSS styles are applied to the HTML element
using selectors. CSS is easy to learn and understand, but it provides powerful control
over the presentation of an HTML document.
39
Handling Service Threads at Servlet Termination
All of a SERVLET'S service methods should be complete when a servlet is removed. The
server tries to ensure this by calling the destroy method only after all service requests
have returned, or after a server-specific grace period, whichever comes first. If your servlet
has operations that take a long time to run (that is, operationsthat may run longer than the
server's grace period), the operations could still be running when destroy is called. You
must make sure that any threads still handling client requests complete; the remainder of
this section describes a technique for doing this.
If your servlet has potentially long-running service requests, use the following
techniques to:
• Keep track of how many threads are currently running the service method.
• Provide a clean shutdown by having the destroy method notify long-
runningthreads of the shutdown and wait for them to complete
• Have the long-running methods poll periodically to check for shutdown and, if
necessary, stop working, clean up and return.
To provide a clean shutdown, your destroy method should not destroy anyshared resources
until all the service requests have completed. One part of doing this isto check the service
counter. Another part is to notify the long-running methods that it is time to shut down. For
this, another field is required along with the usual access methods.
40
Servlet-client Interaction Handling HTTP Clients
An HTTP Servlet handles client requests through its service method. The service
method supports standard HTTP client requests by dispatching each request toa method
designed to handle that request. For example, the service method calls the do Get method
shown earlier in the simple example servlet.
Methods in the HTTPSERVLET class that handle client requests take two arguments:
An HTTPSERVLETREQUEST object provides access to HTTP header data, such as any cookies
found in the request and the HTTP method with which the request was made. The
HTTPSERVLETREQUEST object also allows you to obtain the arguments that the client sent as
part of the request.
41
About Node.js
The methods to which the service method delegates HTTP requests include,
42
Servlet Descriptions
In addition to handling HTTP client requests, some applications, such as theJava Web
Server's Administration Tool, get descriptive information from the servlet and display it.
The servlet description is a string that can describe the purpose of the servlet,its author, its
version number, or whatever the servlet author deems important.
The method that returns this information is GETSERVLETINFO, which returns nullby default.
You are not required to override this method, but applications are unable to supply a
description of your servlet unless you do.
Servlets are also easy to develop. This document discusses the following minimumsteps
needed to create any servlet:
43
About Session Tracking
Session T tracking is a flexible, lightweight mechanism that enables STATEFUL
programming on the web. Its general implementation serves as a basis for more
sophisticated state models, such as persistent user profiles or multi-user sessions.
A session is a series of requests from the same user that occur during a time period. This
transaction model for sessions has many benefits over the single-hit model.It can maintain
state and user identity across multiple page requests. It can alsoconstruct a complex
overview of user behavior that goes beyond reporting of user hits.
Session tracking gives servlets and other server-side applications the ability to keep state
information about a user as the user moves through the site. Server-side applications
can use this facility to create more STATEFUL user experiences and totrack who's doing
what on the site.
Java Web Server maintains user state by creating a Session object for each useron the site.
These Session objects are stored and maintained on the server. When a user first makes a
request to a site, the user is assigned a new Session object and a unique session ID.
Session Endurance
After the user has been idle for more than a certain period of time (30 minutes bydefault),
the user's session becomes invalid, and the corresponding Session object is destroyed.
A session is a set of requests originating from the same browser, going to the same server,
bounded by a period of time. Loosely speaking, a session corresponds toa single sitting of
a single anonymous user (anonymous because no explicit login or authentication is required
to participate in session tracking).
The first part of the DOGET method associates the Session object with the user making the
request. The second part of the method gets an integer data value from the Session object
and increments it. The third part outputs the page, including the current value of the counter.
44
When run, this servlet should output the value of the counter that increments every time you
reload the page. You must obtain the Session object before you actually write any data to
the SERVLET'S output stream. This guarantees that the session tracking headers are sent
with the response.
Session Invalidation
Sessions can be invalidated automatically or manually. Session objects that haveno page
requests for a period of time (30 minutes by default) are automatically invalidated by the
Session Tracker SESSIONINVALIDATIONTIME parameter. When a session is invalidated, the
Session object and its contained data values are removed from the system.
After invalidation, if the user attempts another request, the Session Trackerdetects that the
user's session was invalidated and creates a new Session object. However, data from the
user's previous session will be lost.
45
About React
The React is a powerful JavaScript library for building dynamic and interactive user
interfaces (UIs). It is developed by Facebook. React is known for its component-based
architecture which allows you to create reusable UI elements, making complex web
applications easier to manage and maintain. React is used to build single-page
applications.
React operates by creating an in-memory virtual DOM rather than directly manipulating
the browser’s DOM. It performs necessary manipulations within this virtual
representation before applying changes to the actual browser DOM. React is efficient,
altering only what requires modification.
One-way data binding, the name itself says that it is a one-direction flow. The data in
react flows only in one direction i.e. the data is transferred from top to bottom i.e. from
parent components to child components. The properties(props) in the child component
cannot return the data to its parent component but it can have communication with the
parent components to modify the states according to the provided inputs.
46
Multiple Servlets
URL conversions are required only if the servlet supports session tracking for browsers that
do not support cookies or browsers that reject cookies. The consequences of not doing these
conversions is that the user's session will be lost if the user's browser does not support
cookies and the user clicks on an un-rewritten URL. Note that this can have consequences
for other servlets. If one servlet does notfollow these conventions, then a user's session could
potentially be lost for all servlets.
Page compilation is a feature of the Java Web Server that allows HTML pages containing
Java code to be compiled and run as servlets. Page compilation also simplifies the task of
supporting session tracking. To that end, if URL rewriting is enabled, page compilation
automatically adds the encoder call to links in the HTML page.
47
Additional APIs
In addition to the Session object, there are a few more classes that may interest theservlet
developer.
Description Class
48
Session Swapping and Persistence
An Internet site must be prepared to support many valid sessions. A large site,for
example, might have hundreds, or even thousands, of simultaneously valid sessions.
Because each session can contain arbitrary data objects placed there by the
applicationservlets, the memory requirements for the entire system can grow prohibitively
large.
To alleviate some of these problems, the session tracking system places a limit on the
number of Session objects that can exist in memory. This limit is set in the
session.maxresidents property. When the number of simultaneous sessions
exceeds this number, the Session Tracker swaps the least recently-used sessions out to files
on disk. Those sessions are not lost: they will be reloaded into memory if further requests
come in for those sessions. This system allows for more sessions to remain valid than could
exist in memory
49
Session invalidation is not affected by session swapping. If a session goesunused for longer
than the normal invalidation time, the session is invalidated, whetherit is in memory or on
disk. Session invalidation is set in the session.invalidationinterval property.
Sessions are written to and read from disk using Java serialization. For this reason, only
serializable objects put into the Session object will be written to disk. Any objects put into
the Session object that are not serializable will remain in memory, evenif the rest of the
Session object has been written to disk. This does not affect session tracking, but does
reduce the memory savings that the Session Tracker gets from swapping a session to disk.
For this reason, the servlet developer should try to put only serializable objects into the
Session object. Serializable objects are those that implement either
java.io.Serializable or java.io.Externalizable.
Properties
You can customize properties in the Session Tracker. The properties are kept in the
server. properties
files
at:<server_root>/properties/server/javawebserver/server.properties where <server
root> is the directory into which you installed the Java Web Server product.
Note: These property settings are applied to all sessions, and cannot be tuned for individual
sessions.
50
Parameter Description Defa
ult
session. invalidation Time interval when Java 10000
interval
Web Server checks for (10 seconds)
sessions that have gone
unused long enough tobe
invalidated. Value is an
integer,specifying the
interval in milliseconds.
session. swapinterval Time interval when Java 10000
Web Server checks if too (10 seconds)
many sessionsare in
memory, causing the
overflow of sessions to be
swappedto disk. Value is an
integer, specifying the
interval in milliseconds.
session. Persistence Boolean value specifying true
51
time it starts.
session.swapdirectory Name of directory that the Java Web sessionSwap
52
enable.urlrewriting Boolean value indicating whether Java false
Web Server uses rewritten URLs as a
vehicle to carry the session ID. If true,
then session IDsarriving in the URL are
recognized,
and the Java Web Server rewrites
URLs if necessary to send the
session ID.
enable.protocolswitchrew Boolean value indicating whether the false
riting
session ID is added to URLs when the
URL dictates a switch from "http" to
"https" or vice-versa.
session.cookie.name Name of the cookie used to carry the jwssessionid
53
Introduction to MongoDB
Relational Database Management System (RDBMS) is not the correct choice when it
comes to handling big data by the virtue of their design since they are not
horizontally scalable. If the database runs on a single server, then it will reach a scaling
limit. NoSQL databases are more scalable and provide superior performance. MongoDB
is such a NoSQL database that scales by adding more and more servers and increases
productivity with its flexible document model.
54
Chapter 5: Implementation and Testing
Testing plays a critical role for quality assurance and for ensuring the reliability of the
software. Its basic function is to detect the errors. After the coding phase, testing is done to
test the proper working of the new system. Testing is the process of executing a program
with the intention of finding errors. It is a complete verification to determine whether the
objectives are met and the user requirements are satisfied. The testing phase involves testing
of a system using various test data.
Preparation of the test data plays a vital role in the system testing. After preparing the
test data, the system under study is testing using those test data. Errors were found and
corrected by using the following testing steps and corrections are recorded for future
references. Thus, a series of testing is performed on the system before it is ready for coding.
Since code is the only product that can be executed frequently whose actual behavior can
be observed, this phase is so important for the successful implementation of the software
product. Thus, the goal of testing is to uncover the requirements, design and coding errors
in the program.
Unit Testing
The first step in the testing is the unit testing. Unit test is normally considered as an adjunct
to the coding step. After the coding has been developed, received and verified for correct
syntax, unit testing begins. The standalone modules were tested individually for their correct
functionality, with the corresponding data. This ensures the reliability of the modules when
integrated. Each module is tested independently with sample data and it was found that all
modules are properly functioning. Using the unit test plans, prepared in the design phase of
the system as a guide, important control paths are tested to uncover errors within the
boundary of the modules. Boundary conditions were checked, all independent paths were
exercised to ensure that all statements in the module are checked at least once and all error
handling paths were tested. Each unit was thoroughly tested to check if it might fall in any
possible situation. This testing was carried out during the programming itself. At the end of
this testing phase, each unit was found to be working satisfactory, as regard to the expected
output from the module.
55
Integration Testing
The second step in the testing process is the Integration testing. Integration testing is the
systematic technique for constructing the program structure while conducting tests to
uncover errors associated with interfacing. All the modules when unit testing will work
properly but after interfacing the data can be lost across an interface, one module can have
an inadvertent, adverse effect on other, sub functions when combined may not produce the
desired major function, global data structures can cause problems, etc.
Integration testing was performed by integrating all the individual modules and the activities
of the user such as loading layers, retrieving information from any functions applying
themes based on the records present in the database etc. and is found that it works good to
the examination of the end users. Hence, the objective of integration testing is to take unit
tested modules and build a final program structure.
All the modules developed are independent. Even the whole process of approval for all.
Each module is integrated well with other modules. And all the interfaces are tested
successfully.
Functional Testing
This test involves testing the system under typical operating conditions with sample input
values. Functional testing was performed on the system by giving existing industryid or
plot number and a null or string as the input for any field in which case the user should
be redirected to the same state with the appropriate message, rather thanproceeding and
crashing in the system.
Functional testing was performed on the system by raising the demand with an eye to
check all the validations. The total processing of the system is satisfactory with the
following results.
• All the validations are clearly notified to the user regarding jobseekers reg, newclient reg,
job order, job providers, and job search preparation etc.
• Almost all the functional errors, data storage errors and all types of logical errorsare tested
successfully.
56
Implementation
Implementation includes all those activities that take place to convert the old system to the
new system. The new system will replace the existing system. The aspects of
implementation are as follows. Conversion, Post Implementation Review.
Conversion
Conversion means changing from one system to another. The objective is to put the tested
system into operation. It involves proper installation of the software package developed and
training the operating staff.
The software has been installed and found to be functioning properly. The users how to be
trained to handle the system effectively. Sample data provide to the operatingstuff and were
asked to operate on the system. The operating stuffs now have a clear out look of the
software and are ready for practical implementation of the package.
57
1.1 User Interface and snapshots
Home Page
58
Chat Interface
Search Users
59
Create Group Chat
60
Manage Group Settings
61
TEST CASES
Features to be tested
62
Chapter 6: Conclusion and Future Scope
The Real Chat project represents a comprehensive and feature-rich real-time chat
application developed using the MERN (MongoDB, Express.js, React.js, Node.js) stack.
Throughout the development process, the project has successfully achieved its objectives
of providing a seamless communication experience, mastering the MERN stack,
prioritizing security and privacy, ensuring scalability and performance, facilitating
customization and extension, serving as an educational resource, and delivering a valuable
solution for real-time communication needs.
By implementing modular components and detailed functionalities, Real Chat offers users
a wide range of features including user authentication, real-time messaging, group chat
management, multimedia support, search and navigation, notifications, profile
management, security features, scalability and performance optimization, documentation,
and user support. These functionalities cater to both personal and professional use cases,
enabling efficient communication, collaboration, and engagement across various domains.
Through the development of Real Chat, valuable insights and lessons have been gained in
building real-time web applications, leveraging the capabilities of the MERN stack,
implementing secure and scalable solutions, and meeting the needs of users in today's
interconnected world. The project has demonstrated the importance of real-time chat
applications in fostering communication, collaboration, and connectivity, while also
highlighting the significance of prioritizing user privacy, security, and user experience.
As the project concludes, Real Chat stands as a testament to the capabilities of modern
web technologies and the potential for innovation in real-time communication. Whether
used for personal connections, team collaboration, customer engagement, or community
building, Real Chat serves as a versatile and valuable tool for facilitating meaningful
interactions and fostering connections in an increasingly digital world.
63
Future Work
While the RealChat project has achieved its primary objectives and delivered a robust real-
time chat application, there are several avenues for future work and enhancements to
further improve the application's functionality, scalability, and user experience. Some
potential areas for future work include:
1. Voice and Video Calling: Integrate voice and video calling features to enable real-time
audio and video communication between users or within group chats, enhancing the
application's capabilities for remote collaboration and interaction.
2. Chatbot Integration: Implement chatbots to provide automated assistance, answer
frequently asked questions, perform tasks, and enhance user engagement through natural
language processing and machine learning algorithms.
3. Advanced Search and Filtering: Enhance the search and filtering functionalities to
support more advanced queries, including keyword-based search, filtering by message
attributes, and advanced search operators for more precise results.
4. Cross-Platform Support: Extend the application to support additional platforms such as
desktop applications, mobile apps (iOS and Android), or integration with messaging
platforms like Slack or Microsoft Teams, providing users with seamless access across
different devices and environments.
5. Analytics and Insights: Implement analytics and reporting features to provide users with
insights into chat usage, message trends, user engagement metrics, and other actionable
data to inform decision-making and improve user experience.
64
References
1. Full Stack React Projects" by Shama Hoque: This book provides practical
guidance and tutorials on building full-stack web applications using the
MERN stack, including real-time chat applications. It covers topics such as
user authentication, data management, and deployment strategies.
2. "Pro MERN Stack: Full Stack Web App Development with Mongo,
Express, React, and Node" by Vasan Subramanian: This comprehensive
guide covers the fundamentals of building full-stack web applications with
the MERN stack, including in-depth tutorials, best practices, and advanced
topics such as real-time communication and authentication.
3. "Node.js Design Patterns" by Mario Casciaro: This book explores design
patterns and best practices for building scalable and maintainable Node.js
applications, which can be beneficial for developing the backend logic of
the Real Chat application.
4. "React Design Patterns and Best Practices" by Carlos Santana Roldán:
This resource delves into design patterns and best practices specific to
React.js development, covering topics such as state management,
component composition, and performance optimization, which are essential
for building the frontend of the Real Chat application.
5. MDN Web Docs: The Mozilla Developer Network (MDN) provides
comprehensive documentation, tutorials, and guides on web development
technologies such as JavaScript, HTML, CSS, and web APIs. It serves as a
valuable reference for learning about frontend development and web
standards.
6. MongoDB Documentation: The official MongoDB documentation offers
extensive resources, tutorials, and examples for working with MongoDB,
including data modeling, query optimization, and deployment strategies. It
is a valuable reference for understanding database management in the Real
Chat project.
65