# just2alim/bot-s architecture

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

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

## Overview

Bot(s) KZ is a web platform for creating, configuring, and operating Telegram bots. Owners authenticate, describe a business, optionally generate a draft with AI, edit a visual workflow, configure content and launch the bot; they can then manage bots and respond to customer messages in the inbox. The React client calls a Node.js API, which operates bots and connects to Supabase, Telegram, and Ollama. README documents server-side token encryption, inbox storage, onboarding, and the admin response view; unsampled server implementation limits detail on internal routing.

Main entry points: [`src/App.jsx`](https://github.com/just2alim/bot-s/blob/main/src/App.jsx) (Route application), [`src/context/CreateBotContext.jsx`](https://github.com/just2alim/bot-s/blob/main/src/context/CreateBotContext.jsx) (Bot workspace state), [`server.js`](https://github.com/just2alim/bot-s/blob/main/server.js) (Platform API & bot runtime), [`src/lib/api.js`](https://github.com/just2alim/bot-s/blob/main/src/lib/api.js) (API request helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Route application<br/>[App.jsx]"]
  node_auth["Account access<br/>[Auth.jsx]"]
  node_layout["Workspace shell<br/>[AppLayout.jsx]"]
  node_onboarding["Onboarding &amp; tour<br/>[Welcome.jsx]"]
  node_admin["Admin responses<br/>[AdminResponses.jsx]"]
end

subgraph group_authoring["Bot authoring"]
  node_workspace["Bot workspace state"]
  node_description["Business description &amp; AI draft"]
  node_structure["Feature setup"]
  node_workflow["Workflow model &amp; presets<br/>[workflow.js]"]
  node_editor["Visual flow editor<br/>[BotFlowEditor.jsx]"]
  node_botsetup["Bot content setup<br/>[CreateBotSetup.jsx]"]
  node_token["Telegram token setup<br/>[CreateBotToken.jsx]"]
  node_launch["Bot launch"]
  node_workspacecache["Workspace browser storage"]
end

subgraph group_platform["Bot platform"]
  node_api["Platform API &amp; bot runtime<br/>[server.js]"]
  node_apihelper["API request helper<br/>[api.js]"]
  node_safety["AI safety checks<br/>[ai-safety.js]"]
  node_supabaseclient["Supabase client<br/>[supabase.js]"]
end

subgraph group_operations["Owner operations"]
  node_mybots["Bot management<br/>[MyBots.jsx]"]
  node_inbox["Customer inbox<br/>[Inbox.jsx]"]
  node_settings["Account settings<br/>[Settings.jsx]"]
end

subgraph group_services["External services"]
  node_database[("Supabase application data<br/>[schema.sql]")]
  node_secrets[("Encrypted bot secrets<br/>[schema.sql]")]
  node_telegram{{"Telegram API"}}
  node_ollama{{"Ollama model"}}
end

node_owner(("Bot owner"))

node_owner -->|"uses"| node_app
node_app -->|"routes to"| node_auth
node_app -->|"routes through"| node_layout
node_app -->|"routes to"| node_description
node_app -->|"routes to"| node_structure
node_app -->|"routes to"| node_editor
node_app -->|"routes to"| node_botsetup
node_app -->|"routes to"| node_token
node_app -->|"routes to"| node_launch
node_app -->|"routes to"| node_mybots
node_app -->|"routes to"| node_inbox
node_app -->|"routes to"| node_settings
node_app -->|"routes to"| node_onboarding
node_app -->|"routes to"| node_admin
node_layout -->|"checks session"| node_supabaseclient
node_layout -->|"gates workspace"| node_onboarding
node_auth -->|"authenticates with"| node_supabaseclient
node_description -->|"updates"| node_workspace
node_description -->|"sends AI requests"| node_apihelper
node_editor -->|"edits"| node_workflow
node_editor -->|"loads and updates"| node_workspace
node_editor -->|"saves configuration"| node_apihelper
node_workspace -->|"creates defaults"| node_workflow
node_workspace -->|"persists state"| node_workspacecache
node_workspace -->|"tracks auth session"| node_supabaseclient
node_botsetup -->|"updates"| node_workspace
node_structure -->|"updates"| node_workspace
node_token -->|"updates"| node_workspace
node_launch -->|"reads configuration"| node_workspace
node_launch -->|"requests launch"| node_apihelper
node_apihelper -->|"forwards requests"| node_api
node_api -->|"polls and operates bots"| node_telegram
node_api -->|"requests builder AI"| node_ollama
node_api -->|"reads and writes app data"| node_database
node_api -->|"stores encrypted tokens"| node_secrets
node_api -->|"uses safety checks"| node_safety
node_mybots -->|"manages bots"| node_apihelper
node_inbox -->|"loads inbox data"| node_supabaseclient
node_inbox -->|"sends owner actions"| node_apihelper
node_api -->|"persists customer messages"| node_database
node_admin -->|"loads responses"| node_supabaseclient
node_settings -->|"reads account data"| node_supabaseclient
node_settings -->|"updates platform settings"| node_apihelper
node_onboarding -->|"saves onboarding"| node_supabaseclient

click node_app "https://github.com/just2alim/bot-s/blob/main/src/App.jsx"
click node_auth "https://github.com/just2alim/bot-s/blob/main/src/pages/Auth.jsx"
click node_layout "https://github.com/just2alim/bot-s/blob/main/src/layouts/AppLayout.jsx"
click node_onboarding "https://github.com/just2alim/bot-s/blob/main/src/pages/Welcome.jsx"
click node_admin "https://github.com/just2alim/bot-s/blob/main/src/pages/AdminResponses.jsx"
click node_workspace "https://github.com/just2alim/bot-s/blob/main/src/context/CreateBotContext.jsx"
click node_description "https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotDescribe.jsx"
click node_structure "https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotStructure.jsx"
click node_workflow "https://github.com/just2alim/bot-s/blob/main/src/workflow.js"
click node_editor "https://github.com/just2alim/bot-s/blob/main/src/pages/BotFlowEditor.jsx"
click node_botsetup "https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotSetup.jsx"
click node_token "https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotToken.jsx"
click node_launch "https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotLaunch.jsx"
click node_workspacecache "https://github.com/just2alim/bot-s/blob/main/src/workspace-storage.js"
click node_mybots "https://github.com/just2alim/bot-s/blob/main/src/pages/MyBots.jsx"
click node_inbox "https://github.com/just2alim/bot-s/blob/main/src/pages/Inbox.jsx"
click node_settings "https://github.com/just2alim/bot-s/blob/main/src/pages/Settings.jsx"
click node_api "https://github.com/just2alim/bot-s/blob/main/server.js"
click node_apihelper "https://github.com/just2alim/bot-s/blob/main/src/lib/api.js"
click node_safety "https://github.com/just2alim/bot-s/blob/main/src/ai-safety.js"
click node_supabaseclient "https://github.com/just2alim/bot-s/blob/main/src/lib/supabase.js"
click node_database "https://github.com/just2alim/bot-s/blob/main/supabase/schema.sql"
click node_secrets "https://github.com/just2alim/bot-s/blob/main/supabase/schema.sql"

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_auth,node_layout,node_onboarding,node_admin toneBlue
class node_workspace,node_description,node_structure,node_workflow,node_editor,node_botsetup,node_token,node_launch,node_workspacecache toneAmber
class node_api,node_apihelper,node_safety,node_supabaseclient toneMint
class node_mybots,node_inbox,node_settings toneRose
class node_database,node_secrets,node_telegram,node_ollama,node_owner toneIndigo
```

## Components

### Web application

- [Route application](https://github.com/just2alim/bot-s/blob/main/src/App.jsx): `src/App.jsx`
- [Account access](https://github.com/just2alim/bot-s/blob/main/src/pages/Auth.jsx): `src/pages/Auth.jsx`
- [Workspace shell](https://github.com/just2alim/bot-s/blob/main/src/layouts/AppLayout.jsx): `src/layouts/AppLayout.jsx`
- [Onboarding & tour](https://github.com/just2alim/bot-s/blob/main/src/pages/Welcome.jsx): `src/pages/Welcome.jsx`
- [Admin responses](https://github.com/just2alim/bot-s/blob/main/src/pages/AdminResponses.jsx): `src/pages/AdminResponses.jsx`

### Bot authoring

- [Bot workspace state](https://github.com/just2alim/bot-s/blob/main/src/context/CreateBotContext.jsx): `src/context/CreateBotContext.jsx`
- [Business description & AI draft](https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotDescribe.jsx): `src/pages/CreateBotDescribe.jsx`
- [Feature setup](https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotStructure.jsx): `src/pages/CreateBotStructure.jsx`
- [Workflow model & presets](https://github.com/just2alim/bot-s/blob/main/src/workflow.js): `src/workflow.js`
- [Visual flow editor](https://github.com/just2alim/bot-s/blob/main/src/pages/BotFlowEditor.jsx): `src/pages/BotFlowEditor.jsx`
- [Bot content setup](https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotSetup.jsx): `src/pages/CreateBotSetup.jsx`
- [Telegram token setup](https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotToken.jsx): `src/pages/CreateBotToken.jsx`
- [Bot launch](https://github.com/just2alim/bot-s/blob/main/src/pages/CreateBotLaunch.jsx): `src/pages/CreateBotLaunch.jsx`
- [Workspace browser storage](https://github.com/just2alim/bot-s/blob/main/src/workspace-storage.js): `src/workspace-storage.js`

### Bot platform

- [Platform API & bot runtime](https://github.com/just2alim/bot-s/blob/main/server.js): `server.js`
- [API request helper](https://github.com/just2alim/bot-s/blob/main/src/lib/api.js): `src/lib/api.js`
- [AI safety checks](https://github.com/just2alim/bot-s/blob/main/src/ai-safety.js): `src/ai-safety.js`
- [Supabase client](https://github.com/just2alim/bot-s/blob/main/src/lib/supabase.js): `src/lib/supabase.js`

### Owner operations

- [Bot management](https://github.com/just2alim/bot-s/blob/main/src/pages/MyBots.jsx): `src/pages/MyBots.jsx`
- [Customer inbox](https://github.com/just2alim/bot-s/blob/main/src/pages/Inbox.jsx): `src/pages/Inbox.jsx`
- [Account settings](https://github.com/just2alim/bot-s/blob/main/src/pages/Settings.jsx): `src/pages/Settings.jsx`

### External services

- [Supabase application data](https://github.com/just2alim/bot-s/blob/main/supabase/schema.sql): `supabase/schema.sql`
- [Encrypted bot secrets](https://github.com/just2alim/bot-s/blob/main/supabase/schema.sql): `supabase/schema.sql`
- **Telegram API**
- **Ollama model**

### Other components

- **Bot owner**

## Connections

- Bot owner → Route application: uses (evidence: `README.md`)
- Route application → Account access: routes to (evidence: `src/App.jsx`)
- Route application → Workspace shell: routes through (evidence: `src/App.jsx`)
- Route application → Business description & AI draft: routes to (evidence: `src/App.jsx`)
- Route application → Feature setup: routes to (evidence: `src/App.jsx`)
- Route application → Visual flow editor: routes to (evidence: `src/App.jsx`)
- Route application → Bot content setup: routes to (evidence: `src/App.jsx`)
- Route application → Telegram token setup: routes to (evidence: `src/App.jsx`)
- Route application → Bot launch: routes to (evidence: `src/App.jsx`)
- Route application → Bot management: routes to (evidence: `src/App.jsx`)
- Route application → Customer inbox: routes to (evidence: `src/App.jsx`)
- Route application → Account settings: routes to (evidence: `src/App.jsx`)
- Route application → Onboarding & tour: routes to (evidence: `src/App.jsx`)
- Route application → Admin responses: routes to (evidence: `src/App.jsx`)
- Workspace shell → Supabase client: checks session (evidence: `src/layouts/AppLayout.jsx`)
- Workspace shell → Onboarding & tour: gates workspace (evidence: `src/layouts/AppLayout.jsx`)
- Account access → Supabase client: authenticates with (evidence: `src/pages/Auth.jsx`)
- Business description & AI draft → Bot workspace state: updates (evidence: `src/pages/CreateBotDescribe.jsx`)
- Business description & AI draft → API request helper: sends AI requests (evidence: `src/pages/CreateBotDescribe.jsx`)
- Visual flow editor → Workflow model & presets: edits (evidence: `src/pages/BotFlowEditor.jsx`)
- Visual flow editor → Bot workspace state: loads and updates (evidence: `src/pages/BotFlowEditor.jsx`)
- Visual flow editor → API request helper: saves configuration (evidence: `src/pages/BotFlowEditor.jsx`)
- Bot workspace state → Workflow model & presets: creates defaults (evidence: `src/context/CreateBotContext.jsx`)
- Bot workspace state → Workspace browser storage: persists state (evidence: `src/context/CreateBotContext.jsx`)
- Bot workspace state → Supabase client: tracks auth session (evidence: `src/context/CreateBotContext.jsx`)
- Bot content setup → Bot workspace state: updates (evidence: `src/context/CreateBotContext.jsx`)
- Feature setup → Bot workspace state: updates (evidence: `src/context/CreateBotContext.jsx`)
- Telegram token setup → Bot workspace state: updates (evidence: `src/pages/CreateBotToken.jsx`)
- Bot launch → Bot workspace state: reads configuration (evidence: `src/pages/CreateBotLaunch.jsx`)
- Bot launch → API request helper: requests launch (evidence: `src/pages/CreateBotLaunch.jsx`)
- API request helper → Platform API & bot runtime: forwards requests (evidence: `README.md`)
- Platform API & bot runtime → Telegram API: polls and operates bots (evidence: `README.md`)
- Platform API & bot runtime → Ollama model: requests builder AI (evidence: `README.md`)
- Platform API & bot runtime → Supabase application data: reads and writes app data (evidence: `README.md`)
- Platform API & bot runtime → Encrypted bot secrets: stores encrypted tokens (evidence: `README.md`)
- Platform API & bot runtime → AI safety checks: uses safety checks (evidence: `server.js`)
- Bot management → API request helper: manages bots (evidence: `src/pages/MyBots.jsx`)
- Customer inbox → Supabase client: loads inbox data (evidence: `src/pages/Inbox.jsx`)
- Customer inbox → API request helper: sends owner actions (evidence: `src/pages/Inbox.jsx`)
- Platform API & bot runtime → Supabase application data: persists customer messages (evidence: `README.md`)
- Admin responses → Supabase client: loads responses (evidence: `src/pages/AdminResponses.jsx`)
- Account settings → Supabase client: reads account data (evidence: `src/pages/Settings.jsx`)
- Account settings → API request helper: updates platform settings (evidence: `src/pages/Settings.jsx`)
- Onboarding & tour → Supabase client: saves onboarding (evidence: `src/pages/Welcome.jsx`)
