A modern real-time chat application with group chat and private messaging.
- Frontend: Chat Application
- Backend: Server
- ๐ JWT Authentication
- ๐ฌ Real-time Group & Private Messaging
- ๐ฅ User List for Private Chats
- ๐จ Message Persistence
- ๐จ Modern Responsive UI
Backend: Node.js, Express, MongoDB, Socket.IO, JWT
Frontend: React 19, Vite, Socket.IO Client, Tailwind CSS
- Node.js (v14+)
- MongoDB (local or Atlas)
- Clone and Install
# Backend
cd chat-app-backend
npm install
cp .env.example .env
# Edit .env with your MongoDB URI and JWT secret
npm start
# Frontend (in new terminal)
cd chat-app-frontend
npm install
npm run dev- Environment Variables
Backend .env:
MONGO_URI=mongodb://localhost:27017/chatdb
JWT_SECRET=your_secret_key_here
PORT=5000Frontend .env:
VITE_API_URL=http://localhost:5000- Access
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Register a new account
- Login with your credentials
- Group Chat - Click "# Group Chat" in sidebar
- Private Chat - Click any username to start a private conversation
- Logout - Click the logout button
chat-app/
โโโ chat-app-backend/ # Node.js + Express + Socket.IO
โ โโโ models/ # MongoDB schemas (User, Message)
โ โโโ routes/ # API routes (auth, chat)
โ โโโ middleware/ # JWT authentication
โ โโโ index.js # Server entry point
โโโ chat-app-frontend/ # React + Vite
โโโ src/components/ # UI components
โโโ src/api/ # API client
โโโ src/App.jsx # Main app component
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register user |
| POST | /api/auth/login |
Login & get token |
| GET | /api/auth/users |
Get all users |
| GET | /api/chat/messages |
Fetch messages |
MIT