How vinayak409/whatsapp-clone-mern-stack works
Project type and purpose
• This is a real-time chat application (“WhatsApp clone”) built with the MERN stack plus a dedicated Socket.io service.
• It consists of three distinct services:
a. Frontend (React + Material-UI SPA)
b. Backend API (Node.js + Express + MongoDB, following an MVC-style controllers/models structure)
c. Socket service (Node.js + Socket.io for real-time messaging, typing indicators, online/offline status)
• Docker Compose glues them together along with a MongoDB container.
File structure
• Top level:
• client/ → React app (public/, src/ with components, context, service/api.js)
• server/ → Express API (controllers/, model/, routes/, database connection, Docker Compose file)
• socket/ → standalone Socket.io server (index.js)
• server/docker-compose.yml defines four services: server, client, socket, and MongoDB.
• server follows MVC: model files in server/model, controllers in server/controller, routes in server/routes.
• client uses React Context (AccountProvider) to hold user state and service/api.js for REST calls.
Key insights from README
• Real-time chat powered by Socket.io.
• REST endpoints handle user auth, search, conversations, messages, image upload.
• MongoDB provides persistence for users, conversations, messages.
• Docker or npm scripts can bring up the full stack.
a. Main components
1. React Frontend
2. Express REST API
3. Socket.io Server
4. MongoDB Database
5. (Optional) Image storage (local disk or cloud via server/utils/upload.js)
6. Docker Compose (orchestration)
b. Relationships & data flows
• Frontend ←HTTP/HTTPS→ Express API
• Authentication, user search, conversation history, image uploads
• Frontend ↔WebSocket (Socket.io)↔ Socket Server
• Real-time message delivery, typing indicators, presence updates
• Express API ↔MongoDB
• CRUD operations for User, Conversation, Message models
• Socket Server ↔MongoDB (or via Express)
• Could save messages directly or emit to API for persistence
c. Architectural patterns & design principles
• Microservice-style separation: distinct API and real-time services
• MVC in the backend: controllers/models/routes
• Single-page application with React Context for global state
• Docker Compose for service orchestration and environment parity
d. Technologies & frameworks
• Frontend: React.js, Material-UI, socket.io-client
• Backend API: Node.js, Express.js, Mongoose (MongoDB ODM), Multer (for uploads)
• Real-time: Socket.io server
• Persistence: MongoDB (Dockerized)
• Orchestration: Docker, Docker Compose
Detail
• Every container/service in Docker Compose.
• Detail the data flows for user login, message send/receive, presence updates, image upload.
• Don’t over-complicate—focus on the four main services and how they interact.