# des1red/vex architecture

> Architecture diagram of the GitHub repository des1red/vex, 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/des1red/vex
- Repository: https://github.com/des1red/vex

## Overview

Vex is a local-first conversational runtime: users submit text through its terminal or optional LAN web interface, and the runtime handles requests with deterministic intent and knowledge logic before allowing a controlled local Ollama fallback. Its documented capabilities also include interactive command execution, system and file tools, diagnostics, and first-run model setup. The graph preserves these product branches; several connections are dashed because their wiring was not visible in the sampled source.

Main entry points: [`internal/communication/responder/responder.go`](https://github.com/des1red/vex/blob/main/internal/communication/responder/responder.go) (Responder), [`internal/library/knowledge.go`](https://github.com/des1red/vex/blob/main/internal/library/knowledge.go) (Knowledge library), [`internal/communication/responder/fallback/llm_fallback.go`](https://github.com/des1red/vex/blob/main/internal/communication/responder/fallback/llm_fallback.go) (LLM fallback policy), [`cmd/runtime.go`](https://github.com/des1red/vex/blob/main/cmd/runtime.go) (CLI lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_terminal["Terminal driver<br/>[terminal_driver.go]"]
  node_web["Web server<br/>[server.go]"]
  node_interaction["Interaction layer<br/>[interaction.go]"]
end

subgraph group_conversation["Conversation pipeline"]
  node_handler["Event handler<br/>[handle_event.go]"]
  node_intent["Intent classifier<br/>[classifier.go]"]
  node_responder["Responder<br/>[responder.go]"]
  node_fallback["LLM fallback policy<br/>[llm_fallback.go]"]
end

subgraph group_capabilities["Knowledge and tools"]
  node_knowledge["Knowledge library<br/>[knowledge.go]"]
  node_social["Social answers<br/>[question.go]"]
  node_math["Math answers<br/>[answer.go]"]
  node_system["System commands<br/>[help.go]"]
  node_tools["File and system tools<br/>[answer.go]"]
  node_execution["Execution sessions<br/>[manager_command.go]"]
end

subgraph group_runtime["Runtime services"]
  node_state["Runtime state<br/>[state.go]"]
  node_memory["Conversation memory<br/>[memory.go]"]
  node_llm["Local LLM<br/>[llm.go]"]
end

subgraph group_operations["Setup and management"]
  node_bootstrap["Model bootstrap<br/>[install.go]"]
  node_doctor["Diagnostics<br/>[doctor.go]"]
  node_cli["CLI lifecycle<br/>[runtime.go]"]
end

node_user(("User"))

node_user -.->|"enters text"| node_terminal
node_user -.->|"submits text"| node_web
node_web -->|"injects text"| node_interaction
node_terminal -.->|"submits text"| node_interaction
node_interaction -.->|"dispatches events"| node_handler
node_handler -.->|"classifies input"| node_intent
node_intent -.->|"routes intent"| node_responder
node_responder -.->|"checks knowledge"| node_knowledge
node_knowledge -.->|"matches questions"| node_social
node_knowledge -.->|"answers calculations"| node_math
node_knowledge -.->|"handles commands"| node_system
node_responder -.->|"requests fallback"| node_fallback
node_fallback -->|"invokes inference"| node_llm
node_fallback -->|"reads and updates"| node_memory
node_llm -->|"reads mode"| node_state
node_responder -.->|"offers tools"| node_tools
node_tools -.->|"manages sessions"| node_execution
node_execution -->|"reads session state"| node_state
node_user -.->|"runs commands"| node_cli
node_cli -.->|"starts setup"| node_bootstrap
node_cli -.->|"requests diagnostics"| node_doctor

click node_terminal "https://github.com/des1red/vex/blob/main/internal/communication/interaction/drivers/terminal_driver.go"
click node_web "https://github.com/des1red/vex/blob/main/internal/web/server.go"
click node_interaction "https://github.com/des1red/vex/blob/main/internal/communication/interaction/interaction.go"
click node_handler "https://github.com/des1red/vex/blob/main/internal/communication/handler/handle_event.go"
click node_intent "https://github.com/des1red/vex/blob/main/internal/communication/intent/classifier.go"
click node_responder "https://github.com/des1red/vex/blob/main/internal/communication/responder/responder.go"
click node_knowledge "https://github.com/des1red/vex/blob/main/internal/library/knowledge.go"
click node_social "https://github.com/des1red/vex/blob/main/internal/library/social/question.go"
click node_math "https://github.com/des1red/vex/blob/main/internal/library/math/answer.go"
click node_system "https://github.com/des1red/vex/blob/main/internal/library/system/help.go"
click node_tools "https://github.com/des1red/vex/blob/main/internal/library/tools/answer.go"
click node_execution "https://github.com/des1red/vex/blob/main/internal/library/tools/execution/manager_command.go"
click node_state "https://github.com/des1red/vex/blob/main/internal/state/state.go"
click node_memory "https://github.com/des1red/vex/blob/main/internal/communication/memory/memory.go"
click node_fallback "https://github.com/des1red/vex/blob/main/internal/communication/responder/fallback/llm_fallback.go"
click node_llm "https://github.com/des1red/vex/blob/main/internal/llm/llm.go"
click node_bootstrap "https://github.com/des1red/vex/blob/main/internal/bootstrap/install.go"
click node_doctor "https://github.com/des1red/vex/blob/main/internal/doctor/doctor.go"
click node_cli "https://github.com/des1red/vex/blob/main/cmd/runtime.go"

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_terminal,node_web,node_interaction,node_user toneBlue
class node_handler,node_intent,node_responder,node_fallback toneAmber
class node_knowledge,node_social,node_math,node_system,node_tools,node_execution toneMint
class node_state,node_memory,node_llm toneRose
class node_bootstrap,node_doctor,node_cli toneIndigo
```

## Components

### User interfaces

- [Terminal driver](https://github.com/des1red/vex/blob/main/internal/communication/interaction/drivers/terminal_driver.go): `internal/communication/interaction/drivers/terminal_driver.go`
- [Web server](https://github.com/des1red/vex/blob/main/internal/web/server.go): `internal/web/server.go`
- [Interaction layer](https://github.com/des1red/vex/blob/main/internal/communication/interaction/interaction.go): `internal/communication/interaction/interaction.go`

### Conversation pipeline

- [Event handler](https://github.com/des1red/vex/blob/main/internal/communication/handler/handle_event.go): `internal/communication/handler/handle_event.go`
- [Intent classifier](https://github.com/des1red/vex/blob/main/internal/communication/intent/classifier.go): `internal/communication/intent/classifier.go`
- [Responder](https://github.com/des1red/vex/blob/main/internal/communication/responder/responder.go): `internal/communication/responder/responder.go`
- [LLM fallback policy](https://github.com/des1red/vex/blob/main/internal/communication/responder/fallback/llm_fallback.go): `internal/communication/responder/fallback/llm_fallback.go`

### Knowledge and tools

- [Knowledge library](https://github.com/des1red/vex/blob/main/internal/library/knowledge.go): `internal/library/knowledge.go`
- [Social answers](https://github.com/des1red/vex/blob/main/internal/library/social/question.go): `internal/library/social/question.go`
- [Math answers](https://github.com/des1red/vex/blob/main/internal/library/math/answer.go): `internal/library/math/answer.go`
- [System commands](https://github.com/des1red/vex/blob/main/internal/library/system/help.go): `internal/library/system/help.go`
- [File and system tools](https://github.com/des1red/vex/blob/main/internal/library/tools/answer.go): `internal/library/tools/answer.go`
- [Execution sessions](https://github.com/des1red/vex/blob/main/internal/library/tools/execution/manager_command.go): `internal/library/tools/execution/manager_command.go`

### Runtime services

- [Runtime state](https://github.com/des1red/vex/blob/main/internal/state/state.go): `internal/state/state.go`
- [Conversation memory](https://github.com/des1red/vex/blob/main/internal/communication/memory/memory.go): `internal/communication/memory/memory.go`
- [Local LLM](https://github.com/des1red/vex/blob/main/internal/llm/llm.go): `internal/llm/llm.go`

### Setup and management

- [Model bootstrap](https://github.com/des1red/vex/blob/main/internal/bootstrap/install.go): `internal/bootstrap/install.go`
- [Diagnostics](https://github.com/des1red/vex/blob/main/internal/doctor/doctor.go): `internal/doctor/doctor.go`
- [CLI lifecycle](https://github.com/des1red/vex/blob/main/cmd/runtime.go): `cmd/runtime.go`

### Other components

- **User**

## Connections

- User → Terminal driver: enters text
- User → Web server: submits text
- Web server → Interaction layer: injects text (evidence: `internal/web/server.go`)
- Terminal driver → Interaction layer: submits text
- Interaction layer → Event handler: dispatches events
- Event handler → Intent classifier: classifies input
- Intent classifier → Responder: routes intent
- Responder → Knowledge library: checks knowledge
- Knowledge library → Social answers: matches questions
- Knowledge library → Math answers: answers calculations
- Knowledge library → System commands: handles commands
- Responder → LLM fallback policy: requests fallback
- LLM fallback policy → Local LLM: invokes inference (evidence: `internal/communication/responder/fallback/llm_fallback.go`)
- LLM fallback policy → Conversation memory: reads and updates (evidence: `internal/communication/responder/fallback/llm_fallback.go`)
- Local LLM → Runtime state: reads mode (evidence: `internal/llm/llm.go`)
- Responder → File and system tools: offers tools
- File and system tools → Execution sessions: manages sessions
- Execution sessions → Runtime state: reads session state (evidence: `internal/library/tools/execution/manager_command.go`)
- User → CLI lifecycle: runs commands
- CLI lifecycle → Model bootstrap: starts setup
- CLI lifecycle → Diagnostics: requests diagnostics
