How aldinokemal/go-whatsapp-web-multidevice works
Based on our analysis of the file tree and the README, this project is a Golang-based backend for a WhatsApp Multi Device API with both REST and WebSocket interfaces. It is designed as an API server that provides endpoints to manage WhatsApp sessions, send various types of messages, handle groups, users, newsletters, and more. Additionally, it contains front-end components (views and static assets) for user interactions as well as Docker and CI/CD configurations for building and deploying releases.
Main Components
• API Server – This is the centralized core of the system, handling incoming HTTP requests and WebSocket connections.
• REST API Layer – Located under src/internal/rest, this layer exposes endpoints (e.g., /app/*, /user/*, /send/*, /group/*, /message/*) which interact with the business logic.
• WebSocket Handler – Under src/internal/websocket, this component manages persistent connections for real-time messaging.
• Domain/Business Logic – Under src/domains and src/services, you have the business rules for each functional area (app, user, message, group, newsletter, send). This separation indicates a domain-driven design, where the “domains” package holds core models and the “services” package orchestrates use cases.
• Utility and Library Layer – The src/pkg folder encompasses common utility functions, error handling (error types for app, validation, WhatsApp-specific errors), and WhatsApp client initialization/wrappers.
• Configuration – The src/config and environment files (.env.example) support multi-layered configuration through command-line flags, environment variables, and .env files.
• Frontend/UI – The src/views directory contains HTML and JavaScript (React-like components) for rendering the user interface (login, send messages, group management, etc.).
• Documentation & API Specification – The docs folder, especially docs/openapi.yaml, details the API schema for client generation and integration.
• Deployment – Docker-related files (docker-compose.yml, docker files, GitHub workflows) indicate that the system is containerized and built via CI/CD pipelines.
Relationships and Interactions
• External Clients (Web browsers, mobile apps, API consumers) interact with the API server via REST endpoints and WebSockets.
• REST Controllers (located in src/internal/rest) call the corresponding Service functions (src/services) which in turn leverage Domain Models (src/domains) and Utility packages (src/pkg).
• The authentication process, basic auth middleware and environment configuration ensure secure, configurable endpoints.
• The UI (src/views) serves static assets for a web-based interface to interact with the API.
• CI/CD and containerization components (GitHub workflows and Docker files) facilitate automated building, testing, and deployment.
Architectural Patterns & Design Principles
• Layered Architecture: The project shows a clear separation of concerns (API layer → Service layer → Domain models & utilities). This improves maintainability and scalability.
• Domain-Driven Design: The “domains” folder indicates the encapsulation of business logic in discrete, functionally organized modules.
• Configuration Priority: There’s a defined priority for configuration using command-line flags, environment variables, and .env files.
• Containerization: Use of Docker and docker-compose along with CI/CD workflows shows an emphasis on reproducible builds and deployments.
• RESTful & Event-driven Communication: With defined REST endpoints and a WebSocket component, the system uses both synchronous and real-time communication.
Relevant Technologies, Frameworks, and Libraries
• Golang as the core language.
• Docker for containerization.
• GitHub Actions for CI/CD.
• ffmpeg (as an external dependency on supported OS) for media processing.
• Swagger/OpenAPI (docs/openapi.yaml) for API specification.
• Web technologies (HTML, JavaScript, and CSS) for the front-end.
• The top level represents the Client/UI layer.
• The middle level represents the API gateway – the REST endpoints and WebSocket handler.