# erfanvahabpour/bale-bot-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/erfanvahabpour/bale-bot-sdk
- Repository: https://github.com/erfanvahabpour/bale-bot-sdk

## Overview

Bale Bot PHP SDK provides a typed PHP interface to the Bale Bot API. A bot application selects a configured bot, receives webhook or polling updates, turns them into typed update objects, and can dispatch commands or events before invoking API methods for messaging, chats, media, payments, stickers, and bot commands. Those methods use a shared request/HTTP layer and return typed results. Laravel adds container, facade, configuration, and webhook CLI integration. The graph reflects documented capabilities, but unsampled modules are connected only where the README or excerpts establish the relationship.

Main entry points: [`src/Api.php`](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Api.php) (Bot API facade), [`src/BotsManager.php`](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BotsManager.php) (Multi-bot manager), [`src/BaleClient.php`](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BaleClient.php) (Bale HTTP client), [`src/Traits/CommandsHandler.php`](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Traits/CommandsHandler.php) (Command handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Bot access"]
  node_botmanager["Multi-bot manager<br/>[BotsManager.php]"]
  node_api["Bot API facade<br/>[Api.php]"]
end

subgraph group_updates["Update handling"]
  node_updates["Update intake<br/>[Update.php]"]
  node_updateobj["Typed update<br/>[Update.php]"]
  node_events["Update events"]
  node_commandhandler["Command handling"]
  node_commandbus["Command bus<br/>[CommandBus.php]"]
  node_command["Command classes<br/>[Command.php]"]
  node_answers["Answer helpers<br/>[Answerable.php]"]
end

subgraph group_api["Bale API operations"]
  node_messages["Messages and editing<br/>[Message.php]"]
  node_chats["Chat operations<br/>[Chat.php]"]
  node_media["Media and files<br/>[InputFile.php]"]
  node_payments["In-app payments<br/>[Payments.php]"]
  node_stickers["Stickers<br/>[Stickers.php]"]
  node_botcommands["Bot command menus<br/>[Commands.php]"]
  node_typedobjects["Typed API objects<br/>[BaseObject.php]"]
end

subgraph group_transport["Request transport"]
  node_request["Request construction<br/>[BaleRequest.php]"]
  node_httptrait["HTTP operations<br/>[Http.php]"]
  node_client["Bale HTTP client<br/>[BaleClient.php]"]
  node_httpinterface["HTTP client interface"]
  node_guzzle["Guzzle adapter"]
  node_response["Response handling<br/>[BaleResponse.php]"]
end

subgraph group_laravel["Laravel integration"]
  node_laravelsvc["Laravel service provider"]
  node_facade["Laravel facade<br/>[Bale.php]"]
  node_webhookcli["Webhook CLI<br/>[WebhookCommand.php]"]
end

node_developer(("Bot developer"))
node_baleapi(("Bale Bot API"))
node_laravelapp(("Laravel application"))

node_developer -->|"selects bot"| node_botmanager
node_botmanager -->|"creates bot"| node_api
node_developer -->|"calls methods"| node_api
node_api -->|"uses handler"| node_commandhandler
node_commandhandler -.->|"handles updates"| node_updates
node_updates -.->|"parses updates"| node_updateobj
node_api -.->|"dispatches events"| node_events
node_commandhandler -->|"dispatches commands"| node_commandbus
node_commandbus -->|"resolves commands"| node_command
node_command -->|"uses answers"| node_answers
node_api -->|"exposes methods"| node_messages
node_api -->|"exposes methods"| node_chats
node_api -->|"exposes methods"| node_payments
node_api -->|"exposes methods"| node_stickers
node_api -->|"exposes methods"| node_botcommands
node_messages -->|"accepts uploads"| node_media
node_messages -->|"returns objects"| node_typedobjects
node_payments -.->|"returns objects"| node_typedobjects
node_api -->|"uses transport"| node_httptrait
node_httptrait -->|"builds requests"| node_request
node_httptrait -->|"sends requests"| node_client
node_client -->|"implements"| node_httpinterface
node_client -->|"defaults to"| node_guzzle
node_client -->|"wraps responses"| node_response
node_request -->|"requests endpoints"| node_baleapi
node_laravelapp -->|"registers package"| node_laravelsvc
node_laravelsvc -->|"binds manager"| node_botmanager
node_laravelapp -->|"calls facade"| node_facade
node_facade -->|"delegates access"| node_botmanager
node_laravelapp -->|"runs command"| node_webhookcli
node_webhookcli -->|"resolves bot"| node_botmanager
node_webhookcli -->|"configures webhook"| node_api

click node_botmanager "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BotsManager.php"
click node_api "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Api.php"
click node_updates "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Update.php"
click node_updateobj "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Objects/Update.php"
click node_events "https://github.com/erfanvahabpour/bale-bot-sdk/tree/main/src/Events"
click node_commandhandler "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Traits/CommandsHandler.php"
click node_commandbus "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Commands/CommandBus.php"
click node_command "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Commands/Command.php"
click node_answers "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Answers/Answerable.php"
click node_messages "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Message.php"
click node_chats "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Chat.php"
click node_media "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/FileUpload/InputFile.php"
click node_payments "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Payments.php"
click node_stickers "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Stickers.php"
click node_botcommands "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Commands.php"
click node_typedobjects "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Objects/BaseObject.php"
click node_request "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BaleRequest.php"
click node_httptrait "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Traits/Http.php"
click node_client "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BaleClient.php"
click node_httpinterface "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/HttpClients/HttpClientInterface.php"
click node_guzzle "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/HttpClients/GuzzleHttpClient.php"
click node_response "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BaleResponse.php"
click node_laravelsvc "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Laravel/BaleServiceProvider.php"
click node_facade "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Laravel/Facades/Bale.php"
click node_webhookcli "https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Laravel/Artisan/WebhookCommand.php"

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_botmanager,node_api toneBlue
class node_updates,node_updateobj,node_events,node_commandhandler,node_commandbus,node_command,node_answers toneAmber
class node_messages,node_chats,node_media,node_payments,node_stickers,node_botcommands,node_typedobjects,node_baleapi toneMint
class node_request,node_httptrait,node_client,node_httpinterface,node_guzzle,node_response toneRose
class node_laravelsvc,node_facade,node_webhookcli,node_developer,node_laravelapp toneIndigo
```

## Components

### Bot access

- [Multi-bot manager](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BotsManager.php): `src/BotsManager.php`
- [Bot API facade](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Api.php): `src/Api.php`

### Update handling

- [Update intake](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Update.php): `src/Methods/Update.php`
- [Typed update](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Objects/Update.php): `src/Objects/Update.php`
- [Update events](https://github.com/erfanvahabpour/bale-bot-sdk/tree/main/src/Events): `src/Events`
- [Command handling](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Traits/CommandsHandler.php): `src/Traits/CommandsHandler.php`
- [Command bus](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Commands/CommandBus.php): `src/Commands/CommandBus.php`
- [Command classes](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Commands/Command.php): `src/Commands/Command.php`
- [Answer helpers](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Answers/Answerable.php): `src/Answers/Answerable.php`

### Bale API operations

- [Messages and editing](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Message.php): `src/Methods/Message.php`
- [Chat operations](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Chat.php): `src/Methods/Chat.php`
- [Media and files](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/FileUpload/InputFile.php): `src/FileUpload/InputFile.php`
- [In-app payments](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Payments.php): `src/Methods/Payments.php`
- [Stickers](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Stickers.php): `src/Methods/Stickers.php`
- [Bot command menus](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Methods/Commands.php): `src/Methods/Commands.php`
- [Typed API objects](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Objects/BaseObject.php): `src/Objects/BaseObject.php`

### Request transport

- [Request construction](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BaleRequest.php): `src/BaleRequest.php`
- [HTTP operations](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Traits/Http.php): `src/Traits/Http.php`
- [Bale HTTP client](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BaleClient.php): `src/BaleClient.php`
- [HTTP client interface](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/HttpClients/HttpClientInterface.php): `src/HttpClients/HttpClientInterface.php`
- [Guzzle adapter](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/HttpClients/GuzzleHttpClient.php): `src/HttpClients/GuzzleHttpClient.php`
- [Response handling](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/BaleResponse.php): `src/BaleResponse.php`

### Laravel integration

- [Laravel service provider](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Laravel/BaleServiceProvider.php): `src/Laravel/BaleServiceProvider.php`
- [Laravel facade](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Laravel/Facades/Bale.php): `src/Laravel/Facades/Bale.php`
- [Webhook CLI](https://github.com/erfanvahabpour/bale-bot-sdk/blob/main/src/Laravel/Artisan/WebhookCommand.php): `src/Laravel/Artisan/WebhookCommand.php`

### Other components

- **Bot developer**
- **Bale Bot API**
- **Laravel application**

## Connections

- Bot developer → Multi-bot manager: selects bot (evidence: `README.md`)
- Multi-bot manager → Bot API facade: creates bot (evidence: `src/BotsManager.php`)
- Bot developer → Bot API facade: calls methods (evidence: `src/Api.php`)
- Bot API facade → Command handling: uses handler (evidence: `src/Api.php`)
- Command handling → Update intake: handles updates
- Update intake → Typed update: parses updates
- Bot API facade → Update events: dispatches events (evidence: `src/Api.php`)
- Command handling → Command bus: dispatches commands (evidence: `src/Traits/CommandsHandler.php`)
- Command bus → Command classes: resolves commands (evidence: `src/Commands/CommandBus.php`)
- Command classes → Answer helpers: uses answers (evidence: `src/Commands/Command.php`)
- Bot API facade → Messages and editing: exposes methods (evidence: `src/Api.php`)
- Bot API facade → Chat operations: exposes methods (evidence: `src/Api.php`)
- Bot API facade → In-app payments: exposes methods (evidence: `src/Api.php`)
- Bot API facade → Stickers: exposes methods (evidence: `src/Api.php`)
- Bot API facade → Bot command menus: exposes methods (evidence: `src/Api.php`)
- Messages and editing → Media and files: accepts uploads (evidence: `src/Methods/Message.php`)
- Messages and editing → Typed API objects: returns objects (evidence: `src/Methods/Message.php`)
- In-app payments → Typed API objects: returns objects
- Bot API facade → HTTP operations: uses transport (evidence: `src/Api.php`)
- HTTP operations → Request construction: builds requests (evidence: `src/Traits/Http.php`)
- HTTP operations → Bale HTTP client: sends requests (evidence: `src/Traits/Http.php`)
- Bale HTTP client → HTTP client interface: implements (evidence: `src/BaleClient.php`)
- Bale HTTP client → Guzzle adapter: defaults to (evidence: `src/BaleClient.php`)
- Bale HTTP client → Response handling: wraps responses (evidence: `src/BaleClient.php`)
- Request construction → Bale Bot API: requests endpoints (evidence: `README.md`)
- Laravel application → Laravel service provider: registers package (evidence: `README.md`)
- Laravel service provider → Multi-bot manager: binds manager (evidence: `src/Laravel/BaleServiceProvider.php`)
- Laravel application → Laravel facade: calls facade (evidence: `README.md`)
- Laravel facade → Multi-bot manager: delegates access (evidence: `src/Laravel/Facades/Bale.php`)
- Laravel application → Webhook CLI: runs command (evidence: `README.md`)
- Webhook CLI → Multi-bot manager: resolves bot (evidence: `src/Laravel/Artisan/WebhookCommand.php`)
- Webhook CLI → Bot API facade: configures webhook (evidence: `src/Laravel/Artisan/WebhookCommand.php`)
