# febbadityan/impostor-wabot architecture

> Architecture diagram of the GitHub repository febbadityan/impostor-wabot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/febbadityan/impostor-wabot
- Repository: https://github.com/febbadityan/impostor-wabot

## Overview

This repository is a WhatsApp Impostor word-game bot. Players register and create or join a room, start a game, receive private roles and a clue word, take turns giving clues, and vote; the bot announces the outcome. The map separates WhatsApp connection and message handling from game rules and persisted game state. README documentation is brief, so the guide supplies the documented game stages; the heavily obfuscated game module limits certainty about its internal details.

Main entry points: [`index.js`](https://github.com/febbadityan/impostor-wabot/blob/main/index.js) (Bot connection), [`src/impostor/index.js`](https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/index.js) (Game API), [`handler.js`](https://github.com/febbadityan/impostor-wabot/blob/main/handler.js) (Command handler), [`src/impostor/lib/function.js`](https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/lib/function.js) (Game rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["WhatsApp runtime"]
  node_connection["Bot connection<br/>[index.js]"]
  node_message_adapter["Message adapter<br/>[myfunc.js]"]
  node_command_handler["Command handler<br/>[handler.js]"]
end

subgraph group_gameplay["Game interaction"]
  node_game_api["Game API<br/>[index.js]"]
  node_game_rules["Game rules<br/>[function.js]"]
  node_game_guide["Game guide<br/>[guide.js]"]
end

subgraph group_state["Game state"]
  node_game_data[("Game data")]
end

node_players(("Players"))
node_whatsapp["WhatsApp"]

node_players -->|"send commands"| node_whatsapp
node_whatsapp -->|"deliver messages"| node_connection
node_connection -->|"serialize messages"| node_message_adapter
node_connection -->|"dispatch messages"| node_command_handler
node_connection -->|"connect and reply"| node_whatsapp
node_command_handler -->|"invoke game actions"| node_game_api
node_game_api -->|"re-export functions"| node_game_rules
node_game_api -->|"re-export guide"| node_game_guide
node_game_rules -->|"read and write"| node_game_data

click node_connection "https://github.com/febbadityan/impostor-wabot/blob/main/index.js"
click node_message_adapter "https://github.com/febbadityan/impostor-wabot/blob/main/src/myfunc.js"
click node_command_handler "https://github.com/febbadityan/impostor-wabot/blob/main/handler.js"
click node_game_api "https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/index.js"
click node_game_rules "https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/lib/function.js"
click node_game_guide "https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/guide.js"
click node_game_data "https://github.com/febbadityan/impostor-wabot/tree/main/src/impostor/lib/db"

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_connection,node_message_adapter,node_command_handler toneBlue
class node_game_api,node_game_rules,node_game_guide toneAmber
class node_game_data toneMint
class node_players,node_whatsapp toneIndigo
```

## Components

### WhatsApp runtime

- [Bot connection](https://github.com/febbadityan/impostor-wabot/blob/main/index.js): `index.js`
- [Message adapter](https://github.com/febbadityan/impostor-wabot/blob/main/src/myfunc.js): `src/myfunc.js`
- [Command handler](https://github.com/febbadityan/impostor-wabot/blob/main/handler.js): `handler.js`

### Game interaction

- [Game API](https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/index.js): `src/impostor/index.js`
- [Game rules](https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/lib/function.js): `src/impostor/lib/function.js`
- [Game guide](https://github.com/febbadityan/impostor-wabot/blob/main/src/impostor/guide.js): `src/impostor/guide.js`

### Game state

- [Game data](https://github.com/febbadityan/impostor-wabot/tree/main/src/impostor/lib/db): `src/impostor/lib/db`

### Other components

- **Players**
- **WhatsApp**

## Connections

- Players → WhatsApp: send commands (evidence: `README.md`)
- WhatsApp → Bot connection: deliver messages (evidence: `index.js`)
- Bot connection → Message adapter: serialize messages (evidence: `index.js`)
- Bot connection → Command handler: dispatch messages (evidence: `index.js`)
- Bot connection → WhatsApp: connect and reply (evidence: `index.js`)
- Command handler → Game API: invoke game actions (evidence: `handler.js`)
- Game API → Game rules: re-export functions (evidence: `src/impostor/index.js`)
- Game API → Game guide: re-export guide (evidence: `src/impostor/index.js`)
- Game rules → Game data: read and write (evidence: `src/impostor/lib/function.js`)
