This is a full-featured backend for a scalable real-time chat application under development, currently supporting:
- ✅ 1-to-1 and group chats
- 📩 Real-time messaging using Socket.IO
- ✏️ Edit/Delete messages
- ✅ Delivered/Seen indicators
- 🔔 Typing indicators, archiving, muting
- 🔐 JWT authentication
- 📁 MongoDB database with Mongoose
- 📦 Postman collections for API testing
- Node.js + Express
- MongoDB + Mongoose
- Socket.IO
- JWT for Auth
- Postman for API Testing
git clone https://github.com/your-username/chat-backend.git
cd chat-backendnpm installCreate a .env file in the root directory:
PORT=5001
MONGO_URI=mongodb://localhost:27017/chatapp
JWT_SECRET=your_jwt_secret
CLOUDINARY_CLOUD_NAME=xxx
CLOUDINARY_API_KEY=xxx
CLOUDINARY_API_SECRET=xxx
EMAIL_USER=xxx
EMAIL_PASS=xxxYou can also connect to MongoDB Atlas if you prefer a cloud database.
For development
npm run devThe backend should be running at:
http://localhost:5001
| Collection Name | Description |
|---|---|
postman-collection_.json |
User registration and login endpoints |
postman-collection_Chats.json |
Create, fetch, update, mute, archive, and delete chats |
postman-collection_Message.json |
Send, edit, delete, and mark messages as seen |
Instead of importing files one by one, you can import the entire
postman/folder:
- In Postman, go to
File > Import - Drag & drop the
postman/folder - Postman will auto-import all 4 files:
postman-collection_Authentication.jsonpostman-collection_Chats.jsonpostman-collection_Message.jsonpostman_environment.json
- Postman auto-imports
postman_environment.json - Set it as the active environment
- Edit and add your actual values if needed:
{
"base_url": "http://localhost:5001/api",
"token": "your_token_here",
"user_id": "your_user_id_here",
"user_id_2": "another_user_id",
"user_id_3": "third_user_id",
"user_id_4": "fourth_user_id",
"chat_id": "your_chat_or_group_id_here",
"message_id": "your_message_id_here"
}- Register/Login using the
Authenticationcollection - Use the token received in register/login to populate
{{token}} - Continue with:
Chats(create, update, mute, archive, delete, leave)Messages(send, edit, delete, mark seen)
Each request is pre-filled with placeholders like
{{base_url}},{{token}},{{chat_id}}, etc.
🛡️ Security Notes
- All IDs and tokens in Postman collections are replaced with environment variables.
- Never expose real credentials or tokens in public repositories.
- Use
.envfor managing secrets in code.