This is a real-time chat application built using the MERN (MongoDB, Express.js, React.js, Node.js) stack, featuring real-time messaging through WebSockets. It allows users to communicate instantly and securely, with functionalities like typing indicators, online/offline status, and user authentication.
- Real-Time Messaging: Powered by
socket.io-client
for instant communication. - State Management: Managed using
zustand
for simplicity and performance. - Routing: Handled by
react-router-dom
for dynamic and efficient navigation. - User Notifications: Integrated with
react-hot-toast
for real-time alerts. - Custom Icons: Used
lucide-react
for UI consistency.
- API Management: Developed using
Express.js
to handle RESTful APIs. - Database: MongoDB used for efficient data storage and retrieval.
- Authentication: Secured with
bcryptjs
for password hashing andjsonwebtoken
for token-based authentication. - File Uploads: Supported via
cloudinary
for storing user media. - Cross-Origin Resource Sharing: Managed by
cors
to enable secure communication between frontend and backend. - WebSocket Integration: Implemented with
socket.io
for bidirectional real-time communication.
real-time-chat-app/
├── frontend/ # React-based frontend application
│ ├── src/
│ │ ├── components/ # Reusable React components
│ │ ├── pages/ # Individual page components
│ │ ├── store/ # Zustand state management
│ │ ├── App.js # Main application file
│ │ ├── index.js # Entry point
│ └── package.json # Frontend dependencies
│
├── backend/ # Node.js-based backend application
│ ├── controllers/ # API logic
│ ├── models/ # Mongoose schemas
│ ├── routes/ # Express routes
│ ├── server.js # Main server file
│ └── package.json # Backend dependencies
│
└── README.md # Project documentation
- Node.js installed on your system.
- MongoDB instance running locally or in the cloud.
- Cloudinary account for media storage.
-
Clone the repository:
git clone https://github.com/rishisulakhe/real-time-chat-app.git cd real-time-chat-app
-
Install dependencies:
# Install backend dependencies cd backend npm install # Install frontend dependencies cd frontend npm install
-
Environment variables: Create
.env
files in bothfrontend
andbackend
directories with the following keys:Backend .env:
PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_secret_key CLOUDINARY_NAME=your_cloudinary_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret
Frontend .env:
REACT_APP_BACKEND_URL=http://localhost:5173
-
Run the application:
# Start backend server cd backend npm run dev # Start frontend server cd frontend npm run dev
-
Open your browser and navigate to
http://localhost:3000
.
-
User Authentication:
- Secure sign-up and login using JWT.
- Passwords hashed with bcrypt for security.
-
Real-Time Communication:
- Users can send messages instantly via WebSockets.
- Typing indicators and online/offline statuses are updated in real time.
-
Data Storage:
- MongoDB stores user data and chat history.
- Cloudinary manages file uploads (e.g., images).
-
State Management:
- Zustand simplifies global state management for real-time updates.
- Add group chat functionality.
- Enable message search and filters.
- Integrate AI-based chat suggestions.
- Implement end-to-end encryption for messages.
This project is licensed under the MIT License.