Skip to content

AzmeerX/ChatApp-BackEnd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scalable ChatApp


A real-time, scalable chat application built with Node.js, Socket.IO, Redis, and MongoDB. Designed for low-latency messaging and real-time user presence tracking.

Live Demo: https://scalable-chat-app-three.vercel.app


Tech Stack


  • Backend: Node.js, Express
  • Real-time Communication: Socket.IO
  • Database: MongoDB (Mongoose)
  • Cache: Redis (online/offline presence)
  • Frontend: React
  • Deployment: Vercel (frontend), Render (backend)
  • DevOps: Dockerized
  • Security: End-to-End Encrypted

Key Features

  • Real-time messaging between users
  • JWT-based authentication and protected REST APIs for secure user communication
  • End-to-End Encryption using a hybrid cryptographic model to secure message content
  • API rate limiting to protect backend services from abuse
  • Online/offline presence tracking using Redis
  • Instantaneous Typing Indicators
  • Timestamp for each msg
  • Persistent message storage in MongoDB
  • Scalable architecture ready for multiple Socket.IO instances

Architecture Overview

Architecture Diagram

  • Redis for Presence: Fast, in-memory storage for ephemeral user status. Reduces database writes and latency.
  • Socket.IO: Simplifies event handling, automatic reconnections, and room management.
  • MongoDB: Reliable storage for messages while separating ephemeral presence state.

WorkFlow

  1. User connects → Socket.IO handshake
  2. Redis updates online presence
  3. Messages are broadcast via Socket.IO and stored in MongoDB
  4. Redis broadcasts presence updates to all connected clients
  5. Disconnections handled; presence rebuilds on reconnect

Design Decisions & Trade-offs

  • Redis for Presence: Chosen for speed and efficiency. Avoids hitting the main database for temporary state.
  • Socket.IO over WebSockets: Easier to manage rooms, events, and reconnections.
  • MongoDB for Persistence: Ensures message history is stored reliably, separating ephemeral vs permanent data.

About

Creating a full stack scalable chatapp with alot of features

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors