# ponyndo820/hc-bot-master_v2 architecture

> Architecture diagram of the GitHub repository ponyndo820/hc-bot-master_v2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ponyndo820/hc-bot-master_v2
- Repository: https://github.com/ponyndo820/hc-bot-master_v2

## Overview

This is an under-development, multi-device WhatsApp bot. The principal workflow is a WhatsApp message reaching the bot’s socket listener, being normalized and enriched, then routed through command handling to a reply or media action; database state is loaded at startup and persisted during operation. Documented and sampled capabilities include media conversion, Instagram and YouTube downloading, image search, games, and group-message handling. The excerpts do not show every command route, so only evidenced links are drawn; the HTTP status/process server is shown as a separate capability.

Main entry points: [`Hc.js`](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/Hc.js) (Message commands), [`index.js`](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/index.js) (Socket startup), [`src/message.js`](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/src/message.js) (Message enrichment), [`lib/igdl.js`](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/igdl.js) (Instagram downloader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_listener["Socket startup<br/>[index.js]"]
  node_message_data["Message enrichment<br/>[message.js]"]
  node_http_server["HTTP status endpoints<br/>[server.js]"]
end

subgraph group_commands["Command handling"]
  node_handler["Message commands<br/>[Hc.js]"]
  node_helpers["Message and image helpers<br/>[function.js]"]
end

subgraph group_media["Media tools"]
  node_media_convert["Media conversion<br/>[converter.js]"]
  node_instagram["Instagram downloader<br/>[igdl.js]"]
  node_youtube["YouTube downloader<br/>[ytmp4.js]"]
end

subgraph group_state["State and services"]
  node_settings["Bot settings<br/>[settings.js]"]
  node_database[("Persistent database<br/>[database.js]")]
end

node_user(("WhatsApp users"))
node_whatsapp(("WhatsApp network"))
node_ig_services(("Instagram download services"))
node_youtube_service(("YouTube"))
node_bot_process(("Bot process manager"))

node_user -->|"sends messages"| node_whatsapp
node_whatsapp -->|"delivers events"| node_listener
node_listener -->|"loads and saves"| node_database
node_listener -->|"dispatches messages"| node_handler
node_handler -->|"loads context"| node_message_data
node_message_data -->|"reads state"| node_database
node_message_data -->|"uses settings"| node_settings
node_handler -->|"converts media"| node_media_convert
node_handler -->|"downloads media"| node_instagram
node_instagram -->|"requests downloads"| node_ig_services
node_handler -.->|"downloads video"| node_youtube
node_youtube -->|"fetches video"| node_youtube_service
node_handler -->|"uses utilities"| node_helpers
node_listener -->|"configures startup"| node_settings
node_bot_process -.->|"queries process"| node_http_server
node_listener -.->|"sends replies"| node_whatsapp

click node_listener "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/index.js"
click node_handler "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/Hc.js"
click node_message_data "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/src/message.js"
click node_settings "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/settings.js"
click node_database "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/src/database.js"
click node_media_convert "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/converter.js"
click node_instagram "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/igdl.js"
click node_youtube "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/ytmp4.js"
click node_helpers "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/function.js"
click node_http_server "https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/src/server.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_listener,node_message_data,node_http_server,node_user toneBlue
class node_handler,node_helpers toneAmber
class node_media_convert,node_instagram,node_youtube toneMint
class node_settings,node_database toneRose
class node_whatsapp,node_ig_services,node_youtube_service,node_bot_process toneIndigo
```

## Components

### Bot runtime

- [Socket startup](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/index.js): `index.js`
- [Message enrichment](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/src/message.js): `src/message.js`
- [HTTP status endpoints](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/src/server.js): `src/server.js`

### Command handling

- [Message commands](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/Hc.js): `Hc.js`
- [Message and image helpers](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/function.js): `lib/function.js`

### Media tools

- [Media conversion](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/converter.js): `lib/converter.js`
- [Instagram downloader](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/igdl.js): `lib/igdl.js`
- [YouTube downloader](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/lib/ytmp4.js): `lib/ytmp4.js`

### State and services

- [Bot settings](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/settings.js): `settings.js`
- [Persistent database](https://github.com/ponyndo820/hc-bot-master_v2/blob/mf/src/database.js): `src/database.js`

### Other components

- **WhatsApp users**
- **WhatsApp network**
- **Instagram download services**
- **YouTube**
- **Bot process manager**

## Connections

- WhatsApp users → WhatsApp network: sends messages
- WhatsApp network → Socket startup: delivers events (evidence: `index.js`)
- Socket startup → Persistent database: loads and saves (evidence: `index.js`)
- Socket startup → Message commands: dispatches messages (evidence: `index.js`)
- Message commands → Message enrichment: loads context (evidence: `Hc.js`)
- Message enrichment → Persistent database: reads state (evidence: `src/message.js`)
- Message enrichment → Bot settings: uses settings (evidence: `src/message.js`)
- Message commands → Media conversion: converts media (evidence: `Hc.js`)
- Message commands → Instagram downloader: downloads media (evidence: `Hc.js`)
- Instagram downloader → Instagram download services: requests downloads (evidence: `lib/igdl.js`)
- Message commands → YouTube downloader: downloads video (evidence: `Hc.js`)
- YouTube downloader → YouTube: fetches video (evidence: `lib/ytmp4.js`)
- Message commands → Message and image helpers: uses utilities (evidence: `Hc.js`)
- Socket startup → Bot settings: configures startup (evidence: `index.js`)
- Bot process manager → HTTP status endpoints: queries process
- Socket startup → WhatsApp network: sends replies
