How ayushkul/whatsapp-clone works
Project type and purpose
• This is a full-stack WhatsApp-style chat application clone.
• Frontend: a React single-page application (SPA) providing login, contact list, and conversation UIs.
• Backend: a Node.js/Express server implementing RESTful endpoints (and potentially WebSocket support) with an MVC-style structure and a connection to a document database (e.g., MongoDB) for users and channels.
File structure
Top-level:
• client/ – React app
– public/ – static assets and index.html
– src/ – source code
• components/ – ContactListComponent, ConversationComponent
• managers/ – cookieManager, httpManager (abstractions for auth token storage and API calls)
• modules/login – login page logic
• mockData, utility – helpers for mocks and shared utilities
• server/ – Node/Express API
– app/controllers – request handlers
– app/models – data schemas (channel.js, user.js)
– routes – mapping URLs to controllers
– config – environment and port settings
– dbConnection – database initialization
– utility/validator – input validation
– server.js – entry point
README
• Confirms a deployed demo and tutorial links.
a. Main components
1. Frontend (React SPA)
• UI Components (ContactListComponent, ConversationComponent)
• State & API managers (cookieManager, httpManager)
2. Backend (Express API)
• Routes layer
• Controllers (business logic)
• Models (data schemas)
• Config & Utilities
3. Database (e.g., MongoDB)
4. (Optional) Real-time transport (WebSockets/Socket.io) if implemented
5. External services (if any, e.g., authentication provider, file storage)
b. Relationships & interactions
• React components invoke httpManager → Express endpoints (login, fetch contacts, send/receive messages).
• cookieManager stores JWT or session tokens, attached to outgoing requests.
• Express routes forward requests to controllers → controllers use models to read/write DB via dbConnection.
• DB returns data, controllers format and send HTTP (or WS) responses back to client.
• (If using WebSockets) a persistent socket channel for real-time message delivery.
c. Architectural patterns
• Client: component-based UI, separation of concerns via “managers” and “modules.”
• Server: MVC-inspired layering (Routes → Controllers → Models).
• Configuration and environment kept separate in config/.
• Single responsibility for utilities (validator, dbConnection).
d. Key technologies
• React, React Router (implied), JavaScript modules.
• cookieManager & httpManager abstractions for API calls and auth.
• Node.js, Express.js, RESTful routing.
• Mongoose or similar ODM for user/channel models.
• MongoDB (or any document store).
• Optional real-time library (Socket.io) for bi-directional messaging.
Detail
• Config and utility layers that affect initialization and validation.
• Auth flow: login module → httpManager → auth route → controller → token issued → cookieManager stores it → subsequent API calls include the token.