How jacobo0312/whatsappclient works
Main Components
• Entry Point (app.ts): This component sets up the Express server and defines the port and middleware. It acts as the entry point for all incoming HTTP requests.
• Controller (controller.ts): This module is responsible for defining the API endpoints (GET /sendMessage, GET /isAuthenticated, GET /getQr) and delegating the appropriate business logic.
• WhatsApp Client (WhatsAppClient.ts): This is the core logic that handles the interaction with the WhatsApp Web API, using a singleton pattern to ensure only one instance exists.
• External WhatsApp Web API: Represent this as an external system that the WhatsAppClient interacts with to perform actions like sending messages and retrieving the QR code.
Relationships and Data Flow
• The Controller processes the requests and delegates them to the WhatsApp Client for the actual interaction with the WhatsApp Web API.
• The WhatsApp Client then makes calls to the external WhatsApp Web API (authentication, sending messages, retrieving data) and returns responses back up the chain.
• Finally, responses are delivered back to the client that made the HTTP request.
Important Design Patterns and Technologies
• Express.js for HTTP Server: Highlight that the Express framework manages incoming API requests.
• TypeScript: Mark the project as TypeScript-based, emphasizing type safety and maintainability.
• REST API: Indicate the architectural style used for exposing operations (e.g., GET endpoints).
• Optionally, include notes on important configurations (like the use of TypeScript, ESLint, and Prettier for code quality, even though they are helper tools rather than major architectural elements).