A full-stack real-time chat application built with React, Node.js, Express, Socket.IO, and MongoDB.
- Node.js v18+
- npm
- MongoDB Atlas account or local MongoDB
- Cloudinary account for media uploads
- SendGrid account for email notifications
- Groq API key for AI assistant features
- Giphy API key for GIF search
cd NexChatcd backend
npm installCreate or edit backend/.env and fill in your credentials:
PORT=10000
MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/nexus-chat
JWT_SECRET=your_super_secret_key_here
JWT_EXPIRE=30d
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
EMAIL_FROM=your_verified_sender_email@example.com
EMAIL_FROM_NAME=Nexus Chat
EMAIL_REPLY_TO=support@example.com
SENDGRID_API_KEY=your_sendgrid_api_key
GROQ_API_KEY=your_groq_api_key
GROQ_MODEL=llama-3.3-70b-versatile
CLIENT_URL=http://localhost:3000
CLIENT_URLS=http://localhost:3000Start the backend:
npm run devor:
npm startBackend runs on:
http://localhost:10000
Open a new terminal:
cd frontend
npm installCreate or edit frontend/.env:
REACT_APP_API_URL=http://localhost:10000/api
REACT_APP_SOCKET_URL=http://localhost:10000
REACT_APP_GIPHY_API_KEY=your_giphy_api_key
REACT_APP_TURN_URL=turn:your-turn-server.com:3478
REACT_APP_TURN_USERNAME=your_turn_username
REACT_APP_TURN_CREDENTIAL=your_turn_passwordStart the frontend:
npm startFrontend runs on:
http://localhost:3000
| Feature | Status |
|---|---|
| Real-time messaging with Socket.IO | ✅ |
| JWT authentication | ✅ |
| 1-on-1 and group chats | ✅ |
| Typing indicators | ✅ |
| Read receipts | ✅ |
| Emoji reactions | ✅ |
| Reply, edit, and delete messages | ✅ |
| Pin messages | ✅ |
| File and image sharing with Cloudinary | ✅ |
AI assistant with @AI mentions |
✅ |
| Email notifications for offline users | ✅ |
| Scheduled messages | ✅ |
| Disappearing messages with MongoDB TTL | ✅ |
| Multi-device support | ✅ |
| Voice and video calls with WebRTC | ✅ |
| Screen sharing | ✅ |
| Online and offline status | ✅ |
| Analytics dashboard | ✅ |
| Dark UI | ✅ |
NexChat/
|-- backend/ # Node.js + Express + Socket.IO
| |-- controllers/
| |-- models/ # Mongoose schemas
| |-- routes/
| |-- middleware/
| |-- sockets/
| |-- utils/ # email, AI, cloudinary, scheduler
| `-- server.js
|-- frontend/ # React + Tailwind CSS
| `-- src/
| |-- components/
| |-- context/
| |-- hooks/
| |-- pages/
| |-- services/
| `-- utils/
`-- README.md
POST /api/auth/signup
POST /api/auth/login
GET /api/auth/me
GET /api/users Search users
PUT /api/users/profile Update profile
POST /api/users/upload-avatar
POST /api/chats Create or get 1:1 chat
GET /api/chats Get all user chats
GET /api/chats/:id
PUT /api/chats/:id/mute
GET /api/messages/:chatId Get messages
POST /api/messages Send message
PUT /api/messages/:id Edit message
DELETE /api/messages/:id Delete message
GET /api/messages/search Search messages
PUT /api/messages/:id/pin Pin message
POST /api/groups Create group
PUT /api/groups/:id/add Add group member
PUT /api/groups/:id/remove Remove group member
PUT /api/groups/:id/promote Promote group member
DELETE /api/groups/:id Delete group
POST /api/messages/upload Upload media
| Event | Direction | Description |
|---|---|---|
sendMessage |
client to server | Send a message |
receiveMessage |
server to client | Receive a message |
typing / stopTyping |
client to server | Typing indicators |
userTyping / userStopTyping |
server to client | Broadcast typing status |
messageRead |
client to server | Mark a message as seen |
addReaction / removeReaction |
client to server | Emoji reactions |
callUser / answerCall / endCall |
bidirectional | WebRTC signaling |
iceCandidate |
bidirectional | ICE candidates |
Type @AI or @ai at the start of any message to invoke the AI assistant.
Example:
@AI What is the capital of France?
This feature requires GROQ_API_KEY in backend/.env.
cd frontend
npm run buildPush the project to GitHub, then connect the frontend folder to Vercel.
Set these frontend environment variables in Vercel:
REACT_APP_API_URL=https://your-backend-url/api
REACT_APP_SOCKET_URL=https://your-backend-url
REACT_APP_GIPHY_API_KEY=your_giphy_api_key
REACT_APP_TURN_URL=turn:your-turn-server.com:3478
REACT_APP_TURN_USERNAME=your_turn_username
REACT_APP_TURN_CREDENTIAL=your_turn_passwordUse these settings:
Build command: npm install
Start command: node server.js
Set all backend .env variables in the hosting dashboard.
- Create a free cluster at MongoDB Atlas.
- Whitelist your deployment IPs, or use
0.0.0.0/0for quick testing. - Copy the connection string to
MONGO_URI.
MONGO_URIis required in production.JWT_SECRETshould be long, random, and private.EMAIL_FROMmust be a verified SendGrid sender.- For best inbox delivery, authenticate your sending domain in SendGrid and add the SPF/DKIM DNS records SendGrid gives you. Add a DMARC record for the same domain, and use an
EMAIL_FROMaddress on that authenticated domain instead of a free Gmail/Yahoo/Outlook address. EMAIL_FROM_NAMEis the sender display name shown in inboxes.EMAIL_REPLY_TOshould be an address on the same verified domain.SENDGRID_API_KEYis required for email notifications.CLOUDINARY_*values are required for file and image sharing.GROQ_API_KEYis required for AI assistant features.CLIENT_URLshould point to the frontend URL.CLIENT_URLScan hold allowed frontend origins if multiple client URLs are supported.- React environment variables must start with
REACT_APP_. REACT_APP_TURN_*values are optional, but strongly recommended for mobile WebRTC calls on carrier networks.
Never commit real .env values to Git. If any database credentials, API keys, or JWT secrets have been exposed, rotate them immediately in MongoDB Atlas, Cloudinary, SendGrid, Groq, and any other affected service.