# daggieblanqx/whatsappcloudapi_wrapper architecture

> Architecture diagram of the GitHub repository daggieblanqx/whatsappcloudapi_wrapper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/daggieblanqx/whatsappcloudapi_wrapper
- Repository: https://github.com/daggieblanqx/whatsappcloudapi_wrapper

## Overview

##### Main Components

a. Client Application Layer
- How external applications integrate with the wrapper
- Initialization with required parameters (accessToken, senderPhoneNumberId, WABA_ID)

b. WhatsApp Cloud API Wrapper Core (Main Interface)
- Main WhatsappCloudAPI class
- Two primary functional groups:
- Outbound Messages Handler
- Inbound Messages Parser

c. WhatsApp Cloud API (External Service)
- Meta's official WhatsApp Business API
- Cloud infrastructure

##### Component Relationships

**[Client Application]**
- ↕
**[WhatsApp Cloud API Wrapper]**
- Outbound Handler
- Text Messages
- Media Messages
- Interactive Messages
- Utility Functions

- Inbound Parser
- Message Parser
- Notification Parser
- ↕
**[WhatsApp Cloud API (Meta)]**

##### Important Details to Highlight

a. Message Types Support:
- Text messages
- Media messages (images, documents, audio, video)
- Interactive messages (buttons, lists)
- Location messages
- Contacts
- QR codes

b. Key Processes:
- Message sending flow
- Message parsing flow
- Webhook handling
- File handling (local vs URL-based)

##### Technical Specifications

- Node.js environment
- REST API communication
- Webhook endpoints
- File system interaction points

##### Implementation Notes

- Version information
- Rate limits and constraints
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application Layer"]
        CA[Client Application]
        Init[Initialization<br>accessToken, senderPhoneNumberId, WABA_ID]
    end

    subgraph Wrapper["WhatsApp Cloud API Wrapper"]
        Core["WhatsApp Cloud API Wrapper Core"]:::core
        
        subgraph Outbound["Outbound Messages Handler"]
            Text["Text Messages"]
            Media["Media Messages"]
            Interactive["Interactive Messages"]
            Utils["Utility Functions"]
        end
        
        subgraph Inbound["Inbound Messages Handler"]
            MsgParser["Message Parser"]:::parser
            NotifParser["Notification Parser"]:::parser
        end
    end

    subgraph External["External Services"]
        WhatsAppAPI["WhatsApp Cloud API (Meta)"]
        StaticFiles["Static Resources"]:::static
    end

    %% Connections
    CA --> Init
    Init --> Core
    Core --> Outbound
    Core --> Inbound
    Text --> WhatsAppAPI
    Media --> WhatsAppAPI
    Interactive --> WhatsAppAPI
    Utils --> WhatsAppAPI
    WhatsAppAPI --> MsgParser
    WhatsAppAPI --> NotifParser
    Media --> StaticFiles
    
    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef parser fill:#2ecc71,stroke:#27ae60,color:white
    classDef static fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    
    %% Click events
    click Core "https://github.com/DaggieBlanqx/whatsappcloudapi_wrapper/blob/main/index.js"
    click MsgParser "https://github.com/DaggieBlanqx/whatsappcloudapi_wrapper/blob/main/msg_parser.js"
    click StaticFiles "https://github.com/DaggieBlanqx/whatsappcloudapi_wrapper/tree/main/static_files"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Parsers"]:::parser
        L3["Static Resources"]:::static
        L4["External Services"]:::external
    end
```
