Chatly is a full-stack real-time chat application built using the MERN stack (MongoDB, Express.js, React.js, Node.js) and Socket.IO for instant communication. It enables users to send messages, share images, and view online statuses with real-time updates.
- ⚛️ React (Vite) – Component-based UI
- 🎨 Tailwind CSS – Modern responsive styling
- 🔁 Redux Toolkit – State management
- 🔌 Socket.IO Client – Real-time communication
- 🧠 Node.js + Express.js – RESTful API & WebSocket server
- 🗄️ MongoDB + Mongoose – Database & schema management
- ☁️ Cloudinary – Image hosting service
- 🧱 Multer – File upload handling
- 🔒 Bcrypt.js – Password hashing
- 🧩 CORS, Cookie-parser – Security and request management
- 🔐 User registration and login with JWT authentication
- 💬 Real-time one-to-one chat using Socket.IO
- 🟢 Online user tracking (presence system)
- 🖼️ Image upload via Cloudinary
- 💾 Persistent message storage in MongoDB
- 🔄 State management using Redux
- 🧑💻 Responsive and modern UI with Tailwind
graph TD
A[React Frontend] -->|REST API| B[Express Backend]
A -->|Socket.IO| C[Socket.IO Server]
B --> D[(MongoDB)]
C --> D
B --> E[(Cloudinary)]
- User A sends a message → Socket emits
send-msg. - Backend receives and saves it to MongoDB.
- Server emits
msg-receiveevent to recipient. - Receiver’s UI updates instantly.
- Message persists via REST endpoint for reloads.
root/
├── backend/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── socket/
│ ├── utils/
│ └── index.js
└── frontend/
├── src/
│ ├── components/
│ ├── redux/
│ ├── pages/
│ ├── App.jsx
│ └── main.jsx
{
name: String,
userName: { type: String, unique: true },
email: { type: String, unique: true },
password: String,
image: String,
}{
sender: ObjectId,
receiver: ObjectId,
text: String,
image: String,
createdAt: Date
}{
participants: [ObjectId],
messages: [ObjectId]
}- User signs up → Password hashed with bcryptjs.
- Server generates JWT token → Sent via cookie or header.
- Protected routes use
isAuthmiddleware for validation.
add-user→ Adds user touserSocketMap.send-msg→ Emits new message to receiver.getOnlineUsers→ Broadcasts list of active users.disconnect→ Removes user from online map.
- Frontend sends multipart form (text + file).
- Multer handles parsing.
- File uploaded to Cloudinary.
- Cloudinary URL saved in MongoDB.
- 💬 Group Chat Feature: Enable multi-user chat rooms and broadcast messaging.
- 👁️ Read Receipts: Show when messages are seen by the receiver.
- 🌗 Dark & Light Theme Toggle: Improve accessibility and user preference.
- 🔔 Push Notifications: Real-time alerts for new messages even when the app is closed.
- ⚙️ Redis Adapter Integration: Scale Socket.IO for multi-server deployments.
- 🕒 Message Edit & Delete: Allow users to modify or remove sent messages.
- 🧠 AI Chatbot Integration (Optional): Provide quick replies or suggestions.
- 🧾 User Profile Customization: Allow bio, status, and profile settings.
This project is open-source and free to use for learning and development purposes.
Samagra Jaiswal Software Developer | MERN Stack Enthusiast