This project is a feature-rich real-time chat application built using the MERN stack (MongoDB, Express.js, ReactJS, Node.js) along with Socket.io for real-time communication and Redux for efficient state management. This chat app enables users to send messages instantly, manage contacts, and maintain chat history in a responsive and intuitive interface.
- Instant message delivery using Socket.io for real-time, bidirectional communication.
- Typing indicators to see when other users are typing.
- Message delivery and read receipts.
- Secure user registration and login using JWT (JSON Web Tokens).
- Passwords are hashed and securely stored in the database.
- Access control to protect routes and functionalities based on user roles.
- One-to-One Chat: Users can send private messages to other users.
- Group Chat: Users can create chat groups and invite others to participate.
- Online/Offline Status: Real-time updates of user status to show who is online.
- Responsive Design: Optimized for both desktop and mobile devices using TailwindCSS.
- User-Friendly Interface: Clean and intuitive design for easy navigation.
- Dark Mode: Option to switch between light and dark themes.
- Chat History: Persist messages in MongoDB to allow users to view past conversations.
- Notifications: Receive real-time notifications for new messages.
- Search: Search functionality to find messages and users.
- Emojis and Media: Support for sending emojis, images, and files in chat.
- ReactJS: JavaScript library for building user interfaces.
- Redux: State management for handling user and chat states efficiently.
- Socket.io-client: For establishing real-time communication between client and server.
- TailwindCSS: Utility-first CSS framework for rapid UI development.
- Node.js: JavaScript runtime for building the server-side logic.
- Express.js: Web framework for creating RESTful APIs.
- Socket.io: For real-time, event-based communication.
- JWT: For secure user authentication.
- MongoDB: NoSQL database for storing user information, chat messages, and chat rooms.
Before you begin, make sure you have the following installed on your system:
- Node.js (v14.x or higher)
- npm (Node Package Manager)
- MongoDB (running locally or hosted)
Follow these steps to set up and run the application locally:
-
Clone the Repository
Open your terminal and run:
git clone https://github.com/yourusername/chat-app.git cd chat-app
-
Install Dependencies
-
Server-Side Dependencies:
Navigate to the server directory and install the required Node.js packages:
cd server npm install
-
Client-Side Dependencies:
Navigate to the client directory and install the necessary React packages:
cd client npm install
-
-
Environment Configuration
Create a
.env
file in theserver
directory to store environment variables:MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret PORT=5000
Replace
your_mongodb_connection_string
with your actual MongoDB connection string andyour_jwt_secret
with a secret key for JWT.
-
Start MongoDB
Ensure your MongoDB server is running. If using MongoDB Atlas, ensure the service is configured correctly.
-
Run the Backend Server
Start the Node.js server by navigating to the
server
directory and running:cd server npm start
The backend server will start on
http://localhost:5000
. -
Run the Frontend Server
Start the React development server by navigating to the
client
directory and running:cd client npm start
The frontend will start on
http://localhost:3000
.
- Access the Chat Application: Open a web browser and go to
http://localhost:3000
. - Register: Create a new account or log in with existing credentials.
- Chat: Start a new conversation with users or join a group chat to communicate in real time.
This project is licensed under the MIT License. You are free to use, modify, and distribute this software as long as the original license is included.
- Socket.io: For real-time communication capabilities.
- MERN Stack: A powerful full-stack solution for building modern web applications.
- Redux: For predictable state management.
- TailwindCSS: For creating beautiful and responsive user interfaces quickly.
This chat application is a robust and scalable solution for real-time messaging, suitable for personal projects or as a base for more complex applications. Feel free to customize and expand upon the features as needed. Happy coding!