Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s-satyajit/multi-user-chatapp
A chat application that lets you chat with multiple people at the same time, designed to make communication easy and smooth.
https://github.com/s-satyajit/multi-user-chatapp
chat-application firebase messaging multi-user-chat open-source reactjs vercel web-app
Last synced: 23 days ago
JSON representation
A chat application that lets you chat with multiple people at the same time, designed to make communication easy and smooth.
- Host: GitHub
- URL: https://github.com/s-satyajit/multi-user-chatapp
- Owner: s-satyajit
- License: mit
- Created: 2024-12-04T04:21:51.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-08T17:36:47.000Z (29 days ago)
- Last Synced: 2024-12-08T18:24:25.979Z (29 days ago)
- Topics: chat-application, firebase, messaging, multi-user-chat, open-source, reactjs, vercel, web-app
- Language: JavaScript
- Homepage: https://multi-user-chat.vercel.app/
- Size: 448 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Multi-User Chat Application
The Multi-User Chat Application lets multiple people chat with each other in real-time. Using the latest web technologies, this app provides a smooth and responsive chat experience, making it easy to stay connected## Table of Contents
- [Introduction](#introduction)
- [Features](#features)
- [Tech Stack](#tech-stack)
- [Installation](#installation)
- [Prerequisites](#prerequisites)
- [Environment Setup](#environment-setup)
- [Installing Dependencies](#installing-dependencies)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [API Endpoints](#api-endpoints)
- [Authentication Endpoints](#authentication-endpoints)
- [Chat Endpoints](#chat-endpoints)
- [Components](#components)
- [Hooks](#hooks)
- [Testing](#testing)
- [Logging and Monitoring](#logging-and-monitoring)
- [Security](#security)
- [Performance Optimization](#performance-optimization)
- [Deployment](#deployment)
- [Manual Deployment](#manual-deployment)
- [Automatic Deployment](#automatic-deployment)
- [Continuous Integration/Continuous Deployment (CI/CD)](#continuous-integrationcontinuous-deployment-cicd)
- [Code Quality](#code-quality)
- [Contribution Guidelines](#contribution-guidelines)
- [FAQ](#faq)
- [License](#license)
- [Acknowledgements](#acknowledgements)## Introduction
The Multi-User Chat Application is a real-time messaging platform that enables seamless communication between multiple users. This application ensures a smooth, interactive, and responsive chat experience.## Features
- **Real-Time Messaging:** Instant communication between users.- **User Authentication:** Secure sign-up and sign-in.
- **User Presence:** Show online/offline status of users.
- **Message History:** Store and retrieve chat history.
- **Emoji Support:** Add emojis to enhance user interactions.
## Tech Stack
- **Frontend:** [ReactJS](https://reactjs.org/)
- **Backend:** [Firebase Functions](https://firebase.google.com/docs/functions)
- **Database:** [Firebase Firestore](https://firebase.google.com/docs/firestore)
- **Authentication:** [Firebase Authentication](https://firebase.google.com/docs/auth)
- **Storage:** [Firebase Storage](https://firebase.google.com/docs/storage)
## Installation
### Prerequisites
- [Node.js ](https://nodejs.org/) (v14.x or higher)
- [npm](https://www.npmjs.com/) (v6.x or higher) or [yarn](https://yarnpkg.com/) (v1.22.x or higher)
- [MongoDB](https://www.mongodb.com/) (v4.x or higher)### Environment Setup
#### 1. Clone the repository:```bash
git clone https://github.com/s-satyajit/multi-user-chatApp.git
cd multi-user-chatApp
```### Installing Dependencies
#### 2. Install dependencies:
```bash
npm install
```
#### 3. Configure Firebase:- Create a Firebase project in the Firebase Console.
- Obtain your Firebase configuration details from the project settings.
- Create a ```.env``` file in the root directory and add your Firebase configuration.
```env
REACT_APP_FIREBASE_API_KEY=
REACT_APP_FIREBASE_AUTH_DOMAIN=
REACT_APP_FIREBASE_PROJECT_ID=
REACT_APP_FIREBASE_STORAGE_BUCKET=
REACT_APP_FIREBASE_MESSAGING_SENDER_ID=
REACT_APP_FIREBASE_APP_ID=
```
---
## Usage
Once the setup is complete, you can use the following features:#### **1. Sign Up/In:**
- Users can sign up and sign in using Firebase Authentication.
#### 2. **Messaging:**
- Start new conversations and send messages in real-time using Firebase Firestore.
#### 3. **User Presence:**
View the online/offline status of other users.
## Project Structure
Here's an overview of the project's structure:```
π¦ Project Root
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
βββ eslint.config.js # ESLint configuration
βββ index.html # Main HTML file
βββ package-lock.json # Lockfile for npm dependencies
βββ package.json # Project metadata and dependencies
βββ public/ # Public assets
β βββ arrowDown.png # Arrow down icon
β βββ arrowUp.png # Arrow up icon
β βββ avatar.png # User avatar
β βββ bg.jpg # Background image
β βββ camera.png # Camera icon
β βββ download.png # Download icon
β βββ edit.png # Edit icon
β βββ emoji.png # Emoji icon
β βββ favicon.png # Favicon
β βββ img.png # Generic image
β βββ info.png # Info icon
β βββ mic.png # Microphone icon
β βββ minus.png # Minus icon
β βββ more.png # More options icon
β βββ phone.png # Phone icon
β βββ plus.png # Plus icon
β βββ search.png # Search icon
β βββ theme.png # Theme icon
β βββ video.png # Video icon
β βββ vite.svg # Vite logo
βββ src/ # Source code
β βββ App.jsx # Main React component
β βββ assets/ # Asset files
β β βββ react.svg # React logo
β βββ components/ # React components
β β βββ chat/ # Chat feature components
β β β βββ Chat.jsx # Chat component logic
β β β βββ chat.css # Chat component styles
β β βββ detail/ # Detail view components
β β β βββ Detail.jsx # Detail component logic
β β β βββ detail.css # Detail component styles
β β βββ list/ # List view components
β β β βββ List.jsx # List component logic
β β βββ chatList/ # Chat list components
β β β βββ ChatList.jsx # Chat list component logic
β β β βββ chatList.css # Chat list component styles
β β βββ addUser/ # Add user components
β β β βββ addUser.jsx # Add user component logic
β β β βββ addUser.css # Add user component styles
β β βββ userInfo/ # User information components
β β β βββ Userinfo.jsx # User information component logic
β β β βββ userInfo.css # User information component styles
β β βββ login/ # Login components
β β β βββ Login.jsx # Login component logic
β β β βββ login.css # Login component styles
β β βββ notification/ # Notification components
β β βββ Notification.jsx # Notification component logic
β βββ index.css # Global styles
β βββ lib/ # Utility libraries
β β βββ UserStore.js # User state management
β β βββ chatStore.js # Chat state management
β β βββ firebase.js # Firebase configuration
β β βββ upload.js # File upload utility
β βββ main.jsx # Application entry
ββββββββvite.config.js # Vite configuration
```---
## API Endpoints
### Authentication Endpoints
#### Sign Up
Registers a new user.## API Endpoints
### Authentication Endpoints
#### **Sign Up**
Registers a new user using Firebase Authentication.```javascript
import { getAuth, createUserWithEmailAndPassword } from "firebase/auth";const signUp = (email, password) => {
const auth = getAuth();
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed up successfully
})
.catch((error) => {
// Handle errors here
});
};
```#### **Sign In**
Authenticates a user using Firebase Authentication.```javascript
import { getAuth, signInWithEmailAndPassword } from "firebase/auth";const signIn = (email, password) => {
const auth = getAuth();
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in successfully
})
.catch((error) => {
// Handle errors here
});
};
```### Chat Endpoints
#### **Get Messages**
Fetches message history for a chat from Firebase Firestore.```javascript
import { getFirestore, collection, query, where, getDocs } from "firebase/firestore";const getMessages = async (chatId) => {
const db = getFirestore();
const q = query(collection(db, "messages"), where("chatId", "==", chatId));
const querySnapshot = await getDocs(q);
const messages = [];
querySnapshot.forEach((doc) => {
messages.push(doc.data());
});
return messages;
};
```#### **Send Message**
Adds a new message to the chat in Firebase Firestore.```javascript
import { getFirestore, collection, addDoc } from "firebase/firestore";const sendMessage = async (chatId, text, userId) => {
const db = getFirestore();
await addDoc(collection(db, "messages"), {
chatId,
text,
sender: userId,
timestamp: new Date()
});
};
```---
## Components
### **ChatBox**
Displays chat messages and a form to send new messages.```javascript
import React, { useState, useEffect } from 'react';
import useSocket from '../hooks/useSocket';const ChatBox = ({ chatId }) => {
const [messages, setMessages] = useState([]);
const { socket, sendMessage } = useSocket(chatId);useEffect(() => {
socket.on('message', (message) => {
setMessages((prevMessages) => [...prevMessages, message]);
});return () => {
socket.off('message');
};
}, [socket]);const handleSend = (e) => {
e.preventDefault();
const text = e.target.elements.message.value;
sendMessage({ chatId, text });
e.target.reset();
};return (
{messages.map((msg, index) => (
{msg.text}
))}
Send
);
};export default ChatBox;
```---
## Hooks
### **useSocket**
Custom hook for managing socket connections.```javascript
import { useState, useEffect } from 'react';
import io from 'socket.io-client';const useSocket = (chatId) => {
const [socket, setSocket] = useState(null);useEffect(() => {
const newSocket = io('http://localhost:5000', { query: { chatId } });
setSocket(newSocket);return () => newSocket.close();
}, [chatId]);const sendMessage = (message) => {
if (socket) {
socket.emit('send_message', message);
}
};return { socket, sendMessage };
};export default useSocket;
```### **useNotifications**
Custom hook for managing notifications.```javascript
import { useState, useEffect } from 'react';const useNotifications = () => {
const [notifications, setNotifications] = useState([]);useEffect(() => {
// Logic to fetch and subscribe to notifications
}, []);const addNotification = (notification) => {
setNotifications((prevNotifications) => [...prevNotifications, notification]);
};return { notifications, addNotification };
};export default useNotifications;
```---
## Testing
To ensure the application functions correctly, run the following command to execute tests:
```bash
npm test
```---
## Logging and Monitoring
- Use Firebase Analytics for monitoring.
- Use Firebase Crashlytics for error tracking.---
## Security
1. Use HTTPS to encrypt data in transit.
2. Store passwords securely using Firebase Authentication.
3. Validate inputs to prevent XSS and other attacks.
4. Regularly update dependencies.---
## Performance Optimization
- Use Firestore's offline capabilities.
- Implement lazy loading for components.
- Optimize Firestore queries.
- Use Firebase Performance Monitoring.---
## Deployment
### **Manual Deployment**
1. Build the project:
```bash
npm run build
```2. Initialize Firebase in your project:
```bash
firebase init
```3. Deploy the build directory:
```bash
firebase deploy
```### **Automatic Deployment**
Set up CI/CD pipelines using GitHub Actions.Example `.github/workflows/deploy.yml`:
```yaml
name: Deploy to Firebaseon:
push:
branches:
- mainjobs:
build:
runs-on: ubuntu-lateststeps:
- name: Checkout code
uses: actions/checkout@v2- name: Install dependencies
run: npm install- name: Build project
run: npm run build- name: Deploy to Firebase
run: firebase deploy --token ${{ secrets.FIREBASE_TOKEN }}
```---
## Code Quality
- Use linters like ESLint.
- Write unit and integration tests.
- Use tools like Prettier for code formatting.
- Conduct code reviews.---
## Contribution Guidelines
1. **Fork the repository.**
2. **Clone your fork:**
```bash
git clone https://github.com/your-username/multi-user-chatApp.git
cd multi-user-chatApp
```
3. **Create a new branch:**
```bash
git checkout -b feature-name
```
4. **Make your changes and commit:**
```bash
git commit -m "Add feature-name"
```
5. **Push your branch:**
```bash
git push origin feature-name
```
6. **Create a pull request.**---
## FAQ
**Q: How do I report a bug?**
A: Open an issue in the GitHub repository with a detailed description.**Q: Can I use this project for my own purposes?**
A: Yes, this project is open-source and licensed under the MIT License.---
## License
This project is licensed under the [MIT License](LICENSE).
---