Skip to content

Real-time chat application supporting user authentication (signup, login, logout), messaging, and message voting, supporting concurrent multi-user interactions. Used React.js for the front end, Express.js, and Node.js for the backend, MongoDB for data storage, Docker and Kubernetes for the infrastructure and deployment.

Notifications You must be signed in to change notification settings

Younes43/Chat-Room-Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Application Setup Guide

This README provides instructions on how to set up and run the chat application locally. It includes setting up MongoDB, installing the correct version of Node.js, and running the server and client applications.

The application utilizes React for the front end, Express for the back end, and MongoDB as the database.

chat chat

Installation Steps

1. Set Up MongoDB

To install MongoDB on Ubuntu, follow these steps to use the official MongoDB repository:

Import the MongoDB public GPG Key:

sudo apt-get install gnupg curl

curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor

echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list

sudo apt-get update

sudo apt-get install -y mongodb-org

2. Install Node.js

Install Node.js using NodeSource. This provides the latest versions directly suitable for development:

# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Verify the Node.js installation:

node -v

3. Install Dependencies

Navigate to both the frontend and backend directories in separate terminal windows and install the necessary packages:

# For backend
cd ./chat-app-backend
npm install

# For frontend
cd ./chat-app-frontend
npm install

5. Configure Environment Variables

Set up the necessary environment variables. Create a .env file in your backend directory and add the following:

MONGO_URI=mongodb://localhost:27017/chatApp
PORT=3000

6. Run the Application

Start both the backend and frontend services:

# Start the backend server
cd chat-app/readme.txt
npm start

# In another terminal, start the frontend application
cd ./chat-app-frontend
npm start

Accessing the Application

Open your web browser and navigate to http://localhost:3000 (or whichever port the frontend is set to use) to view and interact with the chat application.

Deployment Using Docker and Kubernetes

This section provides a step-by-step guide on how to deploy the chat application using Docker containers and manage it through Kubernetes with Minikube.

Prerequisites

Ensure you have the following installed:

  • Docker: For creating and managing your application containers.
  • Minikube: A tool that allows you to run Kubernetes locally.
  • kubectl: A command-line tool for interacting with your Kubernetes cluster.

Step 1: Dockerize the Application

  1. Navigate to the Backend Directory:

    • Build the Docker image for the backend.
    cd ./chat-app-backend
    docker build -t chat-app-backend .
  2. Modify MongoDB Connection URL:

    • Before deploying MongoDB, modify the MongoDB URL in your backend's environment settings to ensure it connects to the Kubernetes MongoDB service rather than a local instance:

      MONGO_URI="mongodb://admin:password@mongodb-service:27017/chatApp?authSource=admin"
      
  3. Deploy MongoDB with Docker and Kubernetes:

    • MongoDB can be deployed using Docker and managed within Kubernetes independently of the frontend and backend services.
    1. Build the MongoDB Docker Image (if using a custom setup):

      docker build -t custom-mongo:latest -f Dockerfile.mongo .
    2. Deploy MongoDB using Kubernetes:

      kubectl apply -f mongodb-deployment.yaml

      This will create a MongoDB service and a persistent storage volume to ensure data is not lost when the pod is restarted.

  4. Navigate to the Frontend Directory:

    • Build the Docker image for the frontend.
    cd ./chat-app-frontend
    docker build -t chat-app-frontend .

Step 2: Start Minikube

  • Start your local Kubernetes cluster with Minikube.
    minikube start

Step 3: Enable Ingress in Minikube

  • This allows you to access your services via an external IP.
    minikube addons enable ingress

Step 4: Deploy to Kubernetes

  1. Navigate to the Kubernetes Configuration Directory:

    cd ./k8s
  2. Apply the Kubernetes Configurations:

    • Deploy the backend and frontend services.
    kubectl apply -f backend-deployment.yaml
    kubectl apply -f frontend-deployment.yaml

Step 5: Access the Application

  • Use Minikube to open the frontend service in your default web browser.
    minikube service frontend-service

Step 7: Stop and Cleanup

  • When you're done, you can stop Minikube and optionally delete all resources.
    minikube stop
    minikube delete

Additional Notes

  • Configuration Changes: If you update your Docker images, make sure to rebuild them and apply the changes to Kubernetes.

About

Real-time chat application supporting user authentication (signup, login, logout), messaging, and message voting, supporting concurrent multi-user interactions. Used React.js for the front end, Express.js, and Node.js for the backend, MongoDB for data storage, Docker and Kubernetes for the infrastructure and deployment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published