A modern, real-time chat application built with WebSocket technology, featuring a responsive UI and secure authentication.
- Real-time messaging with WebSocket connections
- User authentication with JWT tokens
- Responsive design optimized for all devices
- Profile management with avatar upload
- Multiple chat rooms support
- Message history with pagination
- Online status indicators
- Secure password management
- WebRTC-based file transfer (temporary, non-persistent)
Files sent via WebRTC are not stored on the server; they will vanish if the page is reloaded.
- Node.js (v16 or higher)
- MongoDB
- npm or yarn
-
Clone the repository
git clone <repository-url> cd cohotWS
-
Install backend dependencies
cd backend npm install -
Install frontend dependencies
cd ../frontend npm install -
Set up environment variables
# Backend (.env) MONGODB_URI=mongodb://localhost:27017/chatapp JWT_SECRET=your-secret-key PORT=5000 # Frontend (.env) VITE_API_URL=http://localhost:5000 VITE_WS_URL=ws://localhost:5000
-
Start the development servers
# Backend (Terminal 1) cd backend npm run dev # Frontend (Terminal 2) cd frontend npm run dev
| Package | Version | Purpose |
|---|---|---|
express |
^4.18.0 | Web framework for Node.js |
mongoose |
^7.0.0 | MongoDB object modeling |
ws |
^8.13.0 | WebSocket server implementation |
jsonwebtoken |
^9.0.0 | JWT authentication |
bcryptjs |
^2.4.3 | Password hashing |
cors |
^2.8.5 | Cross-origin resource sharing |
multer |
^1.4.5 | File upload handling |
dotenv |
^16.0.3 | Environment variable management |
| Package | Version | Purpose |
|---|---|---|
react |
^18.2.0 | UI library |
vite |
^4.3.0 | Build tool and dev server |
@mui/joy |
^5.0.0 | Modern Material-UI components |
@mui/icons-material |
^5.11.0 | Material Design icons |
react-router-dom |
^6.10.0 | Client-side routing |
react-hook-form |
^7.43.0 | Form validation |
@reduxjs/toolkit |
^1.9.0 | State management |
react-redux |
^8.0.0 | React-Redux bindings |
axios |
^1.4.0 | HTTP client |
react-hot-toast |
^2.4.0 | Toast notifications |
cohotWS/
├── backend/
│ ├── src/
│ │ ├── controllers/ # Route handlers
│ │ ├── models/ # MongoDB schemas
│ │ ├── middleware/ # Auth & validation
│ │ ├── routes/ # API routes
│ │ └── utils/ # Helper functions
│ ├── uploads/ # File storage
│ └── server.js # Entry point
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── redux/ # State management
│ │ ├── context/ # React context
│ │ └── shared/ # Shared utilities
│ └── public/ # Static assets
└── README.md
npm run dev # Start development server with nodemon
npm start # Start production server
npm run test # Run testsnpm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintPOST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logout
GET /api/user/profile- Get user profilePATCH /api/user/updateProfile- Update profilePATCH /api/user/updateBio- Update bioPATCH /api/user/updatePassword- Change password
GET /api/chat/members/:id- Get chat membersGET /api/chat/messages/:id- Get chat messagesPOST /api/chat/send- Send message
MONGODB_URI=mongodb://localhost:27017/chatapp
JWT_SECRET=your-super-secret-jwt-key
PORT=5000
NODE_ENV=development
UPLOAD_PATH=./uploadsVITE_API_URL=http://localhost:5000
VITE_WS_URL=ws://localhost:5000
VITE_APP_NAME=ChatApp- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request