# tobijpeg/bot-s architecture

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

- Interactive diagram: https://gitdiagram.com/tobijpeg/bot-s
- Repository: https://github.com/tobijpeg/bot-s

## Overview

Bot(s) KZ is a web-based Telegram bot builder: an owner signs in, creates a bot profile and workflow, edits it manually or with the optional builder AI, then launches it through the platform API. The server runs the saved workflow against Telegram messages; owners can review and reply to inbox items in the web app. The README documents Supabase-backed accounts and data, encrypted Telegram tokens, onboarding, reusable workflow sequences, and admin-only questionnaire responses. Some server and page implementations were not sampled, so those branches are included only where documented; edges reflect excerpted code or README statements.

Main entry points: [`server.js`](https://github.com/tobijpeg/bot-s/blob/main/server.js) (Platform API), [`src/pages/BotFlowEditor.jsx`](https://github.com/tobijpeg/bot-s/blob/main/src/pages/BotFlowEditor.jsx) (Workflow editor), [`src/lib/supabase.js`](https://github.com/tobijpeg/bot-s/blob/main/src/lib/supabase.js) (Supabase client), [`src/lib/api.js`](https://github.com/tobijpeg/bot-s/blob/main/src/lib/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_app_routes["App routes<br/>[App.jsx]"]
  node_auth["Sign-in<br/>[Auth.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_inbox_ui["Inbox<br/>[Inbox.jsx]"]
  node_onboarding["Onboarding and tour<br/>[Welcome.jsx]"]
  node_admin_responses["Admin responses<br/>[AdminResponses.jsx]"]
  node_settings["Settings and library<br/>[Settings.jsx]"]
end

subgraph group_builder["Bot building"]
  node_workspace["Workspace state"]
  node_bot_profile["Bot profile<br/>[bot-profile.js]"]
  node_workflow_editor["Workflow editor<br/>[BotFlowEditor.jsx]"]
  node_workflow_model["Workflow model<br/>[workflow.js]"]
  node_workflow_ai["Builder AI<br/>[workflow-ai.js]"]
  node_workspace_cache[("Local workspace")]
end

subgraph group_platform["Bot platform"]
  node_bot_api["Platform API<br/>[server.js]"]
  node_workflow_runtime["Workflow runtime"]
  node_inbox_delivery["Inbox delivery<br/>[inbox-delivery.js]"]
end

subgraph group_data["Accounts and data"]
  node_supabase_client["Supabase client<br/>[supabase.js]"]
  node_supabase[("Supabase Auth and tables")]
end

node_owner(("Bot owner"))
node_telegram_user(("Telegram user"))
node_telegram{{"Telegram Bot API"}}

node_owner -->|"signs in"| node_auth
node_app_routes -->|"routes to"| node_auth
node_app_routes -->|"routes to"| node_workflow_editor
node_app_routes -->|"routes to"| node_inbox_ui
node_auth -->|"authenticates with"| node_supabase_client
node_supabase_client -->|"connects to"| node_supabase
node_workspace -->|"creates default"| node_workflow_model
node_workspace -->|"reads and writes"| node_workspace_cache
node_workflow_editor -->|"edits state"| node_workspace
node_workflow_editor -->|"edits schema"| node_workflow_model
node_workflow_editor -->|"requests generation"| node_workflow_ai
node_owner -->|"builds bot"| node_workflow_editor
node_workflow_editor -->|"sends AI request"| node_api_client
node_workflow_editor -->|"saves configuration"| node_api_client
node_api_client -->|"calls platform API"| node_bot_api
node_bot_api -->|"loads schema"| node_workflow_model
node_bot_api -->|"uses runtime"| node_workflow_runtime
node_bot_api -->|"polls and replies"| node_telegram
node_telegram_user -->|"sends messages"| node_telegram
node_bot_api -->|"dispatches replies"| node_inbox_delivery
node_inbox_ui -->|"calls API"| node_api_client
node_inbox_ui -->|"accesses data"| node_supabase_client
node_bot_api -->|"stores bot and inbox data"| node_supabase
node_bot_api -->|"stores encrypted tokens"| node_supabase
node_onboarding -->|"uses account data"| node_supabase_client
node_admin_responses -->|"loads responses"| node_supabase_client
node_settings -->|"uses account data"| node_supabase_client
node_settings -->|"manages saved sequences"| node_workspace_cache

click node_app_routes "https://github.com/tobijpeg/bot-s/blob/main/src/App.jsx"
click node_auth "https://github.com/tobijpeg/bot-s/blob/main/src/pages/Auth.jsx"
click node_workspace "https://github.com/tobijpeg/bot-s/blob/main/src/context/CreateBotContext.jsx"
click node_bot_profile "https://github.com/tobijpeg/bot-s/blob/main/src/lib/bot-profile.js"
click node_workflow_editor "https://github.com/tobijpeg/bot-s/blob/main/src/pages/BotFlowEditor.jsx"
click node_workflow_model "https://github.com/tobijpeg/bot-s/blob/main/src/workflow.js"
click node_workflow_ai "https://github.com/tobijpeg/bot-s/blob/main/src/workflow-ai.js"
click node_workspace_cache "https://github.com/tobijpeg/bot-s/blob/main/src/workspace-storage.js"
click node_api_client "https://github.com/tobijpeg/bot-s/blob/main/src/lib/api.js"
click node_bot_api "https://github.com/tobijpeg/bot-s/blob/main/server.js"
click node_workflow_runtime "https://github.com/tobijpeg/bot-s/blob/main/src/workflow-runtime.js"
click node_inbox_delivery "https://github.com/tobijpeg/bot-s/blob/main/src/inbox-delivery.js"
click node_inbox_ui "https://github.com/tobijpeg/bot-s/blob/main/src/pages/Inbox.jsx"
click node_supabase_client "https://github.com/tobijpeg/bot-s/blob/main/src/lib/supabase.js"
click node_onboarding "https://github.com/tobijpeg/bot-s/blob/main/src/pages/Welcome.jsx"
click node_admin_responses "https://github.com/tobijpeg/bot-s/blob/main/src/pages/AdminResponses.jsx"
click node_settings "https://github.com/tobijpeg/bot-s/blob/main/src/pages/Settings.jsx"

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_routes,node_auth,node_api_client,node_inbox_ui,node_onboarding,node_admin_responses,node_settings,node_telegram_user toneBlue
class node_workspace,node_bot_profile,node_workflow_editor,node_workflow_model,node_workflow_ai,node_workspace_cache toneAmber
class node_bot_api,node_workflow_runtime,node_inbox_delivery,node_telegram toneMint
class node_supabase_client,node_supabase toneRose
class node_owner toneIndigo
```

## Components

### Web app

- [App routes](https://github.com/tobijpeg/bot-s/blob/main/src/App.jsx): `src/App.jsx`
- [Sign-in](https://github.com/tobijpeg/bot-s/blob/main/src/pages/Auth.jsx): `src/pages/Auth.jsx`
- [API client](https://github.com/tobijpeg/bot-s/blob/main/src/lib/api.js): `src/lib/api.js`
- [Inbox](https://github.com/tobijpeg/bot-s/blob/main/src/pages/Inbox.jsx): `src/pages/Inbox.jsx`
- [Onboarding and tour](https://github.com/tobijpeg/bot-s/blob/main/src/pages/Welcome.jsx): `src/pages/Welcome.jsx`
- [Admin responses](https://github.com/tobijpeg/bot-s/blob/main/src/pages/AdminResponses.jsx): `src/pages/AdminResponses.jsx`
- [Settings and library](https://github.com/tobijpeg/bot-s/blob/main/src/pages/Settings.jsx): `src/pages/Settings.jsx`

### Bot building

- [Workspace state](https://github.com/tobijpeg/bot-s/blob/main/src/context/CreateBotContext.jsx): `src/context/CreateBotContext.jsx`
- [Bot profile](https://github.com/tobijpeg/bot-s/blob/main/src/lib/bot-profile.js): `src/lib/bot-profile.js`
- [Workflow editor](https://github.com/tobijpeg/bot-s/blob/main/src/pages/BotFlowEditor.jsx): `src/pages/BotFlowEditor.jsx`
- [Workflow model](https://github.com/tobijpeg/bot-s/blob/main/src/workflow.js): `src/workflow.js`
- [Builder AI](https://github.com/tobijpeg/bot-s/blob/main/src/workflow-ai.js): `src/workflow-ai.js`
- [Local workspace](https://github.com/tobijpeg/bot-s/blob/main/src/workspace-storage.js): `src/workspace-storage.js`

### Bot platform

- [Platform API](https://github.com/tobijpeg/bot-s/blob/main/server.js): `server.js`
- [Workflow runtime](https://github.com/tobijpeg/bot-s/blob/main/src/workflow-runtime.js): `src/workflow-runtime.js`
- [Inbox delivery](https://github.com/tobijpeg/bot-s/blob/main/src/inbox-delivery.js): `src/inbox-delivery.js`

### Accounts and data

- [Supabase client](https://github.com/tobijpeg/bot-s/blob/main/src/lib/supabase.js): `src/lib/supabase.js`
- **Supabase Auth and tables**

### Other components

- **Bot owner**
- **Telegram user**
- **Telegram Bot API**

## Connections

- Bot owner → Sign-in: signs in (evidence: `src/pages/Auth.jsx`)
- App routes → Sign-in: routes to (evidence: `src/App.jsx`)
- App routes → Workflow editor: routes to (evidence: `src/App.jsx`)
- App routes → Inbox: routes to (evidence: `src/App.jsx`)
- Sign-in → Supabase client: authenticates with (evidence: `src/pages/Auth.jsx`)
- Supabase client → Supabase Auth and tables: connects to (evidence: `src/lib/supabase.js`)
- Workspace state → Workflow model: creates default (evidence: `src/context/CreateBotContext.jsx`)
- Workspace state → Local workspace: reads and writes (evidence: `src/context/CreateBotContext.jsx`)
- Workflow editor → Workspace state: edits state (evidence: `src/pages/BotFlowEditor.jsx`)
- Workflow editor → Workflow model: edits schema (evidence: `src/pages/BotFlowEditor.jsx`)
- Workflow editor → Builder AI: requests generation (evidence: `src/pages/BotFlowEditor.jsx`)
- Bot owner → Workflow editor: builds bot (evidence: `README.md`)
- Workflow editor → API client: sends AI request (evidence: `src/pages/BotFlowEditor.jsx`)
- Workflow editor → API client: saves configuration (evidence: `src/pages/BotFlowEditor.jsx`)
- API client → Platform API: calls platform API (evidence: `README.md`)
- Platform API → Workflow model: loads schema (evidence: `server.js`)
- Platform API → Workflow runtime: uses runtime (evidence: `server.js`)
- Platform API → Telegram Bot API: polls and replies (evidence: `README.md`)
- Telegram user → Telegram Bot API: sends messages (evidence: `README.md`)
- Platform API → Inbox delivery: dispatches replies (evidence: `server.js`)
- Inbox → API client: calls API (evidence: `src/pages/Inbox.jsx`)
- Inbox → Supabase client: accesses data (evidence: `src/pages/Inbox.jsx`)
- Platform API → Supabase Auth and tables: stores bot and inbox data (evidence: `README.md`)
- Platform API → Supabase Auth and tables: stores encrypted tokens (evidence: `README.md`)
- Onboarding and tour → Supabase client: uses account data (evidence: `src/pages/Welcome.jsx`)
- Admin responses → Supabase client: loads responses (evidence: `src/pages/AdminResponses.jsx`)
- Settings and library → Supabase client: uses account data (evidence: `src/pages/Settings.jsx`)
- Settings and library → Local workspace: manages saved sequences (evidence: `src/pages/Settings.jsx`)
