# akramhaig6-bot/akbotsbuilder2 architecture

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

- Interactive diagram: https://gitdiagram.com/akramhaig6-bot/akbotsbuilder2
- Repository: https://github.com/akramhaig6-bot/akbotsbuilder2

## Overview

This is a Telegram bot design and operations studio: users manage bot configurations, edit messages and button flows, preview behavior, import JSON or scan existing Telegram bots, then connect and operate bots. The browser UI persists through an API backed by local/server bot storage; server-side runtime handles Telegram bot interactions, while scanning uses a separate Telegram account workflow to capture bot structure. The graph reflects documented imports and excerpted calls; HTTP routing and some unsampled runtime details are shown only where directly supported or left unlinked.

Main entry points: [`src/App.tsx`](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/App.tsx) (Studio shell), [`server.ts`](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/server.ts) (API and bot server), [`src/components/BotEditor.tsx`](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/BotEditor.tsx) (Bot editor), [`src/components/ButtonFlowEditor.tsx`](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/ButtonFlowEditor.tsx) (Flow editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_studio["Studio UI"]
  node_app["Studio shell<br/>[App.tsx]"]
  node_botlist["Bot catalog<br/>[BotList.tsx]"]
end

subgraph group_design["Bot Design"]
  node_editor["Bot editor<br/>[BotEditor.tsx]"]
  node_flowedit["Flow editor"]
  node_buttonedit["Button editor"]
  node_startmsg["Start messages"]
  node_media["Media uploader<br/>[MediaUploader.tsx]"]
  node_pagination["Pagination<br/>[pagination.ts]"]
  node_formatters["Telegram formatters"]
  node_simulator["Bot simulator"]
  node_botmodel["Bot configuration model<br/>[bot.ts]"]
end

subgraph group_import["Import and Scan"]
  node_jsonimport["JSON blueprint import"]
  node_quickdeploy["JSON quick deploy"]
  node_scanui["Telegram scan UI"]
  node_scanner["Telegram scanner<br/>[telegramScanner.ts]"]
  node_scanbuilder["Scan blueprint builder"]
  node_scanmodel["Scan data model<br/>[scan.ts]"]
end

subgraph group_runtime["Bot Runtime"]
  node_flowengine["Flow engine<br/>[flowEngine.ts]"]
  node_server["API and bot server<br/>[server.ts]"]
  node_delivery["Telegram delivery helpers"]
end

subgraph group_storage["Persistence"]
  node_api["Browser API client<br/>[api.ts]"]
  node_persistence[("Bot persistence<br/>[botPersistence.ts]")]
end

node_user(("Studio user"))
node_telegram(("Telegram"))

node_user -->|"uses"| node_app
node_app -->|"loads bots"| node_api
node_app -->|"renders"| node_botlist
node_app -->|"renders"| node_editor
node_app -->|"renders"| node_quickdeploy
node_app -->|"renders"| node_scanui
node_editor -->|"renders"| node_flowedit
node_editor -->|"renders"| node_startmsg
node_editor -->|"renders"| node_simulator
node_flowedit -->|"uses"| node_media
node_flowedit -->|"uses"| node_buttonedit
node_flowedit -->|"uses"| node_pagination
node_pagination -->|"formats buttons"| node_formatters
node_simulator -->|"resolves interactions"| node_flowengine
node_flowengine -->|"resolves pages"| node_pagination
node_flowengine -->|"formats keyboards"| node_formatters
node_quickdeploy -->|"parses blueprint"| node_jsonimport
node_scanui -->|"requests scans"| node_api
node_scanner -->|"builds blueprint"| node_scanbuilder
node_scanbuilder -->|"uses blueprint model"| node_jsonimport
node_scanui -->|"previews bot"| node_simulator
node_api -->|"reads and writes"| node_persistence
node_api -.->|"calls API"| node_server
node_server -->|"loads bot data"| node_persistence
node_server -->|"processes flows"| node_flowengine
node_server -->|"uses delivery helpers"| node_delivery
node_server -->|"dispatches scanning"| node_scanner
node_server -.->|"operates bots"| node_telegram
node_scanner -.->|"scans bots"| node_telegram
node_editor -->|"edits configuration"| node_botmodel
node_scanbuilder -->|"uses scan types"| node_scanmodel

click node_app "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/App.tsx"
click node_botlist "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/BotList.tsx"
click node_editor "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/BotEditor.tsx"
click node_flowedit "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/ButtonFlowEditor.tsx"
click node_buttonedit "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/UnifiedButtonForm.tsx"
click node_startmsg "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/StartMessageSection.tsx"
click node_media "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/MediaUploader.tsx"
click node_pagination "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/pagination.ts"
click node_formatters "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/telegramFormatters.ts"
click node_simulator "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/TelegramSimulator.tsx"
click node_flowengine "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/flowEngine.ts"
click node_jsonimport "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/jsonBotBlueprint.ts"
click node_quickdeploy "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/JsonQuickDeploySection.tsx"
click node_scanui "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/ScanTelegramSection.tsx"
click node_scanner "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/server/telegramScanner.ts"
click node_scanbuilder "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/scanBlueprintBuilder.ts"
click node_api "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/services/api.ts"
click node_server "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/server.ts"
click node_persistence "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/botPersistence.ts"
click node_delivery "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/telegramDelivery.ts"
click node_botmodel "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/types/bot.ts"
click node_scanmodel "https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/types/scan.ts"

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_app,node_botlist,node_user toneBlue
class node_editor,node_flowedit,node_buttonedit,node_startmsg,node_media,node_pagination,node_formatters,node_simulator,node_botmodel toneAmber
class node_jsonimport,node_quickdeploy,node_scanui,node_scanner,node_scanbuilder,node_scanmodel toneMint
class node_flowengine,node_server,node_delivery toneRose
class node_api,node_persistence,node_telegram toneIndigo
```

## Components

### Studio UI

- [Studio shell](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/App.tsx): `src/App.tsx`
- [Bot catalog](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/BotList.tsx): `src/components/BotList.tsx`

### Bot Design

- [Bot editor](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/BotEditor.tsx): `src/components/BotEditor.tsx`
- [Flow editor](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/ButtonFlowEditor.tsx): `src/components/ButtonFlowEditor.tsx`
- [Button editor](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/UnifiedButtonForm.tsx): `src/components/UnifiedButtonForm.tsx`
- [Start messages](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/StartMessageSection.tsx): `src/components/StartMessageSection.tsx`
- [Media uploader](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/MediaUploader.tsx): `src/components/MediaUploader.tsx`
- [Pagination](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/pagination.ts): `src/utils/pagination.ts`
- [Telegram formatters](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/telegramFormatters.ts): `src/utils/telegramFormatters.ts`
- [Bot simulator](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/TelegramSimulator.tsx): `src/components/TelegramSimulator.tsx`
- [Bot configuration model](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/types/bot.ts): `src/types/bot.ts`

### Import and Scan

- [JSON blueprint import](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/jsonBotBlueprint.ts): `src/utils/jsonBotBlueprint.ts`
- [JSON quick deploy](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/JsonQuickDeploySection.tsx): `src/components/JsonQuickDeploySection.tsx`
- [Telegram scan UI](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/components/ScanTelegramSection.tsx): `src/components/ScanTelegramSection.tsx`
- [Telegram scanner](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/server/telegramScanner.ts): `server/telegramScanner.ts`
- [Scan blueprint builder](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/scanBlueprintBuilder.ts): `src/utils/scanBlueprintBuilder.ts`
- [Scan data model](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/types/scan.ts): `src/types/scan.ts`

### Bot Runtime

- [Flow engine](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/flowEngine.ts): `src/utils/flowEngine.ts`
- [API and bot server](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/server.ts): `server.ts`
- [Telegram delivery helpers](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/telegramDelivery.ts): `src/utils/telegramDelivery.ts`

### Persistence

- [Browser API client](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/services/api.ts): `src/services/api.ts`
- [Bot persistence](https://github.com/akramhaig6-bot/akbotsbuilder2/blob/main/src/utils/botPersistence.ts): `src/utils/botPersistence.ts`

### Other components

- **Studio user**
- **Telegram**

## Connections

- Studio user → Studio shell: uses (evidence: `src/App.tsx`)
- Studio shell → Browser API client: loads bots (evidence: `src/App.tsx`)
- Studio shell → Bot catalog: renders (evidence: `src/App.tsx`)
- Studio shell → Bot editor: renders (evidence: `src/App.tsx`)
- Studio shell → JSON quick deploy: renders (evidence: `src/App.tsx`)
- Studio shell → Telegram scan UI: renders (evidence: `src/App.tsx`)
- Bot editor → Flow editor: renders (evidence: `src/components/BotEditor.tsx`)
- Bot editor → Start messages: renders (evidence: `src/components/BotEditor.tsx`)
- Bot editor → Bot simulator: renders (evidence: `src/components/BotEditor.tsx`)
- Flow editor → Media uploader: uses (evidence: `src/components/ButtonFlowEditor.tsx`)
- Flow editor → Button editor: uses (evidence: `src/components/ButtonFlowEditor.tsx`)
- Flow editor → Pagination: uses (evidence: `src/components/ButtonFlowEditor.tsx`)
- Pagination → Telegram formatters: formats buttons (evidence: `src/utils/pagination.ts`)
- Bot simulator → Flow engine: resolves interactions (evidence: `src/components/TelegramSimulator.tsx`)
- Flow engine → Pagination: resolves pages (evidence: `src/utils/flowEngine.ts`)
- Flow engine → Telegram formatters: formats keyboards (evidence: `src/utils/flowEngine.ts`)
- JSON quick deploy → JSON blueprint import: parses blueprint (evidence: `src/components/JsonQuickDeploySection.tsx`)
- Telegram scan UI → Browser API client: requests scans (evidence: `src/components/ScanTelegramSection.tsx`)
- Telegram scanner → Scan blueprint builder: builds blueprint (evidence: `server/telegramScanner.ts`)
- Scan blueprint builder → JSON blueprint import: uses blueprint model (evidence: `src/utils/scanBlueprintBuilder.ts`)
- Telegram scan UI → Bot simulator: previews bot (evidence: `src/components/ScanTelegramSection.tsx`)
- Browser API client → Bot persistence: reads and writes (evidence: `src/services/api.ts`)
- Browser API client → API and bot server: calls API
- API and bot server → Bot persistence: loads bot data (evidence: `server.ts`)
- API and bot server → Flow engine: processes flows (evidence: `server.ts`)
- API and bot server → Telegram delivery helpers: uses delivery helpers (evidence: `server.ts`)
- API and bot server → Telegram scanner: dispatches scanning (evidence: `server.ts`)
- API and bot server → Telegram: operates bots
- Telegram scanner → Telegram: scans bots
- Bot editor → Bot configuration model: edits configuration (evidence: `src/components/BotEditor.tsx`)
- Scan blueprint builder → Scan data model: uses scan types (evidence: `src/utils/scanBlueprintBuilder.ts`)
