{"_id":"@anoopgeorgebits/realtime-chat-app","_rev":"2-77e72734e6611c93499f5850d0ebc7cf","name":"@anoopgeorgebits/realtime-chat-app","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@anoopgeorgebits/realtime-chat-app","version":"0.1.0","keywords":["chat","realtime","socket.io","MERN","websocket"],"author":{"name":"Anoop"},"license":"MIT","_id":"@anoopgeorgebits/realtime-chat-app@0.1.0","maintainers":[{"name":"anoopgeorgebits","email":"2024si96509@wilp.bits-pilani.ac.in"}],"dist":{"shasum":"b04226eec99e8e526c74a98faa9a86072e0bca4b","tarball":"https://registry.npmjs.org/@anoopgeorgebits/realtime-chat-app/-/realtime-chat-app-0.1.0.tgz","fileCount":18,"integrity":"sha512-ThY9c7eFVl1lKGidEALAyBAM6eseYiyF08KAgRtOdnGi7DkKKaDhbwxUOuSAElk8jJ2SLTN4CQi6AlO2xfG2EA==","signatures":[{"sig":"MEYCIQDhHNr7iL1NhzkrUkww5AOVFwbOg5nSWxJqqHkrv4CvlAIhALexgrWQF+cuZXiXH//7BtjEa53zxdC45u9ZXayRtT4c","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37209},"jest":{"testMatch":["**/server/**/__tests__/**/*.js","**/server/**/?(*.)+(spec|test).js"],"testEnvironment":"node","testPathIgnorePatterns":["/node_modules/","/client/"],"coveragePathIgnorePatterns":["/node_modules/","/client/"]},"main":"server/server.js","engines":{"npm":">=7.0.0","node":">=14.0.0"},"gitHead":"bc3f3fcca678719a86d709acf403b26f28c793c7","scripts":{"dev":"nodemon server/server.js","lint":"eslint .","test":"jest --coverage --testPathIgnorePatterns=client","build":"cd client && npm run build","start":"node server/server.js","client":"cd client && npm start","dev-all":"concurrently \"npm run dev\" \"npm run client\"","lint:fix":"eslint . --fix","test:all":"npm run test:backend && npm run test:frontend","test:watch":"jest --watch --testPathIgnorePatterns=client","install-all":"npm install && cd client && npm install","build:client":"cd client && npm run build","lint:backend":"eslint server/**/*.js --fix","test:backend":"jest --coverage --testPathIgnorePatterns=client","test:frontend":"cd client && npm test","heroku-postbuild":"npm run build:client"},"_npmUser":{"name":"anoopgeorgebits","email":"2024si96509@wilp.bits-pilani.ac.in"},"_npmVersion":"10.8.2","description":"A real-time chat application built with MERN stack and Socket.io","directories":{},"_nodeVersion":"20.20.0","dependencies":{"cors":"^2.8.5","dotenv":"^16.0.3","express":"^4.18.2","bcryptjs":"^2.4.3","mongoose":"^7.0.3","socket.io":"^4.6.1","jsonwebtoken":"^9.0.0","express-validator":"^7.0.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.57.0","globals":"^17.2.0","nodemon":"^2.0.22","supertest":"^6.3.3","@types/jest":"^29.5.11","concurrently":"^8.0.1"},"_npmOperationalInternal":{"tmp":"tmp/realtime-chat-app_0.1.0_1769596374501_0.1516945089270536","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@anoopgeorgebits/realtime-chat-app","version":"0.1.2","description":"A real-time chat application built with MERN stack and Socket.io","main":"server/server.js","engines":{"node":">=14.0.0","npm":">=7.0.0"},"scripts":{"start":"node server/server.js","dev":"nodemon server/server.js","client":"cd client && npm start","install-all":"npm install && cd client && npm install","dev-all":"concurrently \"npm run dev\" \"npm run client\"","build":"cd client && npm run build","build:client":"cd client && npm run build","heroku-postbuild":"npm run build:client","test":"jest --coverage --testPathIgnorePatterns=client","test:watch":"jest --watch --testPathIgnorePatterns=client","test:backend":"jest --coverage --testPathIgnorePatterns=client","test:frontend":"cd client && npm test","test:all":"npm run test:backend && npm run test:frontend","lint":"eslint .","lint:backend":"eslint server/**/*.js --fix","lint:fix":"eslint . --fix"},"repository":{"type":"git","url":"git+https://github.com/Anoop-2024si96509/Realtime-chat-app.git"},"bugs":{"url":"https://github.com/Anoop-2024si96509/Realtime-chat-app/issues"},"homepage":"https://github.com/Anoop-2024si96509/Realtime-chat-app#readme","keywords":["chat","realtime","socket.io","MERN","websocket"],"author":{"name":"Anoop"},"license":"MIT","dependencies":{"bcryptjs":"^2.4.3","cors":"^2.8.5","dotenv":"^16.0.3","express":"^4.18.2","express-validator":"^7.0.1","jsonwebtoken":"^9.0.0","mongoose":"^7.0.3","socket.io":"^4.6.1"},"devDependencies":{"@types/jest":"^29.5.11","concurrently":"^8.0.1","eslint":"^8.57.0","globals":"^17.2.0","jest":"^29.7.0","nodemon":"^2.0.22","supertest":"^6.3.3"},"jest":{"testEnvironment":"node","coveragePathIgnorePatterns":["/node_modules/","/client/"],"testPathIgnorePatterns":["/node_modules/","/client/"],"testMatch":["**/server/**/__tests__/**/*.js","**/server/**/?(*.)+(spec|test).js"]},"_id":"@anoopgeorgebits/realtime-chat-app@0.1.2","gitHead":"0736025b8c081e9da6a62b893380ab67a072c3fc","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-vSBZndbWk4zcNd7M+Vphc2J2GjkAxyvRWwZTrc1Hou6AfNCumtbAZZvDKCLl5JClo1tZTrENWxy82gAp0LoGBA==","shasum":"211f2444b34fe820dc9ae3702a5e6b9a4f91b995","tarball":"https://registry.npmjs.org/@anoopgeorgebits/realtime-chat-app/-/realtime-chat-app-0.1.2.tgz","fileCount":18,"unpackedSize":37498,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDcGwDmCVMdg4DxsqMsIccosUUiUxTKsae4cA9g7tB55AIhAP35gc0Hcx0YZv1Z94nQXmTgEuslL0rqZn3ww86g1X5Z"}]},"_npmUser":{"name":"anoopgeorgebits","email":"2024si96509@wilp.bits-pilani.ac.in"},"directories":{},"maintainers":[{"name":"anoopgeorgebits","email":"2024si96509@wilp.bits-pilani.ac.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/realtime-chat-app_0.1.2_1769599534968_0.8987073580477944"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-28T10:32:54.419Z","modified":"2026-01-28T11:25:35.212Z","0.1.0":"2026-01-28T10:32:54.652Z","0.1.2":"2026-01-28T11:25:35.113Z"},"author":{"name":"Anoop"},"license":"MIT","keywords":["chat","realtime","socket.io","MERN","websocket"],"description":"A real-time chat application built with MERN stack and Socket.io","maintainers":[{"name":"anoopgeorgebits","email":"2024si96509@wilp.bits-pilani.ac.in"}],"readme":"# Real-time Chat Application 💬\n\nA full-stack real-time chat application built with the MERN stack (MongoDB, Express.js, React.js, Node.js) and Socket.io for WebSocket communication.\n\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n![Node](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen.svg)\n![React](https://img.shields.io/badge/react-18.2.0-blue.svg)\n![CI Status](https://github.com/Anoop-2024si96509/Realtime-chat-app/workflows/CI%20-%20Tests%20and%20Lint/badge.svg)\n\n## 🏗️ Architecture\n\n### System Architecture Overview\n\n```\n┌─────────────────┐         WebSocket/HTTP        ┌─────────────────┐\n│                 │◄──────────────────────────────►│                 │\n│  React Client   │         Socket.io              │  Express Server │\n│   (Frontend)    │         REST API               │   (Backend)     │\n│                 │                                 │                 │\n└─────────────────┘                                 └────────┬────────┘\n                                                             │\n                                                             │ Mongoose\n                                                             │\n                                                    ┌────────▼────────┐\n                                                    │                 │\n                                                    │    MongoDB      │\n                                                    │   (Database)    │\n                                                    │                 │\n                                                    └─────────────────┘\n```\n\n### Technology Stack\n\n#### Frontend\n- **React.js 18** - UI library for building interactive interfaces\n- **Socket.io-client** - Real-time bidirectional event-based communication\n- **Axios** - HTTP client for REST API calls\n- **React Router** - Client-side routing\n- **CSS3** - Styling with modern gradient designs\n\n#### Backend\n- **Node.js** - JavaScript runtime environment\n- **Express.js** - Web application framework\n- **Socket.io** - WebSocket library for real-time communication\n- **Mongoose** - MongoDB object modeling tool\n- **JWT** - JSON Web Tokens for authentication\n- **bcryptjs** - Password hashing\n\n#### Database\n- **MongoDB** - NoSQL document database\n  - **Collections:**\n    - `users` - User accounts and profiles\n    - `messages` - Chat messages with timestamps\n    - `rooms` - Chat rooms with members\n\n## ✨ Features\n\n### Core Features\n- ✅ **User Authentication** - Register, login, logout with JWT\n- ✅ **Real-time Messaging** - Instant message delivery using WebSocket\n- ✅ **Multiple Chat Rooms** - Create and join different chat rooms\n- ✅ **Online Users** - See who's currently in the room\n- ✅ **Typing Indicators** - Know when someone is typing\n- ✅ **Message History** - Persistent message storage in MongoDB\n- ✅ **User Presence** - Join/leave notifications\n- ✅ **Responsive Design** - Works on desktop and mobile devices\n\n### Security Features\n- 🔒 Password hashing with bcrypt\n- 🔒 JWT-based authentication\n- 🔒 Protected API routes\n- 🔒 Input validation\n\n## 📋 Prerequisites\n\nBefore you begin, ensure you have the following installed:\n- **Node.js** (v14 or higher) - [Download](https://nodejs.org/)\n- **MongoDB** (v4 or higher) - [Download](https://www.mongodb.com/try/download/community)\n- **npm** or **yarn** - Comes with Node.js\n\n## 🚀 Installation & Setup\n\n### 1. Clone the repository\n\n```bash\ngit clone https://github.com/yourusername/realtime-chat-app.git\ncd realtime-chat-app\n```\n\n### 2. Install dependencies\n\nInstall both server and client dependencies:\n\n```bash\n# Install server dependencies\nnpm install\n\n# Install client dependencies\ncd client\nnpm install\ncd ..\n```\n\nOr use the convenience script:\n\n```bash\nnpm run install-all\n```\n\n### 3. Configure environment variables\n\nCreate a `.env` file in the root directory:\n\n```bash\ncp .env.example .env\n```\n\nEdit the `.env` file with your configuration:\n\n```env\nPORT=5000\nMONGODB_URI=mongodb://localhost:27017/realtime-chat\nJWT_SECRET=your_super_secret_jwt_key_change_this_in_production\nNODE_ENV=development\nCLIENT_URL=http://localhost:3000\n```\n\n### 4. Start MongoDB\n\nMake sure MongoDB is running on your system:\n\n```bash\n# On Windows (if installed as service)\nnet start MongoDB\n\n# On macOS/Linux\nmongod\n\n# Or using MongoDB Compass (GUI)\n```\n\n### 5. Run the application\n\n#### Development mode (runs both server and client):\n\n```bash\nnpm run dev-all\n```\n\n#### Or run separately:\n\n**Terminal 1 - Backend:**\n```bash\nnpm run dev\n```\n\n**Terminal 2 - Frontend:**\n```bash\nnpm run client\n```\n\n#### Production mode:\n\n```bash\n# Build the React app\ncd client\nnpm run build\ncd ..\n\n# Start the server\nnpm start\n```\n\nThe application will be available at:\n- **Frontend:** http://localhost:3000\n- **Backend API:** http://localhost:5000\n\n## 📁 Project Structure\n\n```\nrealtime-chat-app/\n├── client/                      # React frontend\n│   ├── public/\n│   │   └── index.html\n│   ├── src/\n│   │   ├── components/\n│   │   │   ├── Auth/\n│   │   │   │   ├── Login.js\n│   │   │   │   └── Register.js\n│   │   │   └── Chat/\n│   │   │       ├── ChatRoom.js\n│   │   │       ├── ChatRoom.css\n│   │   │       ├── RoomList.js\n│   │   │       └── RoomList.css\n│   │   ├── App.js\n│   │   ├── App.css\n│   │   ├── index.js\n│   │   └── index.css\n│   └── package.json\n│\n├── server/                      # Express backend\n│   ├── models/\n│   │   ├── User.js             # User schema\n│   │   ├── Message.js          # Message schema\n│   │   └── Room.js             # Room schema\n│   ├── routes/\n│   │   ├── auth.js             # Authentication routes\n│   │   ├── messages.js         # Message routes\n│   │   └── rooms.js            # Room routes\n│   ├── middleware/\n│   │   └── auth.js             # JWT authentication middleware\n│   └── server.js               # Main server file\n│\n├── .env.example                 # Environment variables template\n├── .gitignore                   # Git ignore file\n├── package.json                 # Server dependencies\n└── README.md                    # This file\n```\n\n## 🔌 API Endpoints\n\n### Authentication\n- `POST /api/auth/register` - Register a new user\n- `POST /api/auth/login` - Login user\n- `GET /api/auth/me` - Get current user (protected)\n- `POST /api/auth/logout` - Logout user (protected)\n\n### Rooms\n- `GET /api/rooms` - Get all public rooms (protected)\n- `POST /api/rooms` - Create a new room (protected)\n- `GET /api/rooms/:roomName` - Get room details (protected)\n- `POST /api/rooms/:roomName/join` - Join a room (protected)\n- `POST /api/rooms/:roomName/leave` - Leave a room (protected)\n\n### Messages\n- `GET /api/messages/room/:roomName` - Get messages for a room (protected)\n- `PUT /api/messages/:messageId` - Edit a message (protected)\n- `DELETE /api/messages/:messageId` - Delete a message (protected)\n\n## 🔄 Socket Events\n\n### Client → Server\n- `join` - Join a chat room\n- `send_message` - Send a message to the room\n- `typing` - Notify that user is typing\n- `stop_typing` - Notify that user stopped typing\n- `disconnect` - User disconnects\n\n### Server → Client\n- `receive_message` - Receive a new message\n- `user_joined` - Notification when user joins\n- `user_left` - Notification when user leaves\n- `room_users` - Updated list of users in room\n- `user_typing` - Someone is typing\n- `user_stop_typing` - Someone stopped typing\n\n## 🗄️ Database Schema\n\n### User Model\n```javascript\n{\n  username: String (required, unique),\n  email: String (required, unique),\n  password: String (required, hashed),\n  avatar: String,\n  status: String (online/offline/away),\n  createdAt: Date\n}\n```\n\n### Message Model\n```javascript\n{\n  room: String (required),\n  sender: ObjectId (ref: User),\n  senderName: String,\n  content: String (required),\n  type: String (text/image/file),\n  timestamp: Date,\n  edited: Boolean,\n  editedAt: Date\n}\n```\n\n### Room Model\n```javascript\n{\n  name: String (required, unique),\n  description: String,\n  type: String (public/private),\n  creator: ObjectId (ref: User),\n  members: [ObjectId] (ref: User),\n  createdAt: Date,\n  lastActivity: Date\n}\n```\n\n## 🎨 UI Features\n\n- **Modern gradient design** with purple/blue theme\n- **Smooth animations** for messages and interactions\n- **Responsive layout** adapts to screen size\n- **Real-time updates** without page refresh\n- **Typing indicators** show user activity\n- **Online user list** with avatars\n- **Message timestamps** for context\n- **System notifications** for user joins/leaves\n\n## 🔒 Security Best Practices\n\n1. **Password Security**\n   - Passwords are hashed using bcrypt with salt rounds\n   - Never stored in plain text\n\n2. **Authentication**\n   - JWT tokens expire after 7 days\n   - Tokens stored in localStorage (consider httpOnly cookies for production)\n   - Protected routes require valid token\n\n3. **Input Validation**\n   - Server-side validation using express-validator\n   - Sanitization of user inputs\n\n4. **Environment Variables**\n   - Sensitive data stored in .env file\n   - .env file excluded from version control\n\n## 🚀 Deployment\n\n### Deploy to Heroku\n\n1. Create a Heroku app:\n```bash\nheroku create your-app-name\n```\n\n2. Set environment variables:\n```bash\nheroku config:set JWT_SECRET=your_secret_key\nheroku config:set MONGODB_URI=your_mongodb_connection_string\n```\n\n3. Deploy:\n```bash\ngit push heroku main\n```\n\n### Deploy Frontend to Vercel/Netlify\n\nBuild the React app and deploy the `client/build` directory.\n\n### Database Hosting\n\nConsider using [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) for cloud-hosted MongoDB.\n\n## 🧪 Testing\n\nThis project includes comprehensive test coverage for both backend and frontend.\n\n### Test Summary\n- ✅ **6 tests passing**\n- ✅ **Backend:** 4 tests (Authentication API)\n- ✅ **Frontend:** 2 tests (Login Component)\n- ✅ **Code Coverage:** 51.61% overall, 74% for auth routes\n\n### Run Tests\n\n```bash\n# Run backend tests\nnpm run test:backend\n\n# Run frontend tests\ncd client\nnpm test -- --watchAll=false\n\n# Run all tests\nnpm run test:all\n```\n\n### Test Details\nSee [TESTING.md](./TESTING.md) for complete test documentation including:\n- Detailed test case descriptions\n- Expected results and assertions\n- Code coverage reports\n- Instructions for adding new tests\n\n---\n\n## 🔄 CI/CD Pipeline\n\nThis project uses **GitHub Actions** for continuous integration and deployment.\n\n### Automated Checks\nThe CI pipeline runs automatically on every push and pull request:\n\n✅ **Backend Tests** - Jest + Supertest unit tests  \n✅ **Frontend Tests** - React Testing Library component tests  \n✅ **Build Verification** - Ensures React app builds successfully  \n✅ **Code Linting** - ESLint checks for code quality  \n✅ **Multi-Version Testing** - Tests on Node.js 18.x and 20.x\n\n### Workflow Status\n![CI Status](https://github.com/Anoop-2024si96509/Realtime-chat-app/workflows/CI%20-%20Tests%20and%20Lint/badge.svg)\n\n### Run Linting Locally\n\n```bash\n# Backend linting\nnpm run lint:backend\n\n# Frontend linting\ncd client && npm run lint\n\n# Auto-fix linting issues\nnpm run lint:fix\ncd client && npm run lint:fix\n```\n\n### CI/CD Documentation\nSee [CI_CD_DOCUMENTATION.md](./CI_CD_DOCUMENTATION.md) for:\n- Complete workflow configuration\n- Job details and dependencies\n- Troubleshooting guide\n- Best practices\n\n---\n\n## 📝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## 🤝 Acknowledgments\n\n- Socket.io for real-time communication\n- MongoDB for flexible data storage\n- React community for excellent documentation\n- All contributors who participate in this project\n\n## 📧 Contact\n\nFor questions or support, please open an issue on GitHub.\n\n---\n\n**Happy Chatting! 💬🚀**\n","readmeFilename":"README.md","homepage":"https://github.com/Anoop-2024si96509/Realtime-chat-app#readme","repository":{"type":"git","url":"git+https://github.com/Anoop-2024si96509/Realtime-chat-app.git"},"bugs":{"url":"https://github.com/Anoop-2024si96509/Realtime-chat-app/issues"}}