Code Like A Girl

Welcome to Code Like A Girl, a space that celebrates redefining society's perceptions of women in technology. Share your story with us!

Follow publication

Member-only story

Build Your Own Chat Application Using MERN Stack

Shanmuga priya
Code Like A Girl
Published in
11 min readMar 28, 2025

--

Photo by Adem AY on Unsplash

Chat is the foremost and easiest way of communicating in any application. Chat applications are increasing day by day which shows how important and reliable the chat communications are. There is so much internal works are happening in just a “Hi” message. Learning how to build chat application is not only a great advantage but also fun at the same time. In this article, I’ll teach you how you can build your own mini chat application.

What You Will Learn?

  • Basic Workflow of how chat application works.
  • Building UI.
  • Setting up the backend.
  • Setting up the frontend.
  • Storing the chats in MongoDB (covered in a separate article).

Before moving further, first let’s have a quick overview of what Socket is. It is nothing but the connection that is established between client to the server and also server to the client (Bi-directional). Here, Everything is based on the events. So, we emit and handle those events inorder to build our chat app.

Basic Workflow of Chat Application

In a real-world chat application, we usually go through these steps:

  1. User Authentication: Users sign up or log in before accessing chat features.
  2. Chat Room Creation: A chat room is created dynamically for a user pair or a group based on userId’s.
  3. Message Storage: Messages are saved in a database and retrieved when needed.
  4. Security Measures: Authentication tokens, encrypted WebSocket connections, and access control are enabled for better security.

How We Are Simplifying It Here

For learning purposes, we simplify the process by:

  • Skipping authentication: Users directly enter a room name and username to join the chat.
  • Manual room creation: Users enter a room name instead of creating dynamic rooms.
  • Not persisting messages: Messages are temporarily stored…

--

--

Published in Code Like A Girl

Welcome to Code Like A Girl, a space that celebrates redefining society's perceptions of women in technology. Share your story with us!

Written by Shanmuga priya

👨‍💻 Tech enthusiast sharing what I learn in web development, backend tech, and coding. Join me on this journey to grow, build, and inspire! 🚀

Write a response