// PART 01
Architecture overview
General Bots is one Rust server (botserver) plus a static front-end server (botui), a set of platform services, and an object store that holds the bots themselves. This page is the band-by-band map; later pages zoom into each band.
The bands
| Band | What it is | Where |
|---|---|---|
| Client surfaces | Suite (3000), Cloud (4000), Login (5000), desktop shell (Tauri) | botui/ui/*, botapp/ |
| Transport | Axum HTTP + WebSocket, auth middleware, rate limits | botserver/src/main_module/server/ |
| Application routes | Hand-written route modules + feature-crate routers | botserver/src/main_module/routes/, botserver/crates/*/ |
| Chat engine | WebSocket handler, message pipeline, BASIC runtime | botserver/src/core/bot/, botserver/src/basic/ |
| Intelligence | LLM providers, KB retrieval, MCP, agent VM | botllm, botqdrant, botagent, kb_context/ |
| State | PostgreSQL (Diesel), Valkey, Drive | botschema, botdrive, botcore |
| Platform services | Vault, Zitadel (directory), Qdrant, llama.cpp, mail, ALM | installed components |
Request flow
A chat turn travels through a fixed sequence of stages; the same order applies to every channel:
1. Transport WS handshake at /ws (or channel webhook POST)
2. Identity auth middleware / anonymous_auth resolves the user
3. Session session record + Redis flag (start.bas runs once)
4. Pipeline kb injection → prompt assembly → LLM / tool decision
5. Execution BASIC .ast run, __api_call__, MCP, agent VM
6. Delivery stream chunks over WS or post back to the channel
Non-chat HTTP requests take a shorter path: transport → identity → route handler → Diesel/Drive/cache → JSON or HTMX fragment.
Where state lives
| Store | Holds | Accessed by |
|---|---|---|
| PostgreSQL | users, bots, sessions, message history, tool metadata, feature tables | Diesel, all tables declared in botschema |
| Drive (OtterIO, S3-compatible) | bot packages ({bot}.gbai), KB documents, user files |
botdrive, drive monitors |
| Valkey | suggestions, publish ledger, pub/sub, rate counters | cache client |
| Qdrant | KB embeddings | botqdrant, retrieval |
| Vault | credentials, LLM configuration | botcoresecrets, config |
A restart may drop in-process maps; the durable sources above rebuild them. The process-state contract (which maps are volatile, which mirror to Redis or PostgreSQL, with which TTL) is documented row by row in the observability chapter.
Boot order
main_module::init performs the bootstrap: load configuration, connect Vault,
create the database pool, run Diesel migrations, connect the cache, build the
LLM provider from Vault, then start the Axum server, the drive monitors and
background loops. Only after the health probe answers are the UI surfaces
considered usable — the desktop shell, for instance, polls /api/product
before showing its window.
Module dependency shape
botserver(binary) mounts everything; no crate depends on it.- Feature crates depend on
botcore,botbasic_types,botlib,botschemaand each other through explicit Cargo dependencies — never on the binary. botschemais the only crate allowed to declare Dieseltable!macros; feature crates re-export what they use.- The BASIC keyword families (
botbasic_*) register into the engine hosted bybotserver/src/basic/; they do not call HTTP routes directly.
Reading the architecture in the source
| Question | File |
|---|---|
| What is mounted at boot? | botserver/src/main_module/mod.rs, botserver/src/core/mod.rs |
| Which features compile in? | [features] in botserver/Cargo.toml |
| Which crates exist and why? | botserver/crates/*/Cargo.toml (description field) |
| How does a turn flow? | botserver/src/core/bot/pipeline/ (stage modules) |
| What data exists? | botschema/src/**, botserver/migrations/ |