A real-time one-to-one chat application built with Node.js, Socket.io, Redis, and Firebase Authentication.
- User authentication with Firebase (email/password)
- Real-time messaging using Socket.io
- Direct one-to-one messaging between users
- Online/offline status indicators
- Message persistence using Redis
- Unread message notifications
- User profiles with photos
- Password reset functionality
- Responsive UI design
- Docker support for easy deployment
- Frontend: HTML, CSS, JavaScript
- Backend: Node.js, Express
- Real-time Communication: Socket.io
- Authentication: Firebase Authentication
- Message Storage: Redis
- Containerization: Docker
- Node.js (v14 or higher)
- Redis server (local or remote)
- Firebase project with Authentication enabled
- Docker and Docker Compose (optional)
# Clone the repository
git clone https://github.com/JaydevVadachhak/softtalksapp.git
cd softtalksapp
# Configure Firebase
# Edit public/js/firebase-config.js with your Firebase project settings
# Start the application with Docker
npm run docker:up
# or use the script
./run.sh docker # Linux/macOS
run.bat docker # Windows# Clone the repository
git clone https://github.com/JaydevVadachhak/softtalksapp.git
cd softtalksapp
# Install dependencies
npm install
# Configure Firebase
# Edit public/js/firebase-config.js with your Firebase project settings
# Create .env file (or use the scripts to create it automatically)
echo "PORT=3000" > .env
echo "REDIS_HOST=localhost" >> .env
echo "REDIS_PORT=6379" >> .env
echo "REDIS_PASSWORD=" >> .env
# Start Redis (if not already running)
npm run redis:start
# Start the application
npm run devOpen your browser and navigate to http://localhost:3000
To use this application, you need to create a Firebase project and enable Authentication:
-
Go to Firebase Console
-
Create a new project
-
Enable Authentication (Email/Password method)
-
Get your Firebase config object
-
Set up your environment variables:
a. Copy the example environment file:
# On Windows create-env.bat # On Unix/Linux/Mac ./create-env.sh
b. Edit the
.envfile with your Firebase configuration:FIREBASE_API_KEY=your_api_key FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com FIREBASE_PROJECT_ID=your_project_id FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id FIREBASE_APP_ID=your_app_id
Note: The
.envfile is ignored by Git to keep your API keys secure.
-
Clone the repository
-
Configure Firebase as described above
-
Make sure Docker and Docker Compose are installed
-
Run the application using Docker Compose:
npm run docker:up # or docker-compose up -d -
Open your browser and navigate to
http://localhost:3000 -
To stop the application:
npm run docker:down # or docker-compose down
-
Clone the repository
-
Configure Firebase as described above
-
Create a
.envfile in the root directory with the following variables:PORT=3000 REDIS_HOST=localhost REDIS_PORT=6379 REDIS_PASSWORD=Note: Leave REDIS_PASSWORD empty if your Redis server doesn't have authentication enabled. If your Redis server has a password, add it to the REDIS_PASSWORD field.
-
Install dependencies:
npm install
-
Start the application:
npm start # or for development with auto-reload npm run dev -
Open your browser and navigate to
http://localhost:3000
If you want to run just the Redis instance separately:
npm run redis:start
# or
docker run --name soft-talks-redis-instance -p 6379:6379 -v ./data:/data -d redis redis-server --save 60 1 --loglevel warningNote: The default Docker Redis image doesn't have authentication enabled. If you need to enable password authentication, you'll need to modify the command to include --requirepass yourpassword.
The application uses Socket.io for real-time communication between clients and the server. Firebase handles user authentication, and Redis is used to store messages for persistence.
Users can sign up or log in using email/password authentication via Firebase. Once authenticated, the user's profile information (username, email, photo URL) is sent to the server and stored in Redis.
Users can start a chat with any other online user by clicking on their name in the active users list. Messages are delivered in real-time if both users are online. If a user is offline, messages are stored and delivered when they come back online.
All messages between users are stored in Redis using a consistent naming pattern to ensure the same conversation can be retrieved regardless of which user initiates the chat. When a user opens a chat with another user, they receive the most recent messages from that conversation (up to 100 messages).
When a user receives a message while chatting with someone else, a notification appears next to the sender's name in the active users list.
npm start- Start the applicationnpm run dev- Start the application with nodemon for developmentnpm run docker:up- Start the application with Docker Composenpm run docker:down- Stop the Docker containersnpm run redis:start- Start Redis standalone with Dockernpm run redis:stop- Stop and remove the Redis container
Contributions are welcome! Please read CONTRIBUTING.md for details on how to contribute to this project.
This project is licensed under the MIT License - see the LICENSE file for details.
- Socket.io for real-time communication
- Firebase for authentication
- Redis for data persistence
- Express for the web server
- Docker for containerization
To prepare the application for production deployment, follow these steps:
-
Create a
.envfile based on the.env.example.txttemplate:copy .env.example.txt .env
-
Configure your environment variables in the
.envfile, especially:REDIS_PASSWORDfor secure Redis connectionNODE_ENV=productionto enable production optimizations- Firebase configuration if applicable
The application is containerized and ready for production deployment using Docker:
# Build and start containers in detached mode
docker-compose up -d
# Check container status
docker-compose ps
# View logs
docker-compose logs -fFor production scaling:
- Use a Redis cluster instead of a single instance
- Deploy multiple application instances behind a load balancer
- Consider using container orchestration like Kubernetes for automated scaling
The application includes:
- Health check endpoint at
/health - Structured logging with Winston
- Rate limiting to prevent abuse
- All Redis passwords should be strong and unique
- The application runs as a non-root user in Docker
- Helmet.js is configured for secure HTTP headers
- Rate limiting is enabled to prevent abuse
Regular Redis data backups are configured with:
redis-server --save 60 1
This saves the dataset if at least 1 key changes in 60 seconds.