A real-time chat application built with modern web technologies. Connect, communicate, and collaborate instantly with one-on-one and group messaging capabilities.
π Live Demo: https://chatbox-456l.onrender.com/
- β User Authentication - Secure login/signup with JWT tokens
- β One-on-One Chat - Direct messaging between users
- β Group Chat - Create and manage group conversations
- β Real-time Messaging - Instant message delivery using Socket.io
- β User Search - Find and connect with other users
- β Profile Management - Customize profile with avatar and info
- β Typing Indicators - See when someone is typing
- β Online Status - Real-time user availability
- π Password Encryption - bcryptjs for secure passwords
- π¨ Responsive UI - Works on desktop, tablet, and mobile
- π± Modern Interface - Built with Chakra UI components
- β‘ Fast Performance - Optimized React with hooks
- π Real-time Sync - Socket.io for instant updates
- πΈ Image Upload - Cloudinary integration for profile pictures
- React.js - UI library with functional components
- Chakra UI - Component library for beautiful UI
- Socket.io Client - Real-time communication
- Axios - HTTP client for API calls
- React Router - Navigation and routing
- Lottie - Animations for typing indicators
- Node.js - JavaScript runtime
- Express.js - Web application framework
- MongoDB - NoSQL database
- Mongoose - MongoDB ODM
- Socket.io - Real-time bidirectional communication
- JWT (jsonwebtoken) - Authentication tokens
- bcryptjs - Password hashing
- Cloudinary - Image hosting and management
- Render - Backend hosting
- MongoDB Atlas - Cloud database
- Cloudinary - Image CDN
Before you begin, ensure you have:
- Node.js (v14 or higher) - Download
- npm (v6 or higher) - Comes with Node.js
- MongoDB - Local or Atlas
- Git - Download
- Cloudinary Account - Free signup (for image uploads)
git clone https://github.com/yourusername/chat-box.git
cd chat-boxcd backend
npm installCreate a .env file in the backend folder:
# Database
MONGO_URI=mongodb://localhost:27017/chatbox
# Authentication
JWT_SECRET=your_super_secret_jwt_key_here_change_this
# Server
PORT=5000
NODE_ENV=development
CLIENT_URL=http://localhost:3000
# Optional: For production
CLOUDINARY_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secretStart the backend server:
npm startExpected output:
Server started on port 5000
MongoDB Connected: localhost
Open a new terminal and run:
cd frontend
npm install
npm startThe app will open at: http://localhost:3000
Chat-box/
βββ .gitignore
βββ LICENSE
βββ README.md
βββ Screenshots/
β βββ Screenshot 2023-05-05 211053.png
β βββ Screenshot 2023-05-05 211550.png
β βββ Screenshot 2023-05-05 211630.png
β βββ a.txt
βββ backend/
β βββ config/
β β βββ db.js
β β βββ generateToken.js
β βββ controllers/
β β βββ chatControllers.js
β β βββ messageControllers.js
β β βββ userControllers.js
β βββ data/
β β βββ data.js
β βββ middlewares/
β β βββ authMiddleware.js
β β βββ errorMiddleware.js
β βββ models/
β β βββ chatModel.js
β β βββ messageModel.js
β β βββ userModel.js
β βββ routes/
β β βββ chatRoutes.js
β β βββ messageRoutes.js
β β βββ userRoutes.js
β βββ server.js
βββ frontend/
β βββ build/
β β βββ asset-manifest.json
β β βββ favicon.ico
β β βββ favicon.jpg
β β βββ favicon.png
β β βββ index.html
β β βββ logo192.png
β β βββ logo512.png
β β βββ manifest.json
β β βββ robots.txt
β β βββ static/
β β βββ css/
β β β βββ main.e2308290.css
β β β βββ main.e2308290.css.map
β β βββ js/
β β β βββ main.9d837798.js
β β β βββ main.9d837798.js.LICENSE.txt
β β β βββ main.9d837798.js.map
β β βββ media/
β β βββ background.bb83868fcaa1e68c8558.jpg
β βββ package-lock.json
β βββ package.json
β βββ public/
β β βββ favicon.ico
β β βββ favicon.jpg
β β βββ favicon.png
β β βββ index.html
β β βββ logo192.png
β β βββ logo512.png
β β βββ manifest.json
β β βββ robots.txt
β βββ src/
β βββ App.css
β βββ App.js
β βββ Context/
β β βββ ChatProvider.js
β βββ Pages/
β β βββ Chatpage.js
β β βββ Homepage.js
β β βββ favicon.png
β βββ animations/
β β βββ typing.json
β βββ background.jpg
β βββ components/
β β βββ Authentication/
β β β βββ Login.js
β β β βββ Signup.js
β β βββ ChatBox.js
β β βββ ChatLoading.js
β β βββ MyChats.js
β β βββ ScrollableChat.js
β β βββ SingleChat.js
β β βββ miscellaneous/
β β β βββ GroupChatModal.js
β β β βββ ProfileModel.js
β β β βββ SideDrawer.js
β β β βββ UpdateGroupChatModal.js
β β β βββ favicon.png
β β βββ styles.css
β β βββ userAvatar/
β β βββ UserBadgeItem.js
β β βββ UserListItem.js
β βββ config/
β β βββ ChatLogics.js
β βββ index.css
β βββ index.js
βββ package-lock.json
βββ package.json
| Method | Endpoint | Description |
|---|---|---|
| POST | / |
Register new user |
| POST | /login |
Login user |
| GET | / |
Get all users (search) |
| Method | Endpoint | Description |
|---|---|---|
| POST | / |
Create/fetch one-on-one chat |
| GET | / |
Fetch all chats |
| POST | /group |
Create group chat |
| PUT | /rename |
Rename group |
| PUT | /groupadd |
Add user to group |
| PUT | /groupremove |
Remove user from group |
| Method | Endpoint | Description |
|---|---|---|
| POST | / |
Send message |
| GET | /:chatId |
Get all messages for chat |
The app uses JWT (JSON Web Tokens) for authentication:
- User signs up/logs in
- Server generates JWT token
- Token stored in localStorage (frontend)
- Token sent in Authorization header for protected routes
- Backend verifies token with
authMiddleware
Example:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...socket.emit("setup", userData) // Initialize connection
socket.emit("join chat", chatId) // Join chat room
socket.emit("typing", chatId) // Typing indicator
socket.emit("stop typing", chatId) // Stop typing
socket.emit("new message", message) // Send messagesocket.on("connected") // Connection established
socket.on("message recieved", message) // Receive message
socket.on("typing") // User typing
socket.on("stop typing") // User stopped typing- Click "Sign Up" tab
- Enter name, email, password
- Optional: Upload profile picture
- Click "Sign Up"
- Click "Log In" tab
- Enter email and password
- Click "Log In"
- Click "Search User" button
- Search for user by name or email
- Click on user to start chat
- Click "+" button next to chats
- Enter group name
- Add users to group
- Click "Create Chat"
- Type message in input box
- Press Enter to send
- See messages appear in real-time
- Click your avatar (top right)
- Click "My Profile" to view details
- Click "Logout" to logout
Status: β
Fixed in latest version
Solution: Updated userModel.js with correct isModified("password") check
Status: β
Fixed in latest version
Solution: Fixed undefined userData reference in disconnect handler
Status: β Verify backend is running on port 5000
- Push code to GitHub
- Go to Render.com
- Create new Web Service
- Connect GitHub repository
- Set environment variables in Render dashboard
- Deploy!
cd frontend
npm run build
# Deploy the build folder to VercelContributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
Avijit Roy
- GitHub: @yourusername
- Email: your.email@example.com
For support, email: support@chatbox.com or open an issue on GitHub.
- Message search functionality
- Message reactions (emoji)
- File/document sharing
- Voice/video calling
- Message deletion & editing
- Read receipts
- User blocking feature
- Chat notifications
- Dark mode theme
- Mobile app (React Native)
- β‘ Load Time: < 2 seconds
- π Message Delivery: < 100ms
- π Concurrent Users: 1000+
- ποΈ Database: MongoDB Atlas
- π CDN: Cloudinary for images
- Chakra UI - Component library
- Socket.io - Real-time communication
- MongoDB - Database
- Express.js - Backend framework
- React.js - Frontend framework
- β User authentication with JWT
- β One-on-one messaging
- β Group chat functionality
- β Real-time Socket.io integration
- β User search and profile management
- β Typing indicators
Happy Chatting! π¬
For the latest updates and documentation, visit: https://chatbox-456l.onrender.com/