Skip to content

Architecture Overview 🟑 BETA

botserver is a single Rust binary wired to feature libraries, an Axum HTTP surface, a Rhai-based BASIC interpreter and a set of external services.

Overview of the running platform: clients and channels, the front ends, botserver transport and pipeline, engines, data services and operations.

Layers

Layer Where in the repository Owns
Entry point botserver/src/main.rs Feature-gated module declarations.
Server wiring botserver/src/main_module/ Routes, drive monitors and boot work.
Bot pipeline botserver/src/core/bot/ Message handling, context, tools and runs.
BASIC botserver/src/basic/keywords/ and botserver/crates/botbasic_*/src/keywords/ Keyword registrations.
App catalog botserver/src/apps/registry/ all_apps() entries, categories and ownership.
Feature crates botserver/crates/*/ Independently compiled capabilities.
Schema botschema/src/ and botserver/migrations/ Diesel declarations and SQL migrations.

The diagrams below are the existing architecture drawings. They are navigation aids; the table above and the crate manifests are the authorities.

System architecture diagram of botserver.

Data flow diagram of botserver.

Module dependency diagram of botserver.

Request flow

channel β†’ channel adapter β†’ session β†’ BASIC/context β†’ optional LLM β†’ response β†’ channel

The WebSocket path is the primary chat surface. A message of type 6 (TOOL_EXEC) runs a tool script directly through Rhai without an LLM call; other messages may receive knowledge-base context before generation. The message-type contract is recorded in the root AGENTS.md.

Storage

Concern Service Authority
Relational data PostgreSQL, accessed through Diesel root AGENTS.md; schema in botschema
Files and bot content OtterIO (Drive), S3-compatible root AGENTS.md; botserver/3rdparty.toml
Cache and session data Valkey (Redis-compatible) root AGENTS.md; botserver/3rdparty.toml
Vectors Qdrant root AGENTS.md; botserver/3rdparty.toml

Security boundary

Authentication, authorization and session management are implemented in the botsecurity-auth crate; shared guards and sanitizers are in botsecurity-core. Secrets are read from Vault (or the bundled OpenBao in the desktop edition) β€” never from a documentation file. State-changing HTTP endpoints require CSRF protection unless they use Bearer-token auth; this rule is in the root AGENTS.md.

Deployment shape

Production runs on Incus containers, with Caddy as the reverse proxy. The container inventory and the ports are in the root AGENTS.md; the component downloads and checksums are in botserver/3rdparty.toml. The operator-facing procedures are runbooks: Container Deployment, Infrastructure, Scaling and Observability.

Limits

Claim Status
Framework Axum and Diesel. Older prose naming Actix-Web or SQLx is wrong.
Model names, chunk sizes, top-k and thresholds Not asserted here; none are stable enough to document from prose.
Future architecture plans Roadmaps live in GitHub issues, not in this book.
Database encryption at rest Not claimed; read the storage authority before asserting it.