Skip to content

A real-time chat application built using Java Spring Boot and React, featuring WebSocket-based communication, JWT authentication, and support for multiple chat rooms. Designed for scalable and secure user interactions in real-time.

License

Notifications You must be signed in to change notification settings

abhinavkumar03/chat-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Logo

Real-Time Scalable Chat Engine


🌐 The Project Vision

This isn't just a chat app; it's a full-stack event-driven system. It demonstrates the bridge between stateless RESTful services and stateful real-time communication. By utilizing STOMP over WebSockets, the application provides a seamless, low-latency experience for global users.


🛠️ Technical Power Grid

Tech Role in the System Key Engineering Focus
Spring Boot Core Orchestrator Handled via STOMP protocols for structured messaging and sub-millisecond response times.
React 18 UI Layer Optimized with Functional Components & Hooks to ensure zero-lag rendering during high message frequency.
MongoDB Persistence Selected for its schema-less flexibility, allowing chat histories to scale and store varied metadata (files, reactions).
Docker Infrastructure Containerized for "Build Once, Run Anywhere" consistency across dev, staging, and production.

📈 Engineering for Scale

A common bottleneck in chat apps is handling millions of concurrent connections. Here is how this architecture is designed to grow:

1. The Message Broker (Current vs. Future)

Currently, the system uses an In-Memory Broker. To scale for 1M+ users:

  • The Plan: Integrate Redis Pub/Sub or RabbitMQ.
  • The Goal: This allows us to run multiple backend instances behind a Load Balancer; if User A is on Server 1 and User B is on Server 2, the message broker ensures they can still talk.

2. Database Optimization

  • Sharding: As the chat history grows, MongoDB's sharding capabilities will be utilized to distribute data based on room_id, preventing any single database instance from becoming a bottleneck.

3. Load Balancing

  • NGINX / AWS ALB: Implementing "Sticky Sessions" or "Session Affinity" to ensure WebSocket connections stay pinned to the correct server during a session.

🧠 Solved Challenges

  • The Connection Lifecycle: Managing "Ghost Connections" (users who disconnect without closing the socket) to save server resources.
  • Message Delivery Guarantees: Implementing a structured JSON payload that includes timestamps and unique IDs to ensure messages appear in the correct order on all clients.
  • CORS & Security: Configuring Spring Security to allow cross-origin communication from the React frontend while protecting the WebSocket handshake.

🚀 Deployment & Operations

Quick Start (Production-Ready)

# Bring up the entire stack with one command
docker-compose up -d

🛣️ Roadmap: To the Cloud [ ] Auth: JWT-based stateless authentication.

[ ] Broker: Externalizing the message broker (RabbitMQ/Kafka) for horizontal scaling.

[ ] Cloud: Migrating from Render to AWS ECS (Fargate) for auto-scaling capabilities.


🤝 Let's Connect

I'm an engineer fascinated by distributed systems and real-time data flow. I'm always open to discussing system design, backend optimizations, or potential collaborations.

LinkedIn Portfolio Email


"Scalability is not an afterthought; it's a design requirement."

About

A real-time chat application built using Java Spring Boot and React, featuring WebSocket-based communication, JWT authentication, and support for multiple chat rooms. Designed for scalable and secure user interactions in real-time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages