Skip to content

bhola-dev58/JLiveChats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ JLiveChats β€” Real-Time Chat Application

A modern, production-ready real-time web chat application built with Spring Boot 3.3.0, WebSockets (STOMP), and Google OAuth2 β€” featuring instant multi-user messaging, secure authentication, and a responsive chat UI.

Java Spring Boot WebSocket OAuth2 License


✨ Features

πŸ” Authentication

  • Custom Login & Registration β€” with BCrypt password hashing via Spring Security
  • Google OAuth2 Sign-In β€” one-click sign-in with your Google account
  • Session Management β€” secure HTTP session tracking after login
  • Duplicate User Prevention β€” username/email uniqueness enforced at the database level

πŸ’¬ Real-Time Messaging

  • WebSocket + STOMP β€” instant bidirectional message delivery
  • SockJS Fallback β€” works even in environments where WebSocket is blocked
  • Multi-Channel Support β€” #general, #random, #announcements, #help
  • Message Persistence β€” chat history stored in the H2 database (last 50 messages)
  • Typing Indicators β€” see when someone else is typing in real-time

πŸ‘₯ User Presence

  • Online/Offline Status β€” live tracking of who is connected
  • Active User List β€” shown in the sidebar in real-time
  • User Join/Leave Notifications β€” broadcast events on connect/disconnect

🎨 UI / UX

  • Responsive Design β€” works on desktop and mobile browsers
  • Gradient Dark Theme β€” modern blue-purple sidebar + clean chat area
  • Message Bubbles β€” clear visual separation for sent vs. received messages
  • Smooth Animations β€” fade-in transitions and micro-interactions
  • Emoji Reactions β€” react to messages with emojis

πŸ›  Tech Stack

Layer Technology
Backend Framework Spring Boot 3.3.0
Language Java 21
Real-Time WebSocket + STOMP + SockJS
Security Spring Security + Google OAuth2
Database H2 In-Memory (JPA / Hibernate)
Templating Thymeleaf
Frontend HTML5 + CSS3 + Vanilla JavaScript
Build Tool Maven 3.8+
Server Embedded Apache Tomcat 10

πŸ“ Project Structure

JLiveChats/
β”œβ”€β”€ src/main/java/com/jlivechats/
β”‚   β”œβ”€β”€ JLiveChatsApplication.java          # Spring Boot entry point
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ SecurityConfig.java             # Spring Security + OAuth2 config
β”‚   β”‚   β”œβ”€β”€ WebSocketConfig.java            # STOMP / SockJS WebSocket config
β”‚   β”‚   └── SessionAuthenticationFilter.java # Session β†’ Security bridge
β”‚   β”œβ”€β”€ controller/
β”‚   β”‚   β”œβ”€β”€ WebController.java              # Login, Register, Chat page routes
β”‚   β”‚   └── WebSocketController.java        # STOMP message handlers
β”‚   β”œβ”€β”€ model/
β”‚   β”‚   β”œβ”€β”€ User.java                       # User JPA entity
β”‚   β”‚   └── ChatMessage.java                # Message JPA entity
β”‚   β”œβ”€β”€ repository/
β”‚   β”‚   β”œβ”€β”€ UserRepository.java             # JPA Repository for users
β”‚   β”‚   └── ChatMessageRepository.java      # JPA Repository for messages
β”‚   └── service/
β”‚       └── AuthenticationService.java      # User auth + registration logic
β”œβ”€β”€ src/main/resources/
β”‚   β”œβ”€β”€ templates/                          # Thymeleaf HTML templates
β”‚   β”‚   β”œβ”€β”€ login.html
β”‚   β”‚   β”œβ”€β”€ register.html
β”‚   β”‚   └── chat.html
β”‚   β”œβ”€β”€ static/                             # Static assets
β”‚   β”‚   β”œβ”€β”€ css/style.css
β”‚   β”‚   β”œβ”€β”€ js/
β”‚   β”‚   β”œβ”€β”€ index.html
β”‚   β”‚   └── script.js
β”‚   └── application.properties              # App configuration
β”œβ”€β”€ pom.xml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ render.yaml
└── README.md

πŸš€ Getting Started

Prerequisites

  • Java 17+ β†’ java -version
  • Maven 3.8+ β†’ mvn -version

1. Clone the Repository

git clone https://github.com/bhola-dev58/JLiveChats.git
cd JLiveChats

2. Build

mvn clean package

3. Run

java -jar target/jlivechats-1.0.0.jar

4. Open in Browser

http://localhost:8080

The app will redirect you to /login. Register a new account or sign in with Google.


πŸ”‘ Google OAuth2 Setup (Optional)

By default, the Google credentials in application.properties are pre-configured for local use. If you want to use your own Google Cloud credentials:

  1. Go to Google Cloud Console
  2. Create an OAuth2 Client ID
  3. Add http://localhost:8080/login/oauth2/code/google as an Authorized Redirect URI
  4. Update application.properties:
spring.security.oauth2.client.registration.google.client-id=YOUR_CLIENT_ID
spring.security.oauth2.client.registration.google.client-secret=YOUR_CLIENT_SECRET

For full setup instructions, see GOOGLE_OAUTH_FIX.md


🌐 WebSocket Endpoints

Endpoint Type Description
/ws WebSocket SockJS connection endpoint
/app/sendMessage STOMP Publish Send a chat message
/app/typing STOMP Publish Broadcast typing indicator
/topic/messages STOMP Subscribe Receive new messages
/topic/users STOMP Subscribe Receive user presence updates

🌍 Deployment

Docker

docker build -t jlivechats .
docker run -p 8080:8080 jlivechats

Render / Railway (Free Cloud)

  • See DEPLOYMENT.md for step-by-step cloud deployment instructions.

πŸ”’ Security

  • Passwords are hashed with BCrypt before being stored in the database
  • Sessions are secured via Spring Security's filter chain
  • OAuth2 tokens are managed by Spring Security OAuth2 Client
  • CSRF protection is disabled intentionally to support WebSocket connections

πŸ› Troubleshooting

Problem Fix
Port 8080 already in use Run lsof -i :8080 and kill the process, or change port in application.properties
Google sign-in error 400 See GOOGLE_OAUTH_FIX.md
App won't start Ensure Java 17+ is installed: java -version
Messages not updating Check browser console for WebSocket connection errors

πŸ“ˆ Roadmap

  • WebSocket real-time messaging
  • Google OAuth2 sign-in
  • BCrypt password encryption
  • Database-backed user registration
  • Typing indicators
  • Multi-channel support
  • Direct Messages (1-on-1)
  • File/image sharing
  • PostgreSQL migration (production)
  • Push notifications
  • Admin dashboard

πŸ‘¨β€πŸ’» Author

Bhola Yadav
USN: 1CR23CS044 | Section: K | Branch: Computer Science Engineering
GitHub


πŸ“„ License

This project is open-source and available for educational purposes.


JLiveChats β€” Built with ❀️ using Spring Boot, WebSockets, and Google OAuth2.

About

JLiveChats is a Java-based real-time chating application that uses sockets to stream and visualize live data dynamically. Built with AWT/Swing for the UI and Java Sockets for network communication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors