A full-stack real-time chat application built using React.js, Node.js, Express, and MongoDB with Socket.IO for instant messaging.
Users can register, log in, and chat with other users instantly in a secure and responsive environment.
-
🔐 Authentication System
- Secure login and registration using JWT (JSON Web Tokens).
- Passwords hashed using bcrypt for added security.
-
💬 Real-Time Messaging
- Instant message delivery with Socket.IO.
- Displays online/offline status.
-
👥 User Management
- See all registered users.
- Select and start chatting with anyone.
-
🕓 Message History
- Messages are stored in MongoDB and fetched automatically when a chat opens.
-
🌓 Modern UI
- Built using React and Tailwind CSS for a sleek, responsive interface.
Frontend:
- React.js
- Context API
- Tailwind CSS
Backend:
- Node.js
- Express.js
- MongoDB (Mongoose)
- Socket.IO
- JWT Authentication
- bcrypt.js
git clone https://github.com/Ram-311/chat-app.git
cd chat-appcd server
npm installcd ../client
npm installCreate a .env file inside the server folder and add the following:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_keyTo run both backend and frontend, open two terminals:
cd server
npm startcd client
npm startAfter both are running, open your browser and go to:
👉 http://localhost:5173/ (or the port your React app runs on)
- Users authenticate using JWT during login/register.
- Once logged in, they can see all users and start a conversation.
- Messages are sent in real time through Socket.IO and saved in MongoDB.
- When reopening the chat, previous messages are automatically loaded.
- JWT authentication for protected routes.
- Passwords encrypted using bcrypt.
- Tokens verified for each request.