# remsystem-official/whatsapp-ia architecture

> Architecture diagram of the GitHub repository remsystem-official/whatsapp-ia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/remsystem-official/whatsapp-ia
- Repository: https://github.com/remsystem-official/whatsapp-ia

## Overview

This is a WhatsApp support bot. A user message enters through the WhatsApp client and chat controller, which routes recognized commands to command handlers or sends ordinary text to the Groq response service. The bot also provides fixed help and fetches user listings from an external API. The graph reflects the sampled source and README; the external API endpoint and Groq service are documented/configured, but their runtime details beyond the shown calls are not inferred.

Main entry points: [`controllers/ChatController.js`](https://github.com/remsystem-official/whatsapp-ia/blob/main/controllers/ChatController.js) (Chat Controller), [`commands/handler/command.handler.js`](https://github.com/remsystem-official/whatsapp-ia/blob/main/commands/handler/command.handler.js) (Command Router), [`services/groq/Groq.service.js`](https://github.com/remsystem-official/whatsapp-ia/blob/main/services/groq/Groq.service.js) (Groq Response Service), [`index.js`](https://github.com/remsystem-official/whatsapp-ia/blob/main/index.js) (Bot Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot Runtime"]
  node_entry["Bot Entry<br/>[index.js]"]
  node_client["WhatsApp Client<br/>[whatsapp-client.js]"]
  node_chat["Chat Controller<br/>[ChatController.js]"]
end

subgraph group_commands["Command Handling"]
  node_command_types["Command Types<br/>[commands.const.js]"]
  node_router["Command Router<br/>[command.handler.js]"]
  node_help["Help Reply<br/>[help.command.js]"]
  node_users["User Listing<br/>[users.command.js]"]
end

subgraph group_ai["AI Responses"]
  node_rules["Assistant Rules<br/>[rules.txt]"]
  node_groq_service["Groq Response Service<br/>[Groq.service.js]"]
end

subgraph group_api["User Data API"]
  node_api_service["JSONPlaceholder Service"]
  node_axios["HTTP Client Config<br/>[axios.config.js]"]
end

node_user(("WhatsApp User"))
node_whatsapp{{"WhatsApp"}}
node_groq_api{{"Groq API"}}
node_user_api{{"External User API"}}

node_entry -->|"loads"| node_client
node_entry -->|"creates"| node_chat
node_entry -->|"initializes"| node_client
node_client -->|"connects"| node_whatsapp
node_user -.->|"messages"| node_whatsapp
node_whatsapp -.->|"delivers messages"| node_chat
node_chat -->|"checks commands"| node_command_types
node_chat -->|"dispatches commands"| node_router
node_chat -->|"requests replies"| node_groq_service
node_router -->|"uses command types"| node_command_types
node_router -->|"dispatches help"| node_help
node_router -->|"dispatches support"| node_users
node_help -->|"replies"| node_user
node_users -->|"fetches users"| node_api_service
node_users -->|"replies"| node_user
node_groq_service -->|"loads rules"| node_rules
node_groq_service -->|"requests completion"| node_groq_api
node_groq_service -.->|"returns reply via chat"| node_user
node_api_service -->|"sends requests"| node_axios
node_axios -.->|"requests user data"| node_user_api

click node_entry "https://github.com/remsystem-official/whatsapp-ia/blob/main/index.js"
click node_client "https://github.com/remsystem-official/whatsapp-ia/blob/main/config/whatsapp-client.js"
click node_chat "https://github.com/remsystem-official/whatsapp-ia/blob/main/controllers/ChatController.js"
click node_command_types "https://github.com/remsystem-official/whatsapp-ia/blob/main/common/constanst/commands.const.js"
click node_router "https://github.com/remsystem-official/whatsapp-ia/blob/main/commands/handler/command.handler.js"
click node_help "https://github.com/remsystem-official/whatsapp-ia/blob/main/commands/help.command.js"
click node_users "https://github.com/remsystem-official/whatsapp-ia/blob/main/commands/users.command.js"
click node_rules "https://github.com/remsystem-official/whatsapp-ia/blob/main/rules.txt"
click node_groq_service "https://github.com/remsystem-official/whatsapp-ia/blob/main/services/groq/Groq.service.js"
click node_api_service "https://github.com/remsystem-official/whatsapp-ia/blob/main/services/api/jsonPlaceholder.service.js"
click node_axios "https://github.com/remsystem-official/whatsapp-ia/blob/main/config/axios.config.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_client,node_chat,node_user,node_user_api toneBlue
class node_command_types,node_router,node_help,node_users toneAmber
class node_rules,node_groq_service,node_groq_api toneMint
class node_api_service,node_axios toneRose
class node_whatsapp toneIndigo
```

## Components

### Bot Runtime

- [Bot Entry](https://github.com/remsystem-official/whatsapp-ia/blob/main/index.js): `index.js`
- [WhatsApp Client](https://github.com/remsystem-official/whatsapp-ia/blob/main/config/whatsapp-client.js): `config/whatsapp-client.js`
- [Chat Controller](https://github.com/remsystem-official/whatsapp-ia/blob/main/controllers/ChatController.js): `controllers/ChatController.js`

### Command Handling

- [Command Types](https://github.com/remsystem-official/whatsapp-ia/blob/main/common/constanst/commands.const.js): `common/constanst/commands.const.js`
- [Command Router](https://github.com/remsystem-official/whatsapp-ia/blob/main/commands/handler/command.handler.js): `commands/handler/command.handler.js`
- [Help Reply](https://github.com/remsystem-official/whatsapp-ia/blob/main/commands/help.command.js): `commands/help.command.js`
- [User Listing](https://github.com/remsystem-official/whatsapp-ia/blob/main/commands/users.command.js): `commands/users.command.js`

### AI Responses

- [Assistant Rules](https://github.com/remsystem-official/whatsapp-ia/blob/main/rules.txt): `rules.txt`
- [Groq Response Service](https://github.com/remsystem-official/whatsapp-ia/blob/main/services/groq/Groq.service.js): `services/groq/Groq.service.js`

### User Data API

- [JSONPlaceholder Service](https://github.com/remsystem-official/whatsapp-ia/blob/main/services/api/jsonPlaceholder.service.js): `services/api/jsonPlaceholder.service.js`
- [HTTP Client Config](https://github.com/remsystem-official/whatsapp-ia/blob/main/config/axios.config.js): `config/axios.config.js`

### Other components

- **WhatsApp User**
- **WhatsApp**
- **Groq API**
- **External User API**

## Connections

- Bot Entry → WhatsApp Client: loads (evidence: `index.js`)
- Bot Entry → Chat Controller: creates (evidence: `index.js`)
- Bot Entry → WhatsApp Client: initializes (evidence: `index.js`)
- WhatsApp Client → WhatsApp: connects (evidence: `config/whatsapp-client.js`)
- WhatsApp User → WhatsApp: messages
- WhatsApp → Chat Controller: delivers messages
- Chat Controller → Command Types: checks commands (evidence: `controllers/ChatController.js`)
- Chat Controller → Command Router: dispatches commands (evidence: `controllers/ChatController.js`)
- Chat Controller → Groq Response Service: requests replies (evidence: `controllers/ChatController.js`)
- Command Router → Command Types: uses command types (evidence: `commands/handler/command.handler.js`)
- Command Router → Help Reply: dispatches help (evidence: `commands/handler/command.handler.js`)
- Command Router → User Listing: dispatches support (evidence: `commands/handler/command.handler.js`)
- Help Reply → WhatsApp User: replies (evidence: `commands/help.command.js`)
- User Listing → JSONPlaceholder Service: fetches users (evidence: `commands/users.command.js`)
- User Listing → WhatsApp User: replies (evidence: `commands/users.command.js`)
- Groq Response Service → Assistant Rules: loads rules (evidence: `services/groq/Groq.service.js`)
- Groq Response Service → Groq API: requests completion (evidence: `services/groq/Groq.service.js`)
- Groq Response Service → WhatsApp User: returns reply via chat
- JSONPlaceholder Service → HTTP Client Config: sends requests (evidence: `services/api/jsonPlaceholder.service.js`)
- HTTP Client Config → External User API: requests user data
