Encrypted. Private. Real-time.
A full-stack real-time chat application with end-to-end encryption, voice/video calls, group chats, social features, and more β built with the MERN stack and Socket.IO.
π Live: chatsphere-omega.vercel.app
- Real-time 1-on-1 and group messaging via Socket.IO
- End-to-End Encryption (E2E) β all messages encrypted with AES using CryptoJS
- Voice messages (hold-to-record)
- Image & file sharing
- Message unsend (for everyone)
- Message seen/delivered receipts (ββ)
- Typing indicators β shows who is typing in real time
- WhatsApp-style clear chat (only clears for you)
- Create groups with custom name and photo
- Group admin controls β add/remove members
- Group E2E encryption
- Real-time typing indicators in groups
- Group voice & video calls
- 1-on-1 voice calls (WebRTC)
- 1-on-1 video calls (WebRTC)
- Group calls
- Incoming call banner with accept/reject
- Register with email OTP verification (Resend)
- Login with email or @username
- JWT authentication (7-day tokens)
- Forgot password / reset via OTP
- Password hashing with bcryptjs (12 rounds)
- Rate limiting on messages and search
- Ping = Follow / Send follow request
- Unping = Unfollow
- Private accounts β require approval before following
- Accept / Decline follow requests
- Block / Unblock users
- Posts visible only to followers
- Notifications for pings, requests, and messages
- Avatar upload
- Bio (150 chars)
- Edit name, username
- View other user profiles
| Layer | Technology |
|---|---|
| Frontend | React 19, Vite, Socket.IO Client |
| Backend | Node.js, Express.js |
| Database | MongoDB Atlas + Mongoose |
| Real-time | Socket.IO |
| Auth | JWT + bcryptjs |
| Encryption | CryptoJS (AES E2E) |
| Resend | |
| File uploads | Multer |
| Calls | WebRTC |
| Deployment | Vercel (frontend) + Render (backend) |
ChatSphere uses real Data Structures & Algorithms for maximum performance:
| DSA | Usage |
|---|---|
| HashMap O(1) | userId β socketId online map, socket reverse lookup, DM dedup |
| LRU Cache | Message caching β invalidated on send/unsend/clear |
| Trie | User search β O(log n) prefix search, rebuilt on server start |
| FIFO Queue | Offline message delivery β flushed on reconnect |
| Token Bucket | Rate limiting β messages and search per user |
| Debounce HashMap | Typing indicators β 800ms debounce per user pair |
| Multi-tab Set | Each user has a Set<socketId> β supports multiple browser tabs |
chat-app/
βββ backend/
β βββ config/
β β βββ db.js # MongoDB connection
β βββ dsa/
β β βββ LRUCache.js # Message cache
β β βββ MessageQueue.js # Offline message queue
β β βββ RateLimiter.js # Token bucket rate limiter
β β βββ TrieSearch.js # User search trie
β βββ middleware/
β β βββ authMiddleware.js # JWT verification
β βββ models/
β β βββ Chat.js
β β βββ ConnectionRequest.js
β β βββ Group.js
β β βββ Message.js
β β βββ Post.js
β β βββ User.js
β βββ routes/
β β βββ admin.js
β β βββ auth.js # Register, login, OTP, reset
β β βββ chat.js # DMs, clear chat, file upload
β β βββ connections.js
β β βββ group.js # Groups, members, avatar
β β βββ posts.js
β β βββ profile.js
β β βββ user.js # Ping, unping, block, follow
β βββ utils/
β β βββ encryption.js # AES encrypt/decrypt helpers
β βββ server.js # Express + Socket.IO server
β
βββ frontend/
βββ public/
βββ src/
βββ components/
β βββ AdminPanel.jsx
β βββ Call.jsx
β βββ ChatList.jsx # Sidebar β DMs, groups, users
β βββ ChatWindow.jsx # Message view, voice, calls
β βββ Feed.jsx # Posts feed
β βββ Login.jsx
β βββ Notifications.jsx
β βββ Profile.jsx
β βββ Register.jsx
β βββ UserProfile.jsx
β βββ VideoCall.jsx
βββ services/
β βββ api.js # Axios instance
βββ App.jsx
βββ crypto.js # CryptoJS E2E helpers
βββ main.jsx
βββ socket.js # Socket.IO client
βββ style.css
- Node.js 18+
- MongoDB (local or Atlas)
git clone https://github.com/Sainikhil070304/chatsphere.git
cd chatspherecd backend
npm installCreate backend/.env
Start backend:
node server.jscd frontend
npm installCreate frontend/.env
Start frontend:
npm run devOpen http://localhost:
- Connect GitHub repo to Render
- Set Root Directory to
backend - Set Start Command to
node server.js - Add environment variables:
MONGO_URIJWT_SECRETCHAT_SECRETRESEND_API_KEYNODE_ENV=production
- Connect GitHub repo to Vercel
- Set Root Directory to
frontend - Add environment variables
All messages are encrypted before being sent to the server:
Sender β AES encrypt(message, CHAT_SECRET) β Server β Receiver β AES decrypt
- Server never sees plaintext messages
- Group messages use the same shared secret
- Audio/image messages are stored encrypted
| Event | Direction | Description |
|---|---|---|
online |
clientβserver | User comes online |
send |
clientβserver | Send a message |
receive |
serverβclient | Receive a message |
typing |
clientβserver | User is typing |
stopTyping |
clientβserver | User stopped typing |
seen |
clientβserver | Message seen |
unsend |
clientβserver | Unsend a message |
call:offer |
clientβserver | Initiate a call |
call:incoming |
serverβclient | Notify callee |
call:answer |
clientβserver | Accept call |
call:end |
clientβserver | End call |
- Real-time messaging with E2E encryption
- Group chats with admin controls
- Voice & video calls (WebRTC)
- Voice messages
- OTP email verification
- Social features (ping/unping/block/follow)
- Group photo upload
- Typing indicators
- Message seen/delivered
- Clear chat
- Deploy to Vercel + Render
- Push notifications
- Message reactions
- Stories
- Admin dashboard
Sai Nikhil Nallela
- GitHub: @Sainikhil070304