Skip to content

Thapamanish/real-time-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💬 Real-Time Chat Application (Spring Boot + WebSockets)

A feature-rich real-time chat application leveraging Spring Boot, WebSocket, and HTTP protocols for seamless communication. Includes public/private messaging, chat rooms, file uploads, and user presence indicators.

Java 17+ Spring Boot WebSockets MIT License

1. ✨ Key Features

  • Real-Time Messaging → public chat, private chat, and room-based messaging

  • User Authentication & Sessions → secure login/logout with session management

  • Private Rooms → create, join, leave rooms; private queues for one-to-one messaging

  • File Upload Support → share images/files with uploads stored in a dedicated directory

  • Dynamic Avatars → auto-generated avatar URLs based on usernames

  • Docker Deployment → containerized for reproducible deployments

2. 📡 API Endpoints

2.1. WebSocket Endpoints

Endpoint Functionality

/chat.sendMessage

Broadcast public message, update user status, attach avatar

/chat.addUser

Add a user to session and notify public chat

/chat.sendPrivateMessage

Send private message between two users via dedicated queues

/chat.createPrivateRoom

Create private room and assign users

/chat.joinRoom

Join a user to a room and notify members

/chat.leaveRoom

Remove a user from a room and notify remaining members

/chat.sendRoomMessage

Broadcast message to all users in a private room

2.2. HTTP Endpoints

Endpoint Method Functionality

/

GET

Render chat page if authenticated; else redirect to login

/login

GET

Display login page

/login

POST

Authenticate user and create session

/logout

GET

Invalidate session and redirect to login

/upload

POST

Handle file uploads (e.g., images) and return file URL

3. 🔧 Tech Stack

  • Java 17+

  • Spring Boot (WebSockets, REST)

  • HTML, JavaScript, CSS

  • Docker for containerized deployment

4. 🚀 Quick Start

4.1. Prerequisites

  • Java 17+

  • Maven 3.9+

4.2. Build

mvn clean package

4.3. Run

java -jar target/real-time-chat.jar --server.port=8081

5. 🐳 Docker

5.1. Build

docker build -t real-time-chat:latest .

5.2. Run

docker run -d -p 8081:8081 real-time-chat:latest

6. 📐 Architecture

  • Frontend: HTML/JS + WebSockets client

  • Backend: Spring Boot WebSocket/REST controllers

  • Storage: Session-based authentication + local file uploads

  • Deployment: Packaged in Docker for portability

Browser ↔ Spring Boot Server (WebSocket + REST) ↔ Session/File Store

7. 🧭 Roadmap

  • ❏ Add persistent DB for messages

  • ❏ Enable typing indicators

  • ❏ Integrate Redis pub/sub for scaling across servers

  • ❏ Enhance UI with React frontend

8. 🤝 Contributing

PRs welcome!

  1. Fork repository

  2. Create feature branch

  3. Commit changes

  4. Open a Pull Request

9. 📜 License

Licensed under the MIT License.

About

Feature-rich real-time chat app using Spring Boot and WebSockets with support for public/private messaging, rooms, file uploads, and Docker deployment.

Topics

Resources

Stars

Watchers

Forks

Contributors