# bagussundaru/mcp-server-client-wa architecture

> Architecture diagram of the GitHub repository bagussundaru/mcp-server-client-wa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bagussundaru/mcp-server-client-wa
- Repository: https://github.com/bagussundaru/mcp-server-client-wa

## Overview

##### Project type and purpose
- This is an n8n-based integration “tool” (an open-source workflow orchestration project) that connects WhatsApp (via Business API or Twilio) to an AI assistant (OpenRouter), plus optional services (translator, calculator, scheduler), and persists conversation context in a database.

##### File structure
- Top-level files are JSON exports of n8n workflows:
- ai-agent-wa-ultimate-n8n.json
- mcp_client_workflow.json
- mcp_server_workflow.json
- README.md describes how to import these workflows into an n8n instance, configure credentials, set up webhooks, error catching, and additional features (translation, search, reminders).
- No traditional “src” or “lib” folders since n8n workflows are authored via GUI and stored as JSON.

##### README for additional insights
- Workflow “MCP WhatsApp Integration” is composed of:
- Trigger nodes (Webhook for incoming WhatsApp messages)
- HTTP Request nodes (to WhatsApp Business API or Twilio)
- AI Assistant node (calls OpenRouter)
- Tools Router node (dispatches to calculator, translator, scheduler, or AI)
- DB nodes (MongoDB/MySQL) to store and retrieve conversation history
- Error Catcher node for graceful error handling
- Credentials setup, ngrok for local tunneling, and production deployment notes (Railway, DigitalOcean).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Inbound Trigger
    subgraph "Inbound Trigger"
        A["WhatsApp User"]:::external
        B["MCP Server Trigger"]:::node
    end

    %% Routing & Business Logic
    subgraph "Routing & Business Logic"
        C["Tools Router"]:::router
        D["Calculator Node"]:::node
        E["Translator API"]:::external
        F["Scheduler Service"]:::external
        G["AI Assistant"]:::external
        H["Error Catcher"]:::error
    end

    %% Persistence
    subgraph "Persistence"
        I["DB Nodes"]:::db
    end

    %% Outbound Response
    subgraph "Outbound Response"
        J["MCP Client Workflow"]:::node
    end

    %% Data Flows
    A -->|"Incoming Message"| B
    B --> C
    C -->|"calculate intent"| D
    C -->|"translate intent"| E
    C -->|"schedule intent"| F
    C -->|"default AI"| G
    D --> I
    E --> I
    F --> I
    G --> I
    I --> J
    J -->|"Send to WhatsApp API"| A

    %% Error Handling
    B -.-> H
    C -.-> H
    D -.-> H
    E -.-> H
    F -.-> H
    G -.-> H
    I -.-> H
    J -.-> H

    %% Click Events
    click B "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/mcp_server_workflow.json"
    click J "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/mcp_client_workflow.json"
    click C "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/ai-agent-wa-ultimate-n8n.json"
    click G "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/ai-agent-wa-ultimate-n8n.json"
    click H "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/ai-agent-wa-ultimate-n8n.json"
    click I "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/ai-agent-wa-ultimate-n8n.json"
    click README "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/README.md"
    click SETUP "https://github.com/bagussundaru/mcp-server-client-wa/blob/main/SETUP-WHATSAPP-AI-AGENT-N8N.md"

    %% Styles
    classDef external fill:#ADD8E6,stroke:#000;
    classDef node fill:#90EE90,stroke:#000;
    classDef router fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef db fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef error fill:#f08080,stroke:#000;
```
