# Technical Architecture

This section describes the technical architecture of JP.

## Documents

- [JP Query Architecture] - Deep dive into the `jp query` command stack,
  including component hierarchy, data flow, state management, and refactoring
  opportunities for improved testability.

- [Query Stream Pipeline] - Target architecture for the query command's stream
  handling pipeline.
  Describes the Turn Coordinator state machine, Event Builder, Renderers, Tool
  Coordinator, and Interrupt Handler.
  This is the blueprint for refactoring the current implementation.

- [Structured Output] - Architecture for unified structured output handling.
  Replaces the separate `structured_completion` code path with native provider
  APIs flowing through the standard streaming pipeline.
  The schema is an optional field on `ChatRequest`, and structured JSON data is
  a `Structured` variant on `ChatResponse`.

- [Knowledge Base] - Architecture for the workspace knowledge base system.
  Describes topic/subject organization, system prompt injection, the `learn`
  tool, and CLI integration.

- [Wasm Tools] - Architecture for executing tools as WebAssembly components.
  Covers the `wasmtime` runtime, WIT contract, builtin tools (embedded), local
  Wasm tools (disk-loaded), and the `jp_tool_learn` guest crate.

- [Ubiquitous Language] - The canonical glossary of JP's domain vocabulary.
  Defines the core terms (Workspace, Conversation, Turn, Thread, Attachment,
  Inquiry, Provider, Backend, etc.) and the distinctions between them.

[JP Query Architecture]: architecture.md
[Knowledge Base]: knowledge-base.md
[Query Stream Pipeline]: query-stream-pipeline.md
[Structured Output]: structured-output.md
[Ubiquitous Language]: ubiquitous-language.md
[Wasm Tools]: wasm-tools.md
