How akashkanabur/real-time-chat-app works
This is a distributed Spring Boot real-time chat application. A browser connects through SockJS/STOMP, sends chat or join messages to the application, and receives public-topic broadcasts. Each application instance publishes messages to DragonflyDB Pub/Sub; subscribers broadcast them to their connected WebSocket clients, enabling cross-instance delivery. Disconnects publish leave events. The graph includes documented Kubernetes scaling and the browser UI; unsampled deployment details are represented only at the documented level.
Main entry points: ChatController.java Chat controller · RedisMessageSubscriber.java Message subscriber · WebSocketEventListener.java Connection events · index.html Chat interface
Components 12
Chat client
- Chat interface
src/main/resources/static/index.html
WebSocket messaging
- STOMP endpoint
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/config/WebsocketConfig.java - Chat controller
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/controller/ChatController.java
Chat events
- Connection events
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/listener/WebSocketEventListener.java - Chat payload
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/model/ChatMessage.java - Event types
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/model/MessageType.java
Cross-instance distribution
- Pub/Sub configuration
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/config/RedisConfig.java - Message subscriber
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/listener/RedisMessageSubscriber.java - DragonflyDB
Distributed deployment
- Kubernetes service
k8s/chat-app.yaml - Spring Boot replicas
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/SpringBootWebsocketChatAppApplication.java
Other components
- Browser user
Connections 17
- Browser user → Chat interface: uses
README.md - Chat interface → STOMP endpoint: connects
README.md - STOMP endpoint → Chat controller: routes messages
README.md - Chat controller → Chat payload: handles payload
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/controller/ChatController.java - Chat controller → Event types: sets event type
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/controller/ChatController.java - Chat controller → DragonflyDB: publishes messages
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/controller/ChatController.java - Connection events → Chat payload: creates leave event
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/listener/WebSocketEventListener.java - Connection events → Event types: sets leave type
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/listener/WebSocketEventListener.java - Connection events → DragonflyDB: publishes leave event
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/listener/WebSocketEventListener.java - Pub/Sub configuration → Message subscriber: registers listener
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/config/RedisConfig.java - Pub/Sub configuration → DragonflyDB: configures connection
README.md - DragonflyDB → Message subscriber: delivers messages
- Message subscriber → Chat payload: deserializes payload
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/listener/RedisMessageSubscriber.java - Message subscriber → Chat interface: broadcasts topic
src/main/java/com/programming/techie/spring_boot_websocket_chat_app/listener/RedisMessageSubscriber.java - Kubernetes service → Spring Boot replicas: scales replicas
README.md - Spring Boot replicas → DragonflyDB: shares Pub/Sub
README.md - Kubernetes service → Browser user: routes connections
README.md