A messaging app that allows users to send messages to each other.
π οΈ Tech Stack
Frontend: React (with Context API)
Backend: Node.js, Express.js
Database: MongoDB + Mongoose
Realtime: Socket.IO (WebSocket-based)
Auth: JWT (JSON Web Tokens)
Styling: CSS Modules + CSS Variables (Dark/Light Mode)
Uploads: Multer (local or Cloudinary)
π Development Roadmap (Testable Per Step) β Step 1: Project Setup
Create monorepo: client/ + server/
Enable ESM ("type": "module")
Setup .env files for sensitive config
Setup basic dev script (nodemon, concurrently)
π Test: Console logs run from both client and server β Step 2: Express Server + MongoDB
Install core backend deps: express, mongoose, cors, dotenv
Connect to MongoDB using Mongoose
Create User model schema
π Test: Server runs β DB connects β sample user saved β Step 3: Authentication System (JWT)
Install: bcrypt, jsonwebtoken
Create /auth/register and /auth/login routes
Hash passwords with bcrypt
Issue JWT tokens on login
Protect routes with verifyToken middleware
π Test: Register & login via Postman β secure /profile route β Step 4: React Frontend + Auth Context
Setup React app with axios, react-router-dom
Build AuthContext to manage JWT & user state
Forms for Register & Login
π Test: Register/login from frontend β store token β redirect on success β Step 5: Setup Socket.IO
Backend: Attach Socket.IO to HTTP server
Frontend: Connect using socket.io-client
Store socket connection in context
π Test: Open console β see unique socket ID on connect β Step 6: Global Chat (One Room)
Emit/receive send_message + receive_message events
Display real-time message flow across tabs
π Test: Two tabs exchange messages instantly β Step 7: Private 1-to-1 Chat (DMs)
On login, map userId β socket.id
Add send_private_message handler (Socket.IO)
Check friendship or auth
Chat UI opens per user
π Test: Direct message goes only to the target user β Step 8: Group Chat / Room System
Create/join/leave named rooms
Use socket.join(room) and io.to(room).emit(...)
Chat messages scoped to room
π Test: Room messages are isolated between members β Step 9: Friends System
Create FriendRequest model
Routes: send request, accept, list friends
UI to search, add, and display friends
π Test: Only accepted friends can initiate private chats β Step 10: Image Messaging
Install multer
Backend: Accept image uploads
Store locally or with Cloudinary
Send image URLs via Socket.IO
Frontend: File input + preview
π Test: Upload and display image in chat bubble β Step 11: Online Users Indicator
Track online users in memory (userId β socket.id)
Broadcast presence on connect/disconnect
Frontend: Show real-time online list
π Test: Users appear/disappear in live sidebar as they connect β Step 12: Deploy (Final Step)
Backend: Render, Railway, or Fly.io
Frontend: Netlify or Vercel
Use CORS and environment configs
Confirm Socket.IO works cross-origin
π Test: All features work on live URLs across browsers π₯ Extra Features (Implemented for Credit)
π Dark/Light mode via [data-theme] and CSS variables
πΈ Image uploads and real-time rendering
π― Scheduled messages (optional enhancement)
π§ͺ Ephemeral threads (optional enhancement)
π‘οΈ Invisible mode / ghost reads (optional enhancement)
DiceBear for avatars: https://api.dicebear.com/7.x/adventurer/svg?seed=JohnDoe&radius=50&backgroundColor=ffd5ec