Realtime messaging
Realtime Chat App
A persistent messaging application built around WebSocket communication.

The problem
A chat interface needs messages to arrive without repeated polling while keeping conversation history available between sessions.
The approach
The application uses a persistent WebSocket connection for live communication, a Spring Boot service for message handling, and MongoDB for stored conversation data.
System flow
System flow: Next.js client to WebSocket connection to Spring Boot service to MongoDB.
Engineering decisions
Use WebSockets for the active session
A persistent connection supports bidirectional message delivery without a client polling loop.
Persist conversation data separately
MongoDB keeps message history available independently of the lifetime of a WebSocket connection.
Keep transport concerns in the backend
The client renders conversations while the Spring Boot service manages connection and message behavior.
Challenges and tradeoffs
- Coordinating connection state with the messages shown in the interface.
- Keeping transient delivery behavior separate from persisted conversation history.