// PART 01
Module and service structure
The service layer is the set of in-process modules botserver mounts at boot.
It is not a list of crates: crates live in botserver/crates/* (see
Module Structure) and are reached through Cargo features.
Authority for this page: botserver/src/main_module/mod.rs,
botserver/src/core/mod.rs and the directories they declare.
main_module/ — process wiring
Declared in botserver/src/main_module/mod.rs:
| Module | Responsibility |
|---|---|
init / init_tasks |
bootstrap sequence, task scheduler start-up |
server/ |
Axum server, auth layer, rate limits, fallback responses |
routes/ |
hand-written route modules (chat_handlers.rs, product_handlers.rs, catalog.rs, org_handlers/, feature_routers/, …) |
drive_monitors/ |
Drive (OtterIO .gbai) scanning, bot discovery, reload on ETag change |
git_bot_monitor/ |
pulls git-owned bots every 15 s into the work dir |
state_builder.rs |
assembles AppState from config, pools and caches |
background.rs, auto_service.rs |
long-running loops |
event_dispatcher.rs, channel_delivery.rs |
outbound event and channel fan-out |
ui_plan/ |
__ui_plan__ handling for the web channel |
wizard_provision/ |
first-run provisioning of stack components |
health.rs, shutdown.rs, migrations.rs |
health probes, graceful shutdown, Diesel migrations |
core/ — runtime state and engines
| Module | Responsibility |
|---|---|
state.rs |
AppState shared by every handler |
config.rs, config_reload.rs |
configuration read/reload |
secrets/ |
Vault-backed secret resolution |
session/ |
user session records and lifecycle |
bot/ |
chat engine: ws/ (handshake, frames, streaming), pipeline/, api_catalog/, endpoint_inventory*.rs, kb_context/, sandbox/, runs/ |
directory/ |
Zitadel-backed directory operations |
oauth/ |
OAuth flows |
home_site.rs, peer_network*.rs |
per-tenant home sites and peer federation |
user_memory.rs, desktop_activity.rs, computer_use.rs |
memory hooks, desktop and computer-use surfaces |
ai_accounts*.rs |
per-tenant LLM account records |
basic/ — script host
The BASIC host wires the compiler and the keyword crates into a Rhai engine:
| Concern | Where |
|---|---|
Compiler (.bas → .ast), tool parsing, goto conversion |
botbasic_compiler crate |
| Keyword families (arrays, hearing, data, comms, AI, system) | botserver/crates/botbasic_*/src/keywords/ |
| Host-local keywords and registration glue | botserver/src/basic/keywords/ |
Tool definitions compiled from PARAM/DESCRIPTION headers |
basic_tools table, Drive monitor |
apps/ and security/
| Module | Responsibility |
|---|---|
apps/registry/ |
the suite app catalog (all_apps(), entries.rs, entries_extra.rs) |
apps/commands/ |
AppCommand catalog and verb→route bindings for chat-driven office actions |
apps/integration_catalog/ |
integration provider seeds, credentials, actions |
security/ |
SafeCommand, log_and_sanitize, SQL identifier guards, role resolution (user_role.rs) |
soon_features.rs |
retired file: present in the tree, never declared in the module tree, never compiled |
How crates are mounted
Feature crates expose routers and services; the host mounts them when the
matching Cargo feature is compiled in. A crate that is not in the selected
feature set contributes nothing to the binary. This is why the same source
tree produces profiles as different as minimal (chat only) and full
(the wide server profile) — see Runtime model and product profiles.
What is deliberately not here
- No plugin loader for Rust code. Extension is via crates + feature flags, BASIC keywords, MCP servers, and the skills catalog — not dynamic Rust libraries.
- No microservice split. Channels, LLM providers and domain features run in-process; the process boundary is the container boundary, not a crate boundary.