Back to all projects

Real-Time Chat Application

JavaSpring BootWebSocketThymeleafSockJS
Real-Time Chat Application

Timeline

May 2025

My Role

Backend Developer - Java

Type

Real-Time Application

Project Overview

The Real-Time Chat Application is a lightweight and simple messaging platform that uses WebSocket for real-time communication. Developed with Spring Boot and WebSocket technology, the application allows users to send and receive messages in real time without relying on a persistent database. This app was designed for learning and demonstration purposes, showcasing the ease of integrating WebSocket into Spring Boot applications.

Key Features

  • Real-Time Messaging: Utilizes WebSocket and the STOMP protocol for bidirectional communication.
  • Session-Based Message Persistence: Messages are only persisted for the duration of the user's session.
  • Simple User Interface: Built with Thymeleaf and Bootstrap 5, providing a smooth user experience.
  • No Database: Messages are kept in memory, offering fast message delivery without a backend database.

Technical Approach

The application uses Spring Boot and WebSocket with SockJS to provide real-time message broadcasting. The message flow is managed using the STOMP protocol, with SockJS acting as the WebSocket client to ensure compatibility across different browsers. All message broadcasts are handled via a simple in-memory message broker, and Cross-Origin Resource Sharing (CORS) is configured to allow requests only from http://localhost:8080.

Core Components

  • WebSocket Configuration: Configured WebSocket connection, enabling SockJS and STOMP communication.
  • Controller: Handled HTTP requests and WebSocket message endpoints.
  • Message Model: Defined the structure of messages sent and received.

Development Process

The development followed an agile process with a focus on simplicity and performance. The core logic was developed iteratively, with frequent testing of WebSocket communication to ensure real-time message updates. Collaboration with frontend developers was key to maintaining synchronization between the backend and user interface.

Technology Stack

  • Java 21
  • Spring Boot 3.4.6
  • Spring WebSocket
  • Thymeleaf (for templating)
  • SockJS & STOMP.js (for WebSocket client)
  • Bootstrap 5 (for UI styling)

Challenges

Ensuring smooth real-time communication with WebSocket, managing message delivery without persistence, and maintaining low latency in a lightweight, session-based system.

Solutions

Used Spring Boot and WebSocket with SockJS and STOMP for real-time communication, with a simple in-memory message broker.