This is a simple chat messenger built with Java Spring Boot, utilizing WebSocket and a message broker for real-time messaging. User authentication is handled via Keycloak, enabling users to sign up and log in. Once logged in, each user is visible to other clients and can chat with them in real-time. Each chat session is assigned a unique topic ID based on the users’ session IDs.
- User Authentication: Users authenticate through Keycloak.
- Real-time Messaging: Messages are sent over WebSocket channels with dedicated session topics.
- Dynamic User Availability: Once logged in, users become visible to others and can initiate chats.
- Future Database Migration: The app currently uses a relational database, with plans to migrate to a JSON-based database.
- Java 17
- Docker (for Keycloak setup)
To clone the project repository, run:
git clone https://github.com/Morteza363831/spring-boot-chat-messenger.git
cd spring-boot-chat-messenger
-
Run Keycloak in Docker: Start a Keycloak container on port 8080.
docker run -p 8080:8080 --name keycloak \ -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin \ quay.io/keycloak/keycloak:latest start-dev
-
Import Realm Configuration: Import the Keycloak realm configuration by going to the Keycloak admin console:
- Access Keycloak at
http://localhost:8080
. - Log in with the Keycloak admin credentials (
admin/admin
by default). - Import your realm settings from the provided export file:
- Go to Realm Settings > Add Realm.
- Select Import and upload the provided
.json
file.
- This configuration sets up the authentication required by the chat messenger app.
- The Realm Setting file is in the
src/main/resources
directory of the project
- Access Keycloak at
-
Start the Application:
- Navigate to the project directory and run:
./mvnw spring-boot:run
- The application will start on port
8020
. Keycloak will be available on port8080
.
-
Access the Application:
- Open your browser and navigate to
http://localhost:8020
. - Log in with your Keycloak credentials, and start chatting with other online users.
- Open your browser and navigate to
- Messaging: Users can send and receive messages in real-time.
- Session-based Topics: Each chat session is assigned a unique topic based on the session ID (a combination of usernames).
- User Presence: Once logged in, users appear to others as available to chat.
- Database Migration: Transition from a relational database to a JSON-based database for storing chat history and user data.
For questions or contributions, reach out to me:
- Email: [email protected]
- LinkedIn: Morteza Mahdi Zadeh
- Telegram: @m_mhzd