A modern, full-stack real-time chat application built with React, Spring Boot, and WebSocket technology. Features secure authentication, real-time messaging, and group chat functionality.
- π Project Overview
- π οΈ Technology Stack
- π¦ Installation Instructions
- π Deployment Guide
- π§ Troubleshooting
Chattingo is a comprehensive chat application designed for seamless real-time communication. The application provides a modern user interface with robust backend services, supporting individual and group messaging with real-time updates.
- Real-time Messaging: Instant message delivery using WebSocket technology
- User Authentication: Secure JWT-based authentication system
- Group Chat: Create and manage group conversations
- User Management: Profile management and user discovery
- Responsive Design: Mobile-friendly interface built with React and Tailwind CSS
- Secure Communication: End-to-end secure message transmission
- React 18.2.0 - Modern JavaScript library for building user interfaces
- Material-UI (MUI) - React component library for consistent design
- Tailwind CSS - Utility-first CSS framework for styling
- React Router DOM - Client-side routing for single-page application
- Redux Thunk - State management for predictable application state
- STOMP.js & SockJS - WebSocket client libraries for real-time communication
- React Icons - Comprehensive icon library
- Spring Boot 3.3.1 - Java framework for building production-ready applications
- Spring Security - Authentication and authorization framework
- Spring Data JPA - Data persistence layer with Hibernate
- Spring WebSocket - Real-time bidirectional communication
- JWT (JSON Web Tokens) - Secure token-based authentication
- Maven - Dependency management and build automation
- Java 17 - Latest LTS version of Java
- MySQL 8.0 - Relational database for data persistence
- Hibernate - Object-relational mapping (ORM) framework
- Docker & Docker Compose - Containerization and orchestration
- Jenkins - Continuous Integration/Continuous Deployment (CI/CD)
- Nginx - Web server and reverse proxy
- SonarQube - Code quality analysis
- Trivy - Container security scanning
- OWASP Dependency Check - Security vulnerability scanning
On your Jenkins master, run:
ssh-keygen -t ed25519 -C "chattingo-vps" -f ~/.ssh/chattingo_vpsThis gives you:
- Private key β
~/.ssh/chattingo_vps - Public key β
~/.ssh/chattingo_vps.pub
Now copy the public key:
cat ~/.ssh/chattingo_vps.pubThen Go to Hostinger Dashboard > Settings > SSH Keys > Add SSH Key And paste the public key there. I repeat the public key.
Now SSH to your VPS.
ssh -i ~/.ssh/chattingo_vps root@<your-vps-ip>Then copy the private key (~/.ssh/chattingo_vps) and store it in Jenkins Credentials. Read Credentials section below
apt update && apt upgrade -y
apt install -y docker.io docker-compose
systemctl enable docker
systemctl start dockerVerify:
docker --version
docker-compose --versionOn my VPS there was already git installed.
But if you don't have git installed, you can install it using the following command:
apt install -y gitHere are the steps to setup Jenkins:
Go to Jenkins Master and click on Manage Jenkins --> Plugins --> Available plugins to install the below plugins:
- NodeJs Plugin
- OWASP Dependency Check
- SonarQube Scanner
- Docker Plugin
After these plugins are installed, move to Manage Jenkins --> Tools (Jenkins Worker)
-
NodeJs: Add a NodeJs installation with name
node:18and version18.Y.Z -
Maven: Add a Maven installation with name
maven:3.9and version3.9.Z -
OWASP: Add a OWASP installation with name
OWASP. Check theInstall Automaticallybox and choose any version fromgithub.com -
SonarQube: Add a SonarQube Scanner installation with name
sonarqubeandanyversion you want
- Docker
sudo apt install docker.io -y sudo usermod -aG docker ubuntu && newgrp docker - Trivy
sudo apt-get install wget apt-transport-https gnupg lsb-release -y wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add - echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list sudo apt-get update -y sudo apt-get install trivy -y
Here are the steps to setup SonarQube:
-
Run the SonarQube Container
docker run -itd --name SonarQube-Server -p 9000:9000 sonarqube:lts-community
-
Login to SonarQube server and navigate to Administration --> Security --> Users --> Tokens and create the credentials for jenkins to integrate with SonarQube
-
Add that token to Jenkins, read Credentials section below
Go to Manage Jenkins --> Credentials --> Global and add the following credentials:
-
Dockerhub: Generate a token with read/write access and add it to Jenkins with id
dockerand typeUsername with password -
Github: Generate a ssh key that can be used to clone and push to the repository. Add it to Jenkins with id
github-ssh-keyand typeSSH Username with private key -
VPS: Read this section to setup pass-less SSH to your VPS. Add it to Jenkins with id
vps-ssh-keyand typeSSH Username with private key
Go to Jenkins Master and click on Manage Jenkins --> System and search for Global trusted libraries and add the following library:
- Name:
Shared - Default Version:
main - Project Repository:
https://github.com/HasanAshab/Jenkins_SharedLib.git
Add a Item of type Folder name it chattingo. Everything related to the project will be inside that folder.
Now create these pipelines:
-
orchestrator: The pipeline that orchestrates service pipelines.
- Repository URL:
https://github.com/HasanAshab/chattingo - Script Path:
Jenkinsfile - Check the
GitHub hook trigger for GITScm pollingbox
- Repository URL:
-
frontend: Pipeline responsible for CI/CD of frontend.
- Repository URL:
https://github.com/HasanAshab/chattingo - Script Path:
frontend/Jenkinsfile
- Repository URL:
-
backend: Pipeline responsible for CI/CD of backend.
- Repository URL:
https://github.com/HasanAshab/chattingo - Script Path:
backend/Jenkinsfile
- Repository URL:
Go to chattingo repo and navigate to Settings --> Webhooks and add the following webhook:
- Payload URL:
https://<jenkins-server-ip>/github-webhook/ - Content type:
application/x-www-form-urlencoded
First Connect to your VPS do the following step by step:
- Clone chatingo-compose repo (not the chattingo repo)
git clone https://github.com/HasanAshab/chattingo-compose.git
- Go to the cloned directory
cd chattingo-compose - Run setup script with your mysql password (First give permission to the script).
chmod +x setup.sh ./setup.sh <your db password>
- Finally run the docker compose
docker-compose up -d
Issue: Communication link failure
Check the SPRING_DATASOURCE_URL in backend/.env file. It should be in the format of jdbc:mysql://<service_name>:<port>/<database_name>
Note: <service_name> is the name of the MySQL service in Docker Compose.
Issue: Application fails to start
# Check Java version
java -version
# Should be Java 17 or higher
# Check if port 8080 is available
netstat -tulpn | grep :8080
# Kill process if port is occupied
sudo kill -9 $(lsof -t -i:8080)Issue: Database connection failed
# Check MySQL service status
sudo systemctl status mysql
# Start MySQL if not running
sudo systemctl start mysql
# Verify database exists
mysql -u root -p -e "SHOW DATABASES;"
# Create database if missing
mysql -u root -p -e "CREATE DATABASE chattingo_db;"Issue: JWT token errors
# Generate new JWT secret (64 characters)
openssl rand -base64 64
# Update JWT_SECRET in backend/.env
# Restart the applicationIssue: CORS errors in browser
# Check CORS configuration in backend/.env
CORS_ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
# Restart backend after changing CORS settings
cd backend && ./mvnw spring-boot:runIssue: API connection failed
# Check if backend is running
curl http://localhost:8080/Issue: WebSocket connection failed
# Check browser console for WebSocket errors
# Verify JWT token is valid
# Ensure backend WebSocket endpoint is accessible
curl -I http://localhost:8080/wsIf you encounter issues not covered here:
- Check the logs - Most issues are revealed in application logs
- Verify configuration - Ensure all environment variables are set correctly
- Test components individually - Isolate the problem to specific services
- Check network connectivity - Verify services can communicate with each other
- Review documentation - Refer to Spring Boot and React documentation
For additional support, please create an issue in the GitHub repository with:
- Detailed error description
- Steps to reproduce
- Environment information
- Relevant log outputs
# View application logs
docker-compose logs -f backend
# View specific service logs
docker logs chattingo-backend-1 --tail 100
# Search for errors
docker-compose logs backend | grep ERROR-- Add indexes for better query performance
CREATE INDEX idx_messages_chat_id ON messages(chat_id);
CREATE INDEX idx_messages_timestamp ON messages(timestamp);
CREATE INDEX idx_users_email ON users(email);# Add to nginx.conf for caching static filess
location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|ttf|woff|woff2)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# Add to application.properties for production
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=false
logging.level.org.hibernate.SQL=WARN
server.compression.enabled=true