An open API service indexing awesome lists of open source software.

https://github.com/devanshdevs/chat-app

A responsive real-time chat application built with React, Node.js, and Socket.IO. It supports instant messaging, live online user tracking, typing indicators, and system notifications β€” all wrapped in a clean, modern UI using Tailwind CSS and shadcn/ui.
https://github.com/devanshdevs/chat-app

socket-io tailwindcss webdevelopment

Last synced: 2 months ago
JSON representation

A responsive real-time chat application built with React, Node.js, and Socket.IO. It supports instant messaging, live online user tracking, typing indicators, and system notifications β€” all wrapped in a clean, modern UI using Tailwind CSS and shadcn/ui.

Awesome Lists containing this project

README

          

# Real-Time Chat Application

A modern, real-time chat application built with React and Node.js, featuring Socket.IO for instant messaging capabilities.

πŸš€ Features

- ⚑ Real-time messaging via WebSockets
- πŸ§β€β™‚οΈ Live user presence and online list
- ✍️ Typing indicators
- βœ… Connection status and auto-reconnect
- πŸ“± Fully responsive UI (mobile + desktop)
- 🎨 Clean UI using Tailwind CSS + shadcn/ui
- πŸ”” System messages (join/leave events)

---

πŸ› οΈ Tech Stack

🧩 Backend
- **Node.js** + **Express**
- **Socket.IO**
- **CORS**

🎨 Frontend
- **React** + **Vite**
- **Tailwind CSS** + **shadcn/ui**
- **Lucide React**
- **Socket.IO client**

---

πŸ“ Project Structure

```
chat-app/
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ server.js # Main server file
β”‚ β”œβ”€β”€ package.json # Backend dependencies
β”‚ └── node_modules/ # Backend dependencies
β”œβ”€β”€ frontend/
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ App.jsx # Main React component
β”‚ β”‚ β”œβ”€β”€ App.css # Styles
β”‚ β”‚ β”œβ”€β”€ main.jsx # Entry point
β”‚ β”‚ └── components/ # UI components
β”‚ β”œβ”€β”€ index.html # HTML template
β”‚ β”œβ”€β”€ package.json # Frontend dependencies
β”‚ └── node_modules/ # Frontend dependencies
└── README.md # This file
```

βš™οΈ Installation & Setup

🧾 Prerequisites:
Node.js v18+
npm or pnpm installed globally

globally

πŸ”§ Backend Setup
cd backend # Navigate to backend directory
npm install # Install server dependencies
npm run dev # Start backend server
The backend server will run on `http://localhost:3001`

πŸ’» Frontend Setup
cd backend # Navigate to backend directory
npm install # Install server dependencies
npm run dev # Start backend server
The frontend will be available at `http://localhost:5173` or `http://localhost:5174`

πŸ§ͺ Usage

🟒 Start both servers – Backend + Frontend
🌐 Open http://localhost:5173 in your browser
πŸ‘€ Enter a username to join the chat
πŸ’¬ Start chatting with other users in real time
πŸ§ͺ Test multiple users by opening additional tabs or windows

πŸ“‘ API & WebSocket Events

🌐 Backend Routes
- `GET /` - Server status check
- `GET /health` - Health check with connection info

πŸ”Œ Socket.IO Events
- `join` - User joins the chat
- `send_message` - Send a message
- `receive_message` - Receive a message
- `typing` - Typing indicator
- `user_joined` - User joined notification
- `user_left` - User left notification
- `users_list` - Current users list
- `users_update` - Updated users list

βš™οΈ Configuration

πŸ›  Backend Configuration
The backend server is configured to:
- Listen on port 3001 (configurable via PORT environment variable)
- Accept connections from any origin (CORS enabled)
- Listen on all network interfaces (0.0.0.0)

🎨 Frontend Configuration
The frontend is configured to:
- Connect to `http://localhost:3001` for Socket.IO
- Use Vite for development with hot reload
- Support responsive design for mobile and desktop

πŸ›  Development

πŸ”„ Running in Development Mode
Both servers support hot reload for development:
- Backend: Uses `nodemon` for automatic restart on file changes
- Frontend: Uses Vite's built-in hot module replacement

πŸ— Building for Production
To build the frontend for production:
```bash
cd frontend
pnpm run build
```

✨ Features in Detail

πŸ” Real-time Communication
- Uses Socket.IO for WebSocket-based real-time communication
- Automatic reconnection on connection loss
- Connection status indicator

πŸ–ΌοΈ User Interface
- Modern, clean design with gradient backgrounds
- Responsive layout that works on all screen sizes
- Smooth animations and transitions
- Professional color scheme with light/dark mode support

πŸ“¨ Message Features
- Timestamps on all messages
- User identification with different styling for own messages
- System messages for user join/leave events
- Typing indicators with timeout

πŸ§‘β€πŸ’» User Management
- Live user count
- Online users list with visual indicators
- Automatic cleanup when users disconnect

🐞 Troubleshooting

❗Common Issues
1. **Connection refused** - Make sure the backend server is running on port 3001
2. **CORS errors** - The backend is configured to allow all origins
3. **Port conflicts** - Vite will automatically use the next available port
4. **Socket connection issues** - Check that both frontend and backend are running

πŸ“œ Logs
- Backend logs show user connections, messages, and server status
- Frontend console shows Socket.IO connection status and errors

πŸš€ Future Enhancements

Potential features that could be added:
- User authentication and persistent sessions
- Message history and persistence
- Private messaging
- File sharing
- Emoji support
- Message reactions
- User profiles and avatars
- Chat rooms/channels
- Message encryption

πŸ“„ License

This project is open source and available under the MIT License.

πŸ™‹β€β™‚οΈ Support

For issues or questions, please check the troubleshooting section above or review the code comments for implementation details.

Built with ⚑ by DEVanshDEVS