Training File Shivam 1222370
Training File Shivam 1222370
Training Report
On
MERN STACK
Submitted for partial fulfillment of the award of degree of Bachelor of Technology
(B.Tech)
in
Computer Science & Engineering
Submitted By:
SHIVAM 1222370
Submitted to:
1222370
SHIVAM
1
2
CANDIDATE’S DECLARATION
I hereby certify that the work which is being presented in the Summer
Internship/Training entitled “Chat Application” in partial fulfilment for the
award of the Degree of Bachelor of Technology in Computer Science and
Engineering / Information Technology affiliated to Kurukshetra university ,
Kurukshetra (Hrayana) and submitted to the Department of Computer
Science and Engineering Seth Jai Parkash Mukand Lal Institute of Engineering
& Technology, Radaur, is an authentic record of my own work. The matter
represented in this report has not been submitted by me for award of any other
degree of this or any other institute/university.
This is to certify that the above statement made by the candidate is correct to the
best of our knowledge.
Signature of Supervisor
Date - (name of teacher
3
Preface
The end objectives of the training are to obtain an In-depth knowledge to:
• Learn the fundamentals and significance of the MERN stack for full-stack web
development.
• Build dynamic, responsive user interfaces using React with components, props, and
state.
• Implement advanced React features like hooks, context, and state management with
Redux.
• Create and manage RESTful APIs with Express.js and Node.js for backend development.
• Master asynchronous programming in Node.js using Promises and async/await.
• Design, query, and manage NoSQL databases with MongoDB and Mongoose.
• Perform CRUD operations and handle database relationships effectively.
• Integrate the front-end and back-end, ensuring seamless data flow via RESTful APIs.
• Implement user authentication and authorization using JWT and session management.
• Optimize React applications with lazy loading, code splitting, and performance tuning. •
Debug and handle errors across the full stack using tools like Chrome DevTools and
Postman.
• Deploy MERN stack applications on platforms like Heroku, Vercel, or AWS.
• Learn Git and GitHub for version control, branching, and team collaboration.
• Build a feature-rich, real-world MERN stack project as a capstone assignment.
• Learn how to implement server-side rendering (SSR) and static site generation (SSG)
using Next.js.
• Master the use of middleware in Express.js to handle requests, responses, and custom
logic.
• Understand how to secure web applications by preventing common vulnerabilities like XSS and
CSRF.
• Explore real-time communication using WebSockets and libraries like Socket.IO.
• Gain proficiency in testing MERN stack applications using tools like Jest, Mocha, and
Postman. • Follow best practices for organizing and structuring MERN stack
projects for scalability.
4
Company Profile
Webotech Solutions Private Limited is a Private company incorporated on 16 June 2020. It is
classified as Non-government company and is registered at Registrar of Companies, Delhi. Its
authorized share capital is Rs. 100,000 and its paid up capital is Rs. 100,000. It's NIC code is 725
(which is part of its CIN). As per the NIC code, it is inolved in Maintenance and repair of office,
accounting and computing machinery.
Core Services
• Web Development: Creating dynamic and responsive websites.
• Mobile App Development: Building user-friendly mobile apps across Android and
iOS.
Global Presence
Webotech Solutions' Corporate Identification Number (CIN) is U72501HR2020PTC086815
and its registration number is 86815. Users may contact Webotech Solutions on its Email
address - [email protected]. Registered address of Webotech Solutions is
SCO. A-58, GROUND FLOOR SCHOOL CUM CANAL AREA, NILOKHERI , KARNAL,
Haryana, India - 132117.
5
Training Schedule
w.e.f. July 8, 2024
Time Duration Contents
Introduction to MERN Stack and Web Development Basics:
Introductory The first week introduces the MERN stack (MongoDB, Express,
Week React, Node.js) and covers web development basics like HTML,
(08-07-2024 to CSS, and JavaScript. Participants are introduced to React,
14-07-2024) learning about components, JSX, props, and state management.
React Basics and Component Design:
WEEK-1
Participants dive deeper into React, exploring hooks (useState,
useEffect) and state management. They learn to design dynamic
(14-07-2024
user interfaces, work with forms, and navigate between pages
to 20-07-
2024) using React Router.
6
List of Figures
Figure Title of the figure
Figure 3.1 Components of a full stack development
Figure 3.2 A Full Stack Development Workflow
Figure 4.1 Illustration of MERN stack logo
Figure 4.2 Example of how to use Component
Figure 4.3 Example of how to use hook
Figure 4.4 Architectural representation of MERN stack
Figure 6.1 Screenshot of MongoDB Compass
Figure 6.2 Folder and file structure of the application
Figure 9.1 Login Page
Figure 9.2 Register Page
Figure 9.3 Home Page
Figure 9.4 Create Post Page
Figure 9.5 Home Screen
Figure 9.6 Your Profile Page
7
TABLE OF CONTENTS
1) Title Page 1
2) Candidate Declaration 2
3) List of Figures 5
4) Acknowledgement 6
5) Abstract 7
Chapter 4. RESULTS 19 - 21
4.1) Screenshots 19
4.1.1) Setting up the Connection 19
4.1.2) Entering Interface 20
4.1.3) Chatting Demo 21
8
Chapter 5. CONCLUSION 22
Chapter 6. REFERENCES 23
9
LIST OF FIGURES
10
List of Abbreviations
Abbreviation Full Form
MERN Technology stack: MongoDB, NodeJS, Express JS, and React JS
DBMS Database Management System
API Application Programming Interface
UI User Interface
SPA Single Page Application
HTML Hyper Text Markup Language
CSS Cascading Style Sheets
HTTP Hypertext Transfer Protocol
JSON JavaScript Object Notation
JSX JavaScript XML
NPM Node Package Manager
11
ACKNOWLEDGEMENT
I would like to express our gratitude towards our mentor (name of teacher) for
exposing me to this topic and moreover for being the guiding light all this while.
Furthermore I would like to thank other teachers for their valuable suggestions
and to our principal for presenting me with this golden opportunity of making this
project. Finally, I would like to thank my friends and family for being the constant
support system and encouraging force all this while.
12
CHAPTER-1
INTRODUCTION
Today Developers around the world are making efforts to enhance user experience of using
application as well as to enhance the developer’s workflow of designing applications to deliver
projects and rollout change requests under strict timeline. Stacks can be used to build web
applications in the shortest span of time. The stacks used in web development are basically the
response of software engineers to current demands. They have essentially adopted pre-existing
frameworks (including JavaScript) to make their lives easier.
While there are many, MEAN and MERN are just two of the popular stacks that have evolved
out of JavaScript. Both stacks are made up of open source components and offer an end-to-end
framework for building comprehensive web apps that enable browsers to connect with
databases. The common theme between the two is JavaScript and this is also the key benefit of
using either stack. One can basically avoid any syntax errors or any confusion by just coding
in one programming language, JavaScript. Another advantage of building web projects with
MERN is the fact that one can benefit from its enhanced flexibility.
In order to understand MERN stack, we need to understand the four components that make up
the MERN stack(fig.1), namely – MongoDB, Express.js, React and Node.js.
13
1.1) Problem Statement
This project is to create a chat application with a server and users to enable the users to
chat with each other’s.
To develop an instant messaging solution to enable users to seamlessly communicate
with each other.
The project should be very easy to use enabling even a novice person to use it.
This project can play an important role in organizational field where employees can
connect through LAN.
1.2 ) Objectives
GUI: Easy to use GUI (Graphical User Interface), hence any user with minimal
knowledge of operating a system can use the software.
Platform independence: The messenger operates on any system irrelevant of the
underlying operating system.
Unlimited clients: “N” number of users can be connected without any performance
degradation of the server.
14
CHAPTER-2
TECHNOLOGIES USED
Express is a minimal and flexible Node.js web application framework that provides a
robust set of features for web and mobile applications. It is an open source framework
developed and maintained by the Node.js foundation.
Express provides us the tools that are required to build our app, be it single-page, multi-
page or hybrid web applications. It is flexible as there are numerous modules available
on npm(Node Package Manager), which can be directly plugged into Express.
15
Unlike its competitors like Rails and Django, which have an opinionated way of
building applications, Express has no "best way" to do something. It is very flexible
and pluggable.
Pug (earlier known as Jade) is a terse language for writing HTML templates. It produces
HTML, supports dynamic code and code reusability (DRY). It is one of the most
popular template languages used with Express.
Express can be thought of as a layer built on the top of the Node.js that helps manage a
server and routes. It allows users to setup middleware to respond to HTTP Requests
and defines a routing table which is used to perform different actions based on HTTP
method and URL.
Express allows to dynamically render HTML Pages based on passing arguments to
templates.
Express is asynchronous and single threaded and performs I/O operations quickly.
ReactJS is a declarative, efficient, and flexible JavaScript library for building reusable
UI components. It is an open-source, component-based front-end library which is
responsible only for the view layer of the application. It was initially developed and
maintained by Facebook and later used in its products like WhatsApp & Instagram.
A ReactJS application is made up of multiple components, each component responsible
for outputting a small, reusable piece of HTML code. The components are the heart of
all React applications. These Components can be nested with other components to allow
complex applications to be built of simple building blocks. ReactJS uses virtual DOM
based mechanism to fill data in HTML DOM. The virtual DOM works fast as it only
changes individual DOM elements instead of reloading complete DOM every time.
Instead of using regular JavaScript, React codes are written in something called JSX
(JavaScript Syntax Extension). JSX is basically a syntax extension of regular JavaScript
and is used to create React elements. These elements are then rendered to the React
DOM. JSX is faster than normal JavaScript as it performs optimizations while
translating to regular JavaScript.
16
2.3.1) Why use React? [4]
Uses virtual DOM which is a JavaScript object. This will improve apps performance,
since JavaScript virtual DOM is faster than the regular DOM.
Can be used on client and server side as well as with other frameworks.
Component and data patterns improve readability, which helps to maintain larger apps.
17
CHAPTER-3
This is a very basic web based chat application and it is in its primary state. I have
provided with a very easy to use GUI Interface.
18
CODE : -
3.2) Implementation
Chat App or client part, which is a Web chat application. Build on React
Chat Server Engine or server part, which is a pool of external servers responsible for
the chat operation. This is the place where all the chat magic happens.
Both parts contain various components that communicate to each other and bring the
chat into action
19
3.2.1) Chat App or Client Side
Chat App is the other major part of the chat architecture, the one that users directly interact
with. It's split into two separate root components:
Chat Client Engine handles all the communication with the Chat Server Engine via its
internal components: Chat REST API Client Library and Chat WebSocket Client
Library.
Chat UI displays data to users: Chat Contact List UI, Chat Dialog UI
Component:
A package.json file :
20
specifies versions of a package that your project can use.
makes your build reproducible, and therefore easier to share with other
developers.
CODE :-
This is a core of the chat architecture that handles message delivery and dispatch. In our version
of chat architecture, it includes the following components:
Chat REST API handles the tasks that are not connected directly to message dispatch
and delivery, such as user authentication, changing of user settings, friends invitation,
downloading sticker packs, etc. The Chat App (the chat client part) communicates with
the Chat REST API via the Chat REST API Client Library.
Chat WebSocket Server is responsible for transmitting messages between users. The
Chat App communicates with the Chat WebSocket Server via the Chat WebSocket
Client Library. This connection is open two ways; that means users don’t have to make
requests to the server if there are any messages for them, they just get them right away.
21
CODE :-
22
CODE :-
23
CHAPTER-4
RESULTS
4.1) Screenshots
Below are the screenshots of our web based chat application that demonstrate its functioning
:-
This images displays how the connection is build and Port 3000 is active.
24
4.1.2) Entering Interface
This image display that when to visit the localhost at Port 3000, you have to give input your
name.
Figure 9 : localhost
25
4.1.3) Chatting Demo
Here is a depiction how your send and received messages will appear on the
respective screens.
26
CHAPTER-5
CONCLUSION
There is always a room for improvements in any apps and this being in its primary phase needs
a loads of it. But I will keep working on it and improving it with technological advancements
in coming times. Right now, we are just dealing with text communication. There are several
chat apps which serve similar purpose as this project, but these apps were rather difficult to use
and provide confusing interfaces. I have built this application keeping in mind that even the
very beginner with technology can operate this application with ease. A positive first
impression is essential in human relationship as well as in human computer interaction. This
project hopes to develop a chat service Web app with high quality user interface. In future we
may be extended to include features such as file transfer, video message, voice message, audio
and video calls etc.
27
CHAPTER-6
REFERENCES
1. https://www.guru99.com/what-is-mongodb.html
2. https://www.javatpoint.com/expressjs-tutorial
3. https://www.javatpoint.com/reactjs-tutorial
4. https://www.tutorialspoint.com/reactjs/reactjs_overview.htm
5. https://www.javatpoint.com/nodejs-tutorial
6. https://www.cometchat.com/tutorials/how-to-build-a-chat-app-
with-websockets-and-node-js
28