How diazzaid/whatsapp-api-venom works
Project type and purpose
• This is a full-stack HTTP API server built with NestJS (TypeScript) that wraps the Venom library to expose WhatsApp messaging features over REST.
• The README confirms it serves Swagger/OpenAPI docs and implements controllers for sending messages, screenshots, device info, etc.
File structure
• Top-level:
• package.json, tsconfig.json, nest-cli.json – show Node/NestJS configuration
• docs/ – static Swagger UI and OpenAPI spec
• examples/ – client-side Python curl example
• src/ – the NestJS application
• src/api: controllers for each REST resource (chatting.controller.ts, screenshot.controller.ts, device.controller.ts) and a DTO file.
• src/whatsapp.service.ts: encapsulates calls to the Venom library.
• src/config.service.ts: holds environment-specific paths (e.g., token storage).
• src/app.module.ts and src/main.ts: NestJS module and entrypoint.
Key insights from README
• Project serves on http://localhost:3000, auto-generates Swagger UI under docs.
• Uses Venom to spawn a headless browser session for WhatsApp Web, stores session tokens on disk.
• Exposes endpoints for messaging, media, contacts, screenshots, and more.
Main components
a. API Gateway (NestJS HTTP server)
• Controllers layer (ChattingController, DeviceController, ScreenshotController)
• Service layer (WhatsappService)
• ConfigService for environment and file‐path settings
b. Venom Library
• Underlying WhatsApp Web headless-browser client
c. Token Storage
• Local file system directory (e.g., /tmp/whatsapp-files or Windows path)
d. Swagger UI / OpenAPI Docs
• Static files served from docs/
e. Clients
• curl/HTTP clients, Swagger UI browser, example Python script
Relationships and interactions
• Client → HTTP request → NestJS Controller → calls WhatsappService → Venom API → WhatsApp Web
• Venom API reads/writes session tokens in file system
• NestJS serves Swagger UI assets and OpenAPI JSON from docs/
• ConfigService injects environment‐specific settings into WhatsappService
Architectural patterns & design principles
• Layered pattern: Controllers → Services → External Library
• Dependency Injection (NestJS modules/services)
• Configuration-as-Service (ConfigService)
• DTOs for request validation
Technologies & frameworks
• Node.js + NestJS (TypeScript)
• Venom (WhatsApp Web automation)
• Swagger/OpenAPI for documentation
• File system for token persistence