# christopherkahler/base architecture

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

- Interactive diagram: https://gitdiagram.com/christopherkahler/base
- Repository: https://github.com/christopherkahler/base

## Overview

basemode is a Rust engine that builds a workspace knowledge graph and serves relevant context through Claude Code hooks. The main loop maps code and workspace knowledge, queries it at session and tool moments, then formats a bounded briefing for the agent. Persistent graph data also supports project knowledge, handoffs, operational signals, and graph exploration. The dashboard is a separate presentation surface. The README documents the product-level flow; some subsystem connections below are based on its descriptions because their implementation files were not sampled.

Main entry points: [`src/hook`](https://github.com/christopherkahler/base/tree/main/src/hook) (Hook pipeline), [`src/domain/query.rs`](https://github.com/christopherkahler/base/blob/main/src/domain/query.rs) (Context retrieval), [`src/domain/sync.rs`](https://github.com/christopherkahler/base/blob/main/src/domain/sync.rs) (Graph sync), [`src/store.rs`](https://github.com/christopherkahler/base/blob/main/src/store.rs) (Workspace graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mapping["Workspace mapping"]
  node_ast_extract["AST extraction"]
  node_doc_extract["Document extraction"]
  node_sync["Graph sync<br/>[sync.rs]"]
end

subgraph group_knowledge["Knowledge graph"]
  node_graph[("Workspace graph<br/>[store.rs]")]
  node_domain_rules["Domain rules<br/>[rules.rs]"]
  node_decisions["Decisions"]
  node_projects["Projects and tasks"]
end

subgraph group_briefing["Agent briefing"]
  node_query["Context retrieval<br/>[query.rs]"]
  node_graph_query["Graph Q&amp;A<br/>[graph_query.rs]"]
  node_hooks["Hook pipeline"]
  node_prompt["Prompt assembly<br/>[prompt.rs]"]
  node_match_log["Match history<br/>[match_log.rs]"]
end

subgraph group_operations["Sessions and operations"]
  node_session_state["Session state<br/>[session.rs]"]
  node_handoffs["Handoffs<br/>[handoff_show.rs]"]
  node_relay["Agent relay"]
end

subgraph group_surfaces["User surfaces"]
  node_dashboard["Dashboard<br/>[server.rs]"]
  node_panels["Dashboard panels"]
end

node_operator(("Operator"))
node_claude(("Claude Code"))

node_operator -->|"maps workspace"| node_sync
node_ast_extract -->|"provides code map"| node_sync
node_doc_extract -->|"extracts documents"| node_sync
node_sync -->|"writes graph"| node_graph
node_operator -->|"prompts agent"| node_claude
node_claude -->|"runs hooks"| node_hooks
node_hooks -->|"retrieves context"| node_query
node_query -->|"queries graph"| node_graph
node_query -->|"selects rules"| node_domain_rules
node_query -->|"selects decisions"| node_decisions
node_hooks -->|"assembles briefing"| node_prompt
node_prompt -->|"injects context"| node_claude
node_hooks -->|"tracks session"| node_session_state
node_hooks -->|"records matches"| node_match_log
node_operator -->|"asks graph"| node_graph_query
node_graph_query -->|"retrieves subgraph"| node_graph
node_operator -->|"manages knowledge"| node_projects
node_operator -->|"creates handoffs"| node_handoffs
node_hooks -->|"surfaces handoffs"| node_handoffs
node_hooks -->|"dispatches relay"| node_relay
node_operator -.->|"opens dashboard"| node_dashboard
node_dashboard -->|"serves panels"| node_panels

click node_ast_extract "https://github.com/christopherkahler/base/tree/main/scripts/ast"
click node_doc_extract "https://github.com/christopherkahler/base/tree/main/src/extract"
click node_sync "https://github.com/christopherkahler/base/blob/main/src/domain/sync.rs"
click node_graph "https://github.com/christopherkahler/base/blob/main/src/store.rs"
click node_domain_rules "https://github.com/christopherkahler/base/blob/main/src/domain/rules.rs"
click node_decisions "https://github.com/christopherkahler/base/blob/main/src/domain/global_decisions.rs"
click node_projects "https://github.com/christopherkahler/base/tree/main/src/crud"
click node_query "https://github.com/christopherkahler/base/blob/main/src/domain/query.rs"
click node_graph_query "https://github.com/christopherkahler/base/blob/main/src/graph_query.rs"
click node_hooks "https://github.com/christopherkahler/base/tree/main/src/hook"
click node_prompt "https://github.com/christopherkahler/base/blob/main/src/emit/prompt.rs"
click node_match_log "https://github.com/christopherkahler/base/blob/main/src/emit/match_log.rs"
click node_session_state "https://github.com/christopherkahler/base/blob/main/src/domain/session.rs"
click node_handoffs "https://github.com/christopherkahler/base/blob/main/src/crud/handoff_show.rs"
click node_relay "https://github.com/christopherkahler/base/tree/main/src/relay"
click node_dashboard "https://github.com/christopherkahler/base/blob/main/src/dashboard/server.rs"
click node_panels "https://github.com/christopherkahler/base/tree/main/dashboard/src/panels"

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_ast_extract,node_doc_extract,node_sync toneBlue
class node_graph,node_domain_rules,node_decisions,node_projects toneAmber
class node_query,node_graph_query,node_hooks,node_prompt,node_match_log toneMint
class node_session_state,node_handoffs,node_relay toneRose
class node_dashboard,node_panels,node_operator,node_claude toneIndigo
```

## Components

### Workspace mapping

- [AST extraction](https://github.com/christopherkahler/base/tree/main/scripts/ast): `scripts/ast`
- [Document extraction](https://github.com/christopherkahler/base/tree/main/src/extract): `src/extract`
- [Graph sync](https://github.com/christopherkahler/base/blob/main/src/domain/sync.rs): `src/domain/sync.rs`

### Knowledge graph

- [Workspace graph](https://github.com/christopherkahler/base/blob/main/src/store.rs): `src/store.rs`
- [Domain rules](https://github.com/christopherkahler/base/blob/main/src/domain/rules.rs): `src/domain/rules.rs`
- [Decisions](https://github.com/christopherkahler/base/blob/main/src/domain/global_decisions.rs): `src/domain/global_decisions.rs`
- [Projects and tasks](https://github.com/christopherkahler/base/tree/main/src/crud): `src/crud`

### Agent briefing

- [Context retrieval](https://github.com/christopherkahler/base/blob/main/src/domain/query.rs): `src/domain/query.rs`
- [Graph Q&A](https://github.com/christopherkahler/base/blob/main/src/graph_query.rs): `src/graph_query.rs`
- [Hook pipeline](https://github.com/christopherkahler/base/tree/main/src/hook): `src/hook`
- [Prompt assembly](https://github.com/christopherkahler/base/blob/main/src/emit/prompt.rs): `src/emit/prompt.rs`
- [Match history](https://github.com/christopherkahler/base/blob/main/src/emit/match_log.rs): `src/emit/match_log.rs`

### Sessions and operations

- [Session state](https://github.com/christopherkahler/base/blob/main/src/domain/session.rs): `src/domain/session.rs`
- [Handoffs](https://github.com/christopherkahler/base/blob/main/src/crud/handoff_show.rs): `src/crud/handoff_show.rs`
- [Agent relay](https://github.com/christopherkahler/base/tree/main/src/relay): `src/relay`

### User surfaces

- [Dashboard](https://github.com/christopherkahler/base/blob/main/src/dashboard/server.rs): `src/dashboard/server.rs`
- [Dashboard panels](https://github.com/christopherkahler/base/tree/main/dashboard/src/panels): `dashboard/src/panels`

### Other components

- **Operator**
- **Claude Code**

## Connections

- Operator → Graph sync: maps workspace
- AST extraction → Graph sync: provides code map
- Document extraction → Graph sync: extracts documents
- Graph sync → Workspace graph: writes graph
- Operator → Claude Code: prompts agent
- Claude Code → Hook pipeline: runs hooks
- Hook pipeline → Context retrieval: retrieves context (evidence: `src/hook/user_prompt_submit.rs`)
- Context retrieval → Workspace graph: queries graph (evidence: `src/domain/query.rs`)
- Context retrieval → Domain rules: selects rules (evidence: `src/domain/query.rs`)
- Context retrieval → Decisions: selects decisions (evidence: `src/domain/query.rs`)
- Hook pipeline → Prompt assembly: assembles briefing (evidence: `src/hook/user_prompt_submit.rs`)
- Prompt assembly → Claude Code: injects context
- Hook pipeline → Session state: tracks session (evidence: `src/hook/user_prompt_submit.rs`)
- Hook pipeline → Match history: records matches (evidence: `src/hook/user_prompt_submit.rs`)
- Operator → Graph Q&A: asks graph
- Graph Q&A → Workspace graph: retrieves subgraph (evidence: `src/graph_query.rs`)
- Operator → Projects and tasks: manages knowledge
- Operator → Handoffs: creates handoffs
- Hook pipeline → Handoffs: surfaces handoffs (evidence: `src/hook/mod.rs`)
- Hook pipeline → Agent relay: dispatches relay (evidence: `src/hook/mod.rs`)
- Operator → Dashboard: opens dashboard
- Dashboard → Dashboard panels: serves panels
