# googol23/bd1 architecture

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

- Interactive diagram: https://gitdiagram.com/googol23/bd1
- Repository: https://github.com/googol23/bd1

## Overview

BD-1 is a local text-chat and simulated robot-control prototype, with a separate local visual interface and an offline-capable voice-session boundary. Text requests route to chat, metadata, capability, clarification, or simulated-action handling; actions pass deterministic policy checks before changing in-memory simulation state. Receipts are audited locally. The graph also preserves dialogue, intent, and voice components, but their unshown internal wiring is omitted. The README documents no hardware or persistent state; unsampled modules and integrations are not inferred beyond indexed references.

Main entry points: [`core.py`](https://github.com/googol23/bd1/blob/master/core.py) (Text request handler), [`bd1/ui/server.py`](https://github.com/googol23/bd1/blob/master/bd1/ui/server.py) (Visual API server), [`bd1/policy.py`](https://github.com/googol23/bd1/blob/master/bd1/policy.py) (Action policy), [`bd1/llm.py`](https://github.com/googol23/bd1/blob/master/bd1/llm.py) (Ollama adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_text_entry["Text chat entry<br/>[app.py]"]
  node_visual_server["Visual API server<br/>[server.py]"]
  node_visual_assets["Visual UI assets<br/>[index.html]"]
  node_voice_session["Voice session<br/>[session.py]"]
  node_voice_adapters["Mock audio adapters<br/>[mock.py]"]
end

subgraph group_conversation["Conversation handling"]
  node_text_core["Text request handler<br/>[core.py]"]
  node_router["Request router<br/>[router.py]"]
  node_intent["Intent handling<br/>[intent.py]"]
  node_dialogue["Dialogue context<br/>[dialogue.py]"]
  node_metadata["Model metadata<br/>[metadata.py]"]
end

subgraph group_simulation["Simulation and policy"]
  node_policy["Action policy<br/>[policy.py]"]
  node_registry["Tool registry<br/>[registry.py]"]
  node_controller["Simulation controller<br/>[controller.py]"]
  node_sim_state[("Simulation state<br/>[state.py]")]
end

subgraph group_services["Local services"]
  node_ollama_adapter["Ollama adapter<br/>[llm.py]"]
  node_audit[("Audit log<br/>[audit.py]")]
end

node_user(("User"))
node_ollama(("Local Ollama"))
node_browser(("Local browser"))

node_user -->|"sends text"| node_text_entry
node_text_entry -->|"calls"| node_text_core
node_text_core -->|"routes via"| node_router
node_text_core -->|"builds context"| node_dialogue
node_text_core -->|"fetches metadata"| node_metadata
node_text_core -->|"dispatches actions"| node_policy
node_text_core -->|"requests chat"| node_ollama_adapter
node_ollama_adapter -->|"calls local API"| node_ollama
node_text_core -->|"records result"| node_audit
node_voice_session -->|"handles confirmed text"| node_text_core
node_voice_session -.->|"uses injected adapters"| node_voice_adapters
node_policy -->|"validates tools"| node_registry
node_policy -->|"executes action"| node_controller
node_controller -->|"reads and updates"| node_sim_state
node_user -->|"uses visual view"| node_visual_server
node_visual_server -->|"serves assets"| node_visual_assets
node_visual_server -->|"dispatches actions"| node_policy
node_visual_server -->|"records result"| node_audit
node_browser -.->|"requests local API"| node_visual_server
node_intent -.->|"references"| node_ollama_adapter
node_intent -.->|"references"| node_registry

click node_text_entry "https://github.com/googol23/bd1/blob/master/app.py"
click node_visual_server "https://github.com/googol23/bd1/blob/master/bd1/ui/server.py"
click node_visual_assets "https://github.com/googol23/bd1/blob/master/bd1/ui/index.html"
click node_voice_session "https://github.com/googol23/bd1/blob/master/bd1/audio/session.py"
click node_voice_adapters "https://github.com/googol23/bd1/blob/master/bd1/audio/mock.py"
click node_text_core "https://github.com/googol23/bd1/blob/master/core.py"
click node_router "https://github.com/googol23/bd1/blob/master/bd1/router.py"
click node_intent "https://github.com/googol23/bd1/blob/master/bd1/intent.py"
click node_dialogue "https://github.com/googol23/bd1/blob/master/bd1/dialogue.py"
click node_metadata "https://github.com/googol23/bd1/blob/master/bd1/metadata.py"
click node_policy "https://github.com/googol23/bd1/blob/master/bd1/policy.py"
click node_registry "https://github.com/googol23/bd1/blob/master/bd1/tools/registry.py"
click node_controller "https://github.com/googol23/bd1/blob/master/bd1/controller.py"
click node_sim_state "https://github.com/googol23/bd1/blob/master/bd1/state.py"
click node_ollama_adapter "https://github.com/googol23/bd1/blob/master/bd1/llm.py"
click node_audit "https://github.com/googol23/bd1/blob/master/bd1/audit.py"

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_text_entry,node_visual_server,node_visual_assets,node_voice_session,node_voice_adapters,node_user,node_browser toneBlue
class node_text_core,node_router,node_intent,node_dialogue,node_metadata toneAmber
class node_policy,node_registry,node_controller,node_sim_state toneMint
class node_ollama_adapter,node_audit toneRose
class node_ollama toneIndigo
```

## Components

### User interfaces

- [Text chat entry](https://github.com/googol23/bd1/blob/master/app.py): `app.py`
- [Visual API server](https://github.com/googol23/bd1/blob/master/bd1/ui/server.py): `bd1/ui/server.py`
- [Visual UI assets](https://github.com/googol23/bd1/blob/master/bd1/ui/index.html): `bd1/ui/index.html`
- [Voice session](https://github.com/googol23/bd1/blob/master/bd1/audio/session.py): `bd1/audio/session.py`
- [Mock audio adapters](https://github.com/googol23/bd1/blob/master/bd1/audio/mock.py): `bd1/audio/mock.py`

### Conversation handling

- [Text request handler](https://github.com/googol23/bd1/blob/master/core.py): `core.py`
- [Request router](https://github.com/googol23/bd1/blob/master/bd1/router.py): `bd1/router.py`
- [Intent handling](https://github.com/googol23/bd1/blob/master/bd1/intent.py): `bd1/intent.py`
- [Dialogue context](https://github.com/googol23/bd1/blob/master/bd1/dialogue.py): `bd1/dialogue.py`
- [Model metadata](https://github.com/googol23/bd1/blob/master/bd1/metadata.py): `bd1/metadata.py`

### Simulation and policy

- [Action policy](https://github.com/googol23/bd1/blob/master/bd1/policy.py): `bd1/policy.py`
- [Tool registry](https://github.com/googol23/bd1/blob/master/bd1/tools/registry.py): `bd1/tools/registry.py`
- [Simulation controller](https://github.com/googol23/bd1/blob/master/bd1/controller.py): `bd1/controller.py`
- [Simulation state](https://github.com/googol23/bd1/blob/master/bd1/state.py): `bd1/state.py`

### Local services

- [Ollama adapter](https://github.com/googol23/bd1/blob/master/bd1/llm.py): `bd1/llm.py`
- [Audit log](https://github.com/googol23/bd1/blob/master/bd1/audit.py): `bd1/audit.py`

### Other components

- **User**
- **Local Ollama**
- **Local browser**

## Connections

- User → Text chat entry: sends text (evidence: `README.txt`)
- Text chat entry → Text request handler: calls (evidence: `app.py`)
- Text request handler → Request router: routes via (evidence: `core.py`)
- Text request handler → Dialogue context: builds context (evidence: `core.py`)
- Text request handler → Model metadata: fetches metadata (evidence: `core.py`)
- Text request handler → Action policy: dispatches actions (evidence: `core.py`)
- Text request handler → Ollama adapter: requests chat (evidence: `core.py`)
- Ollama adapter → Local Ollama: calls local API (evidence: `bd1/llm.py`)
- Text request handler → Audit log: records result (evidence: `core.py`)
- Voice session → Text request handler: handles confirmed text (evidence: `bd1/audio/session.py`)
- Voice session → Mock audio adapters: uses injected adapters (evidence: `bd1/audio/mock.py`)
- Action policy → Tool registry: validates tools (evidence: `bd1/policy.py`)
- Action policy → Simulation controller: executes action (evidence: `bd1/policy.py`)
- Simulation controller → Simulation state: reads and updates (evidence: `bd1/controller.py`)
- User → Visual API server: uses visual view (evidence: `README.txt`)
- Visual API server → Visual UI assets: serves assets (evidence: `bd1/ui/server.py`)
- Visual API server → Action policy: dispatches actions (evidence: `bd1/ui/server.py`)
- Visual API server → Audit log: records result (evidence: `bd1/ui/server.py`)
- Local browser → Visual API server: requests local API
- Intent handling → Ollama adapter: references (evidence: `bd1/intent.py`)
- Intent handling → Tool registry: references (evidence: `bd1/intent.py`)
