# bobliu0518/blbot architecture

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

- Interactive diagram: https://gitdiagram.com/bobliu0518/blbot
- Repository: https://github.com/bobliu0518/blbot

## Overview

BLBot is a lightweight QQ bot built on the kjBot framework and designed for OneBot-compatible runtimes. Its principal workflow is a QQ message entering the public runtime, being processed as a command or non-command middleware event, dispatched to a feature module, and turned into a reply. Feature areas include account/economy, games, transit lookups, and utilities; scheduled jobs form a separate path. The README documents MongoDB and OneBot dependencies. Some processor and SDK wiring is inferred from the documented framework layout and tree; sampled modules confirm data access and reply behavior, but not every dispatch detail.

Main entry points: [`public/messageProcessor.php`](https://github.com/bobliu0518/blbot/blob/main/public/messageProcessor.php) (Message processor), [`public/index.php`](https://github.com/bobliu0518/blbot/blob/main/public/index.php) (Runtime entry), [`public/Database.php`](https://github.com/bobliu0518/blbot/blob/main/public/Database.php) (Data access), [`module/cr`](https://github.com/bobliu0518/blbot/tree/main/module/cr) (Transit information)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Runtime entry<br/>[index.php]"]
  node_init["Initialization<br/>[init.php]"]
  node_message_processor["Message processor"]
  node_notice_processor["Notice processor"]
  node_meta_processor["Meta processor"]
  node_request_processor["Request processor"]
  node_sender["Message sender<br/>[MessageSender.php]"]
  node_sdk["OneBot SDK<br/>[CoolQ.php]"]
end

subgraph group_middleware["Middleware"]
  node_chain["Middleware chain<br/>[Chain.php]"]
  node_middleware_modules["Non-command handlers"]
end

subgraph group_features["Bot features"]
  node_account_features["Accounts and economy"]
  node_game_features["Games and interaction"]
  node_transit_features["Transit information"]
  node_utility_features["Text and utilities"]
  node_social_features["Group and profile"]
  node_integrated_info["External information"]
end

subgraph group_state["State and scheduling"]
  node_database_api["Data access<br/>[Database.php]"]
  node_scheduler["Scheduler runtime<br/>[Scheduler.php]"]
  node_scheduled_jobs["Scheduled jobs"]
end

subgraph group_integrations["External integrations"]
  node_mongodb[("MongoDB")]
  node_external_apis["Information APIs"]
end

node_qq_user(("QQ user"))
node_onebot["OneBot runtime"]

node_qq_user -->|"sends event"| node_onebot
node_onebot -->|"delivers events"| node_entry
node_entry -->|"initializes"| node_init
node_entry -->|"processes messages"| node_message_processor
node_entry -->|"routes notices"| node_notice_processor
node_entry -->|"routes metadata"| node_meta_processor
node_entry -->|"routes requests"| node_request_processor
node_message_processor -->|"runs middleware"| node_chain
node_chain -->|"dispatches handlers"| node_middleware_modules
node_message_processor -->|"dispatches commands"| node_account_features
node_message_processor -->|"dispatches commands"| node_game_features
node_message_processor -->|"dispatches commands"| node_transit_features
node_message_processor -->|"dispatches commands"| node_utility_features
node_message_processor -->|"dispatches commands"| node_social_features
node_message_processor -->|"dispatches commands"| node_integrated_info
node_account_features -->|"reads and writes"| node_database_api
node_game_features -->|"reads and writes"| node_database_api
node_transit_features -->|"reads cached data"| node_database_api
node_integrated_info -->|"reads cached data"| node_database_api
node_database_api -->|"persists data"| node_mongodb
node_message_processor -->|"queues replies"| node_sender
node_sender -->|"sends messages"| node_sdk
node_sdk -->|"calls API"| node_onebot
node_entry -->|"starts runtime"| node_scheduler
node_scheduler -->|"runs jobs"| node_scheduled_jobs
node_scheduled_jobs -->|"accesses data"| node_database_api
node_transit_features -.->|"queries schedules"| node_external_apis
node_integrated_info -.->|"queries information"| node_external_apis

click node_entry "https://github.com/bobliu0518/blbot/blob/main/public/index.php"
click node_init "https://github.com/bobliu0518/blbot/blob/main/public/init.php"
click node_message_processor "https://github.com/bobliu0518/blbot/blob/main/public/messageProcessor.php"
click node_notice_processor "https://github.com/bobliu0518/blbot/blob/main/public/noticeProcessor.php"
click node_meta_processor "https://github.com/bobliu0518/blbot/blob/main/public/meta_eventProcessor.php"
click node_request_processor "https://github.com/bobliu0518/blbot/blob/main/public/requestProcessor.php"
click node_sender "https://github.com/bobliu0518/blbot/blob/main/public/MessageSender.php"
click node_sdk "https://github.com/bobliu0518/blbot/blob/main/SDK/CoolQ.php"
click node_chain "https://github.com/bobliu0518/blbot/blob/main/middleWare/Chain.php"
click node_middleware_modules "https://github.com/bobliu0518/blbot/tree/main/middleWare"
click node_account_features "https://github.com/bobliu0518/blbot/tree/main/module/credit"
click node_game_features "https://github.com/bobliu0518/blbot/tree/main/module/rh"
click node_transit_features "https://github.com/bobliu0518/blbot/tree/main/module/cr"
click node_utility_features "https://github.com/bobliu0518/blbot/tree/main/module/base64"
click node_social_features "https://github.com/bobliu0518/blbot/tree/main/module/alias"
click node_integrated_info "https://github.com/bobliu0518/blbot/tree/main/module/weather"
click node_database_api "https://github.com/bobliu0518/blbot/blob/main/public/Database.php"
click node_scheduler "https://github.com/bobliu0518/blbot/blob/main/public/Scheduler.php"
click node_scheduled_jobs "https://github.com/bobliu0518/blbot/tree/main/scheduler"

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_init,node_message_processor,node_notice_processor,node_meta_processor,node_request_processor,node_sender,node_sdk,node_qq_user toneBlue
class node_chain,node_middleware_modules toneAmber
class node_account_features,node_game_features,node_transit_features,node_utility_features,node_social_features,node_integrated_info toneMint
class node_database_api,node_scheduler,node_scheduled_jobs toneRose
class node_mongodb,node_external_apis,node_onebot toneIndigo
```

## Components

### Bot runtime

- [Runtime entry](https://github.com/bobliu0518/blbot/blob/main/public/index.php): `public/index.php`
- [Initialization](https://github.com/bobliu0518/blbot/blob/main/public/init.php): `public/init.php`
- [Message processor](https://github.com/bobliu0518/blbot/blob/main/public/messageProcessor.php): `public/messageProcessor.php`
- [Notice processor](https://github.com/bobliu0518/blbot/blob/main/public/noticeProcessor.php): `public/noticeProcessor.php`
- [Meta processor](https://github.com/bobliu0518/blbot/blob/main/public/meta_eventProcessor.php): `public/meta_eventProcessor.php`
- [Request processor](https://github.com/bobliu0518/blbot/blob/main/public/requestProcessor.php): `public/requestProcessor.php`
- [Message sender](https://github.com/bobliu0518/blbot/blob/main/public/MessageSender.php): `public/MessageSender.php`
- [OneBot SDK](https://github.com/bobliu0518/blbot/blob/main/SDK/CoolQ.php): `SDK/CoolQ.php`

### Middleware

- [Middleware chain](https://github.com/bobliu0518/blbot/blob/main/middleWare/Chain.php): `middleWare/Chain.php`
- [Non-command handlers](https://github.com/bobliu0518/blbot/tree/main/middleWare): `middleWare`

### Bot features

- [Accounts and economy](https://github.com/bobliu0518/blbot/tree/main/module/credit): `module/credit`
- [Games and interaction](https://github.com/bobliu0518/blbot/tree/main/module/rh): `module/rh`
- [Transit information](https://github.com/bobliu0518/blbot/tree/main/module/cr): `module/cr`
- [Text and utilities](https://github.com/bobliu0518/blbot/tree/main/module/base64): `module/base64`
- [Group and profile](https://github.com/bobliu0518/blbot/tree/main/module/alias): `module/alias`
- [External information](https://github.com/bobliu0518/blbot/tree/main/module/weather): `module/weather`

### State and scheduling

- [Data access](https://github.com/bobliu0518/blbot/blob/main/public/Database.php): `public/Database.php`
- [Scheduler runtime](https://github.com/bobliu0518/blbot/blob/main/public/Scheduler.php): `public/Scheduler.php`
- [Scheduled jobs](https://github.com/bobliu0518/blbot/tree/main/scheduler): `scheduler`

### External integrations

- **MongoDB**
- **Information APIs**

### Other components

- **QQ user**
- **OneBot runtime**

## Connections

- QQ user → OneBot runtime: sends event
- OneBot runtime → Runtime entry: delivers events
- Runtime entry → Initialization: initializes
- Runtime entry → Message processor: processes messages
- Runtime entry → Notice processor: routes notices
- Runtime entry → Meta processor: routes metadata
- Runtime entry → Request processor: routes requests
- Message processor → Middleware chain: runs middleware
- Middleware chain → Non-command handlers: dispatches handlers
- Message processor → Accounts and economy: dispatches commands
- Message processor → Games and interaction: dispatches commands
- Message processor → Transit information: dispatches commands
- Message processor → Text and utilities: dispatches commands
- Message processor → Group and profile: dispatches commands
- Message processor → External information: dispatches commands
- Accounts and economy → Data access: reads and writes
- Games and interaction → Data access: reads and writes
- Transit information → Data access: reads cached data
- External information → Data access: reads cached data
- Data access → MongoDB: persists data
- Message processor → Message sender: queues replies
- Message sender → OneBot SDK: sends messages
- OneBot SDK → OneBot runtime: calls API
- Runtime entry → Scheduler runtime: starts runtime
- Scheduler runtime → Scheduled jobs: runs jobs
- Scheduled jobs → Data access: accesses data
- Transit information → Information APIs: queries schedules
- External information → Information APIs: queries information
