⚙️ Quick Chat App — Backend Server
This is the backend service for the Quick Chat App , built with Node.js , Express.js , MongoDB , and Socket.IO . It provides REST APIs and real-time communication for messaging, authentication, and user management.
🔐 JWT-based Authentication (Signup/Login)
👤 User management & profile handling
💬 One-to-one real-time chat with Socket.IO
📨 Message storage & retrieval
☁️ Image upload support via Cloudinary
🛡️ Protected routes with middleware
⚡ Scalable and modular structure
Node.js
Express.js
MongoDB + Mongoose
Socket.IO
Cloudinary (for media uploads)
JSON Web Token (JWT)
Server/
├─ config/
│ └─ dbConfig.js # MongoDB connection setup
│
├─ controllers/ # Request handling logic
│ ├─ authController.js
│ ├─ chatController.js
│ ├─ messageController.js
│ └─ userController.js
│
├─ middlewares/ # Custom middleware
│ └─ authMiddleware.js # JWT verification
│
├─ models/ # Mongoose schemas
│ ├─ chat.js
│ ├─ message.js
│ └─ user.js
│
├─ app.js # Express app configuration
├─ server.js # Server entry point (HTTP + Socket.IO)
├─ cloudinary.js # Cloudinary configuration
│
├─ .env # Environment variables
├─ .env.example # Sample environment file
├─ .gitignore
├─ package.json
├─ package-lock.json
└─ README.MD
Create a .env file in the root directory:
PORT = create a port
MONGO_URI = your_mongodb_connection_string
JWT_SECRET = your_jwt_secret
# Cloudinary Config
CLOUDINARY_CLOUD_NAME = your_cloud_name
CLOUDINARY_API_KEY = your_api_key
CLOUDINARY_API_SECRET = your_api_secret
git clone https://github.com/Nayan-Krishna-Ball/Chat-application-server.git
Method
Endpoint
Description
POST
/api/auth/signup
Register new user
POST
/api/auth/login
Login user
Method
Endpoint
Description
GET
/api/users
Get all users
GET
/api/users/:id
Get user by ID
PUT
/api/users/:id
Update user profile
Method
Endpoint
Description
POST
/api/chat
Create or access chat
GET
/api/chat
Get user chats
Method
Endpoint
Description
POST
/api/messages
Send a message
GET
/api/messages/:chatId
Get chat messages
🔄 Real-Time Communication (Socket.IO)
connection → User connects
disconnect → User disconnects
join_chat → Join a chat room
send_message → Emit message
receive_message → Receive message
Uses Cloudinary for storing images
Configured in cloudinary.js
Can be used for:
Profile pictures
Chat media (images)
🔐 Authentication & Security
JWT stored on client side
Protected routes via authMiddleware
Token required in headers:
Authorization: Bearer < token>
User authenticates → receives JWT
Client connects to Socket.IO server
User joins chat rooms
Messages are:
Saved in database
Emitted in real-time
✅ Group chat support
✅ Message reactions
✅ Online/offline status
✅ Push notifications
✅ End-to-end encryption
Recommended tools:
Fork the repository
Create a new branch (feature/your-feature)
Commit your changes
Push and create a Pull Request