# memoket/memoket-kite architecture

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

- Interactive diagram: https://gitdiagram.com/memoket/memoket-kite
- Repository: https://github.com/memoket/memoket-kite

## Overview

KITE is a vector-free conversational-memory library: messages become structured, source-linked facts in XML, and questions become inspectable symbolic plans executed against that memory to produce evidence-backed answers. The graph emphasizes the public Memory workflow and its retrieval/answer layers, while retaining the MCP and research interfaces. Edges follow README-described stages or relationships visible in the supplied source index and excerpts; unsampled implementation details are not inferred.

Main entry points: [`src/memoket_kite/memory.py`](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/memory.py) (Memory API), [`src/memoket_kite/pipeline/answer.py`](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/answer.py) (Answer generation), [`src/memoket_kite/pipeline/retrieve.py`](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/retrieve.py) (Retrieval orchestration), [`src/memoket_kite/pipeline/extract.py`](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/extract.py) (Fact extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public interfaces"]
  node_memory_api["Memory API<br/>[memory.py]"]
  node_mcp["MCP server<br/>[server.py]"]
  node_research_api["Codebook API<br/>[codebook.py]"]
end

subgraph group_memory["Memory construction"]
  node_xml[("XML memory<br/>[storage.py]")]
  node_session["Session building<br/>[remember.py]"]
  node_extract["Fact extraction<br/>[extract.py]"]
  node_fact["Facts and vocabulary<br/>[fact.py]"]
  node_extract_prompt["Extraction prompts<br/>[extract.py]"]
  node_provider["LLM provider<br/>[llm.py]"]
end

subgraph group_query["Query and retrieval"]
  node_plan_compile["Plan compiler<br/>[compile_plan.py]"]
  node_query_contract["Query contracts<br/>[query.py]"]
  node_algebra["Symbolic algebra<br/>[algebra.py]"]
  node_vocab["Topic vocabulary<br/>[vocab.py]"]
  node_retrieve["Retrieval orchestration<br/>[retrieve.py]"]
  node_ledger["Execution ledger<br/>[ledger.py]"]
end

subgraph group_answer["Evidence and answers"]
  node_answer["Answer generation<br/>[answer.py]"]
  node_answer_prompt["Answer prompts<br/>[answer.py]"]
  node_render["Evidence rendering<br/>[render.py]"]
  node_postproc["Answer postprocessing<br/>[postproc.py]"]
end

node_caller(("Application / agent"))
node_llm_service{{"OpenAI-compatible LLM"}}

node_caller -->|"calls"| node_memory_api
node_memory_api -->|"loads / saves"| node_xml
node_memory_api -->|"builds session"| node_session
node_session -->|"extracts facts"| node_extract
node_extract -->|"requests extraction"| node_provider
node_extract -->|"formats prompt"| node_extract_prompt
node_provider -->|"sends request"| node_llm_service
node_extract -.->|"creates facts"| node_fact
node_memory_api -.->|"compiles question"| node_plan_compile
node_plan_compile -->|"requests plan"| node_provider
node_plan_compile -->|"validates plan"| node_query_contract
node_retrieve -->|"compiles plan"| node_plan_compile
node_retrieve -->|"executes plan"| node_algebra
node_algebra -->|"resolves symbols"| node_vocab
node_retrieve -->|"records steps"| node_ledger
node_memory_api -.->|"requests recall"| node_retrieve
node_memory_api -.->|"requests answer"| node_answer
node_answer -->|"retrieves evidence"| node_retrieve
node_answer -->|"generates answer"| node_provider
node_answer -->|"formats prompt"| node_answer_prompt
node_answer -->|"builds evidence pack"| node_render
node_answer -->|"applies policy"| node_postproc
node_memory_api -->|"loads codebook"| node_research_api
node_mcp -->|"uses public API"| node_memory_api
node_caller -.->|"connects via MCP"| node_mcp
node_research_api -->|"retrieves evidence"| node_retrieve
node_research_api -->|"answers with evidence"| node_answer

click node_memory_api "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/memory.py"
click node_mcp "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/mcp/server.py"
click node_research_api "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/research/codebook.py"
click node_xml "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/storage.py"
click node_session "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/remember.py"
click node_extract "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/extract.py"
click node_fact "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/fact.py"
click node_extract_prompt "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/prompts/extract.py"
click node_provider "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/providers/llm.py"
click node_plan_compile "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/compile_plan.py"
click node_query_contract "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/research/query.py"
click node_algebra "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/core/algebra.py"
click node_vocab "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/core/vocab.py"
click node_retrieve "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/retrieve.py"
click node_ledger "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/ledger.py"
click node_answer "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/answer.py"
click node_answer_prompt "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/prompts/answer.py"
click node_render "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/render.py"
click node_postproc "https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/postproc.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_memory_api,node_mcp,node_research_api toneBlue
class node_xml,node_session,node_extract,node_fact,node_extract_prompt,node_provider toneAmber
class node_plan_compile,node_query_contract,node_algebra,node_vocab,node_retrieve,node_ledger toneMint
class node_answer,node_answer_prompt,node_render,node_postproc toneRose
class node_caller,node_llm_service toneIndigo
```

## Components

### Public interfaces

- [Memory API](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/memory.py): `src/memoket_kite/memory.py`
- [MCP server](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/mcp/server.py): `src/memoket_kite/mcp/server.py`
- [Codebook API](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/research/codebook.py): `src/memoket_kite/research/codebook.py`

### Memory construction

- [XML memory](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/storage.py): `src/memoket_kite/storage.py`
- [Session building](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/remember.py): `src/memoket_kite/remember.py`
- [Fact extraction](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/extract.py): `src/memoket_kite/pipeline/extract.py`
- [Facts and vocabulary](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/fact.py): `src/memoket_kite/fact.py`
- [Extraction prompts](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/prompts/extract.py): `src/memoket_kite/prompts/extract.py`
- [LLM provider](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/providers/llm.py): `src/memoket_kite/providers/llm.py`

### Query and retrieval

- [Plan compiler](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/compile_plan.py): `src/memoket_kite/pipeline/compile_plan.py`
- [Query contracts](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/research/query.py): `src/memoket_kite/research/query.py`
- [Symbolic algebra](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/core/algebra.py): `src/memoket_kite/core/algebra.py`
- [Topic vocabulary](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/core/vocab.py): `src/memoket_kite/core/vocab.py`
- [Retrieval orchestration](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/retrieve.py): `src/memoket_kite/pipeline/retrieve.py`
- [Execution ledger](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/ledger.py): `src/memoket_kite/pipeline/ledger.py`

### Evidence and answers

- [Answer generation](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/answer.py): `src/memoket_kite/pipeline/answer.py`
- [Answer prompts](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/prompts/answer.py): `src/memoket_kite/prompts/answer.py`
- [Evidence rendering](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/render.py): `src/memoket_kite/pipeline/render.py`
- [Answer postprocessing](https://github.com/memoket/memoket-kite/blob/main/src/memoket_kite/pipeline/postproc.py): `src/memoket_kite/pipeline/postproc.py`

### Other components

- **Application / agent**
- **OpenAI-compatible LLM**

## Connections

- Application / agent → Memory API: calls (evidence: `README.md`)
- Memory API → XML memory: loads / saves (evidence: `src/memoket_kite/memory.py`)
- Memory API → Session building: builds session (evidence: `src/memoket_kite/memory.py`)
- Session building → Fact extraction: extracts facts (evidence: `src/memoket_kite/remember.py`)
- Fact extraction → LLM provider: requests extraction (evidence: `src/memoket_kite/pipeline/extract.py`)
- Fact extraction → Extraction prompts: formats prompt (evidence: `src/memoket_kite/pipeline/extract.py`)
- LLM provider → OpenAI-compatible LLM: sends request (evidence: `src/memoket_kite/providers/llm.py`)
- Fact extraction → Facts and vocabulary: creates facts
- Memory API → Plan compiler: compiles question
- Plan compiler → LLM provider: requests plan (evidence: `src/memoket_kite/pipeline/compile_plan.py`)
- Plan compiler → Query contracts: validates plan (evidence: `src/memoket_kite/pipeline/compile_plan.py`)
- Retrieval orchestration → Plan compiler: compiles plan (evidence: `src/memoket_kite/pipeline/retrieve.py`)
- Retrieval orchestration → Symbolic algebra: executes plan (evidence: `src/memoket_kite/pipeline/retrieve.py`)
- Symbolic algebra → Topic vocabulary: resolves symbols (evidence: `src/memoket_kite/core/algebra.py`)
- Retrieval orchestration → Execution ledger: records steps (evidence: `src/memoket_kite/pipeline/retrieve.py`)
- Memory API → Retrieval orchestration: requests recall
- Memory API → Answer generation: requests answer
- Answer generation → Retrieval orchestration: retrieves evidence (evidence: `src/memoket_kite/pipeline/answer.py`)
- Answer generation → LLM provider: generates answer (evidence: `src/memoket_kite/pipeline/answer.py`)
- Answer generation → Answer prompts: formats prompt (evidence: `src/memoket_kite/pipeline/answer.py`)
- Answer generation → Evidence rendering: builds evidence pack (evidence: `src/memoket_kite/pipeline/answer.py`)
- Answer generation → Answer postprocessing: applies policy (evidence: `src/memoket_kite/pipeline/answer.py`)
- Memory API → Codebook API: loads codebook (evidence: `src/memoket_kite/memory.py`)
- MCP server → Memory API: uses public API (evidence: `src/memoket_kite/mcp/server.py`)
- Application / agent → MCP server: connects via MCP (evidence: `README.md`)
- Codebook API → Retrieval orchestration: retrieves evidence (evidence: `src/memoket_kite/research/codebook.py`)
- Codebook API → Answer generation: answers with evidence (evidence: `src/memoket_kite/research/codebook.py`)
