# akash-black-fox/black-fox-bot architecture

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

- Interactive diagram: https://gitdiagram.com/akash-black-fox/black-fox-bot
- Repository: https://github.com/akash-black-fox/black-fox-bot

## Overview

BLACK FOX is a Facebook Messenger bot built on a local FOX client API. The principal workflow is a Messenger event entering the bot’s listener, being routed to command or event handlers, and producing a reply or platform action; user, thread, and currency data are persisted in SQLite. The README also advertises anti-unsend, downloads, AI chat, group security, and economy features, represented by their command/event modules where the tree supports them. Some wiring beyond the excerpts is uncertain, so unverified links are dashed.

Main entry points: [`BLACK-FOX/system/listen.js`](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/listen.js) (Event listener), [`Module/commands`](https://github.com/akash-black-fox/black-fox-bot/tree/main/Module/commands) (Command modules), [`BLACK-FOX/system/database/models`](https://github.com/akash-black-fox/black-fox-bot/tree/main/BLACK-FOX/system/database/models) (SQLite models), [`black-fox.js`](https://github.com/akash-black-fox/black-fox-bot/blob/main/black-fox.js) (Bot entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Bot entry<br/>[black-fox.js]"]
  node_listener["Event listener<br/>[listen.js]"]
  node_commands["Command handler<br/>[handleCommand.js]"]
  node_auto["Auto detection"]
  node_reply["Reply handler<br/>[handleReply.js]"]
  node_eventhandler["Event handler<br/>[handleEvent.js]"]
  node_reaction["Reaction handler<br/>[handleReaction.js]"]
  node_notification["Notification handler"]
  node_bootstrap["Data bootstrap"]
  node_logs["Logging<br/>[logs.js]"]
end

subgraph group_features["Bot features"]
  node_commandmods["Command modules"]
  node_eventmods["Event modules"]
end

subgraph group_platform["Messenger client"]
  node_fox["FOX API client<br/>[index.js]"]
  node_foxutils["FOX request utilities<br/>[utils.js]"]
end

subgraph group_state["Bot state"]
  node_users["User controller<br/>[users.js]"]
  node_threads["Thread controller<br/>[threads.js]"]
  node_currencies["Currency controller<br/>[currencies.js]"]
  node_models["SQLite models"]
  node_database[("SQLite database<br/>[index.js]")]
end

node_person(("Messenger user"))
node_messenger["Facebook Messenger"]

node_person -->|"sends messages"| node_messenger
node_messenger -.->|"delivers events"| node_listener
node_entry -.->|"registers listener"| node_listener
node_listener -->|"initializes data"| node_bootstrap
node_listener -->|"routes messages"| node_commands
node_listener -->|"checks messages"| node_auto
node_listener -->|"routes replies"| node_reply
node_listener -->|"routes events"| node_eventhandler
node_listener -->|"handles notifications"| node_notification
node_listener -->|"routes reactions"| node_reaction
node_listener -.->|"logs unsends"| node_commandmods
node_commands -.->|"dispatches commands"| node_commandmods
node_eventhandler -.->|"dispatches events"| node_eventmods
node_reply -->|"invokes reply hooks"| node_commandmods
node_reaction -->|"invokes reaction hooks"| node_commandmods
node_listener -->|"reports errors"| node_logs
node_entry -->|"uses controller"| node_users
node_entry -->|"uses controller"| node_threads
node_bootstrap -.->|"creates user data"| node_users
node_bootstrap -.->|"creates thread data"| node_threads
node_users -->|"reads and writes"| node_models
node_threads -->|"persists thread data"| node_models
node_currencies -->|"persists balances"| node_models
node_models -->|"uses database"| node_database
node_fox -->|"uses utilities"| node_foxutils
node_listener -.->|"receives platform API"| node_fox
node_commandmods -.->|"performs Messenger actions"| node_fox

click node_entry "https://github.com/akash-black-fox/black-fox-bot/blob/main/black-fox.js"
click node_listener "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/listen.js"
click node_commands "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleCommand.js"
click node_auto "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleAutoDetect.js"
click node_reply "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleReply.js"
click node_eventhandler "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleEvent.js"
click node_reaction "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleReaction.js"
click node_notification "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleNotification.js"
click node_bootstrap "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleCreateDatabase.js"
click node_commandmods "https://github.com/akash-black-fox/black-fox-bot/tree/main/Module/commands"
click node_eventmods "https://github.com/akash-black-fox/black-fox-bot/tree/main/Module/events"
click node_fox "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/FOX/index.js"
click node_foxutils "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/FOX/utils.js"
click node_users "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/controllers/users.js"
click node_threads "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/controllers/threads.js"
click node_currencies "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/controllers/currencies.js"
click node_models "https://github.com/akash-black-fox/black-fox-bot/tree/main/BLACK-FOX/system/database/models"
click node_database "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/database/index.js"
click node_logs "https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/utility/logs.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_listener,node_commands,node_auto,node_reply,node_eventhandler,node_reaction,node_notification,node_bootstrap,node_logs,node_person toneBlue
class node_commandmods,node_eventmods toneAmber
class node_fox,node_foxutils toneMint
class node_users,node_threads,node_currencies,node_models,node_database toneRose
class node_messenger toneIndigo
```

## Components

### Bot runtime

- [Bot entry](https://github.com/akash-black-fox/black-fox-bot/blob/main/black-fox.js): `black-fox.js`
- [Event listener](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/listen.js): `BLACK-FOX/system/listen.js`
- [Command handler](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleCommand.js): `BLACK-FOX/system/handle/handleCommand.js`
- [Auto detection](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleAutoDetect.js): `BLACK-FOX/system/handle/handleAutoDetect.js`
- [Reply handler](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleReply.js): `BLACK-FOX/system/handle/handleReply.js`
- [Event handler](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleEvent.js): `BLACK-FOX/system/handle/handleEvent.js`
- [Reaction handler](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleReaction.js): `BLACK-FOX/system/handle/handleReaction.js`
- [Notification handler](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleNotification.js): `BLACK-FOX/system/handle/handleNotification.js`
- [Data bootstrap](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/handle/handleCreateDatabase.js): `BLACK-FOX/system/handle/handleCreateDatabase.js`
- [Logging](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/utility/logs.js): `BLACK-FOX/utility/logs.js`

### Bot features

- [Command modules](https://github.com/akash-black-fox/black-fox-bot/tree/main/Module/commands): `Module/commands`
- [Event modules](https://github.com/akash-black-fox/black-fox-bot/tree/main/Module/events): `Module/events`

### Messenger client

- [FOX API client](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/FOX/index.js): `BLACK-FOX/FOX/index.js`
- [FOX request utilities](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/FOX/utils.js): `BLACK-FOX/FOX/utils.js`

### Bot state

- [User controller](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/controllers/users.js): `BLACK-FOX/system/controllers/users.js`
- [Thread controller](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/controllers/threads.js): `BLACK-FOX/system/controllers/threads.js`
- [Currency controller](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/controllers/currencies.js): `BLACK-FOX/system/controllers/currencies.js`
- [SQLite models](https://github.com/akash-black-fox/black-fox-bot/tree/main/BLACK-FOX/system/database/models): `BLACK-FOX/system/database/models`
- [SQLite database](https://github.com/akash-black-fox/black-fox-bot/blob/main/BLACK-FOX/system/database/index.js): `BLACK-FOX/system/database/index.js`

### Other components

- **Messenger user**
- **Facebook Messenger**

## Connections

- Messenger user → Facebook Messenger: sends messages
- Facebook Messenger → Event listener: delivers events
- Bot entry → Event listener: registers listener
- Event listener → Data bootstrap: initializes data (evidence: `BLACK-FOX/system/listen.js`)
- Event listener → Command handler: routes messages (evidence: `BLACK-FOX/system/listen.js`)
- Event listener → Auto detection: checks messages (evidence: `BLACK-FOX/system/listen.js`)
- Event listener → Reply handler: routes replies (evidence: `BLACK-FOX/system/listen.js`)
- Event listener → Event handler: routes events (evidence: `BLACK-FOX/system/listen.js`)
- Event listener → Notification handler: handles notifications (evidence: `BLACK-FOX/system/listen.js`)
- Event listener → Reaction handler: routes reactions (evidence: `BLACK-FOX/system/listen.js`)
- Event listener → Command modules: logs unsends
- Command handler → Command modules: dispatches commands
- Event handler → Event modules: dispatches events
- Reply handler → Command modules: invokes reply hooks (evidence: `BLACK-FOX/system/handle/handleReply.js`)
- Reaction handler → Command modules: invokes reaction hooks (evidence: `BLACK-FOX/system/handle/handleReaction.js`)
- Event listener → Logging: reports errors (evidence: `BLACK-FOX/system/listen.js`)
- Bot entry → User controller: uses controller (evidence: `black-fox.js`)
- Bot entry → Thread controller: uses controller (evidence: `black-fox.js`)
- Data bootstrap → User controller: creates user data
- Data bootstrap → Thread controller: creates thread data
- User controller → SQLite models: reads and writes (evidence: `BLACK-FOX/system/controllers/users.js`)
- Thread controller → SQLite models: persists thread data (evidence: `BLACK-FOX/system/controllers/threads.js`)
- Currency controller → SQLite models: persists balances (evidence: `BLACK-FOX/system/controllers/currencies.js`)
- SQLite models → SQLite database: uses database (evidence: `BLACK-FOX/system/database/models/users.js`)
- FOX API client → FOX request utilities: uses utilities (evidence: `BLACK-FOX/FOX/index.js`)
- Event listener → FOX API client: receives platform API
- Command modules → FOX API client: performs Messenger actions
