# limeflash/quipu architecture

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

## Overview

quipu is a local-first memory system for AI coding agents, extending engram with automatic capture and compression while retaining agent-written memory, search, and sync. The main workflow records redacted hook events, batches them for summarization, stores resulting memories, and makes repository-specific context available in later sessions. Other major capabilities include project attribution and profiles, cloud and file-based sync, agent integrations, setup, diagnostics, import, and a terminal UI. Arrows are limited to README-documented relationships or connections visible in the supplied excerpts and SOURCE INDEX; unsampled implementation details are not asserted.

Main entry points: [`cmd/engram/main.go`](https://github.com/limeflash/quipu/blob/main/cmd/engram/main.go) (CLI entry point), [`internal/store/store.go`](https://github.com/limeflash/quipu/blob/main/internal/store/store.go) (Memory store), [`internal/autocapture/compress/drain.go`](https://github.com/limeflash/quipu/blob/main/internal/autocapture/compress/drain.go) (Batch compressor), [`internal/server/server.go`](https://github.com/limeflash/quipu/blob/main/internal/server/server.go) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Automatic capture"]
  node_capturebin["Capture hook<br/>[main.go]"]
  node_redaction["Secret redaction<br/>[redact.go]"]
  node_spool[("Event spool<br/>[spool.go]")]
  node_compressor["Batch compressor<br/>[drain.go]"]
  node_modelchain["Model chain<br/>[chain.go]"]
end

subgraph group_memory["Memory runtime"]
  node_project["Project attribution<br/>[detect.go]"]
  node_profile["Project profile<br/>[profile.go]"]
  node_store[("Memory store<br/>[store.go]")]
  node_llm["Semantic LLM runner<br/>[factory.go]"]
end

subgraph group_sync["Synchronization"]
  node_file_sync["File-based sync<br/>[sync.go]"]
  node_autosync["Cloud sync manager<br/>[manager.go]"]
  node_cloud_transport["Cloud transport<br/>[transport.go]"]
  node_cloud_server["Cloud service<br/>[cloudserver.go]"]
end

subgraph group_interfaces["Agent interfaces"]
  node_mcp["MCP memory tools<br/>[mcp.go]"]
  node_http["HTTP API<br/>[server.go]"]
  node_cli["CLI entry point<br/>[main.go]"]
  node_obsidian["Obsidian integration<br/>[main.ts]"]
  node_pi["Pi integration<br/>[index.ts]"]
  node_opencode["OpenCode integration<br/>[engram.ts]"]
  node_tui["Terminal UI<br/>[update.go]"]
end

subgraph group_operations["Operations"]
  node_setup["Agent setup<br/>[setup.go]"]
  node_diagnostics["Diagnostics<br/>[checks.go]"]
  node_import["Claude-mem import<br/>[main.go]"]
end

node_agent(("Claude Code / Codex"))
node_ollama(("Ollama Cloud"))
node_paid_models(("Codex / Claude models"))

node_agent -->|"sends hook events"| node_capturebin
node_capturebin -->|"redacts events"| node_redaction
node_capturebin -->|"writes event file"| node_spool
node_spool -->|"drains batches"| node_compressor
node_compressor -->|"compresses events"| node_modelchain
node_modelchain -->|"calls first"| node_ollama
node_modelchain -.->|"falls back"| node_paid_models
node_compressor -->|"writes memories"| node_store
node_agent -->|"calls memory tools"| node_mcp
node_agent -->|"calls memory API"| node_http
node_mcp -->|"reads and writes"| node_store
node_http -->|"reads and writes"| node_store
node_cli -->|"manages memories"| node_store
node_cli -->|"starts sync"| node_autosync
node_autosync -->|"replicates mutations"| node_store
node_autosync -.->|"uses transport"| node_cloud_transport
node_cloud_transport -.->|"syncs remotely"| node_cloud_server
node_file_sync -->|"imports and exports"| node_store
node_cli -.->|"runs sync"| node_file_sync
node_cli -->|"resolves projects"| node_project
node_compressor -->|"attributes events"| node_project
node_compressor -.->|"builds profiles"| node_profile
node_cli -->|"creates runner"| node_llm
node_agent -.->|"uses plugin"| node_obsidian
node_obsidian -.->|"syncs memories"| node_http
node_agent -.->|"uses plugin"| node_pi
node_pi -.->|"calls API"| node_http
node_agent -.->|"uses plugin"| node_opencode
node_opencode -.->|"calls API"| node_http
node_cli -->|"configures agents"| node_setup
node_cli -->|"runs checks"| node_diagnostics
node_cli -->|"imports records"| node_import
node_cli -.->|"launches interface"| node_tui
node_tui -->|"reads and updates"| node_store

click node_capturebin "https://github.com/limeflash/quipu/blob/main/cmd/engram-capture/main.go"
click node_redaction "https://github.com/limeflash/quipu/blob/main/internal/redact/redact.go"
click node_spool "https://github.com/limeflash/quipu/blob/main/internal/autocapture/spool.go"
click node_compressor "https://github.com/limeflash/quipu/blob/main/internal/autocapture/compress/drain.go"
click node_modelchain "https://github.com/limeflash/quipu/blob/main/internal/autocapture/compress/chain.go"
click node_project "https://github.com/limeflash/quipu/blob/main/internal/project/detect.go"
click node_profile "https://github.com/limeflash/quipu/blob/main/internal/autocapture/compress/profile.go"
click node_mcp "https://github.com/limeflash/quipu/blob/main/internal/mcp/mcp.go"
click node_http "https://github.com/limeflash/quipu/blob/main/internal/server/server.go"
click node_store "https://github.com/limeflash/quipu/blob/main/internal/store/store.go"
click node_cli "https://github.com/limeflash/quipu/blob/main/cmd/engram/main.go"
click node_llm "https://github.com/limeflash/quipu/blob/main/internal/llm/factory.go"
click node_file_sync "https://github.com/limeflash/quipu/blob/main/internal/sync/sync.go"
click node_autosync "https://github.com/limeflash/quipu/blob/main/internal/cloud/autosync/manager.go"
click node_cloud_transport "https://github.com/limeflash/quipu/blob/main/internal/cloud/remote/transport.go"
click node_cloud_server "https://github.com/limeflash/quipu/blob/main/internal/cloud/cloudserver/cloudserver.go"
click node_obsidian "https://github.com/limeflash/quipu/blob/main/plugin/obsidian/src/main.ts"
click node_pi "https://github.com/limeflash/quipu/blob/main/plugin/pi/index.ts"
click node_opencode "https://github.com/limeflash/quipu/blob/main/plugin/opencode/engram.ts"
click node_setup "https://github.com/limeflash/quipu/blob/main/internal/setup/setup.go"
click node_diagnostics "https://github.com/limeflash/quipu/blob/main/internal/diagnostic/checks.go"
click node_import "https://github.com/limeflash/quipu/blob/main/cmd/engram/main.go"
click node_tui "https://github.com/limeflash/quipu/blob/main/internal/tui/update.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_capturebin,node_redaction,node_spool,node_compressor,node_modelchain toneBlue
class node_project,node_profile,node_store,node_llm toneAmber
class node_file_sync,node_autosync,node_cloud_transport,node_cloud_server toneMint
class node_mcp,node_http,node_cli,node_obsidian,node_pi,node_opencode,node_tui toneRose
class node_setup,node_diagnostics,node_import,node_agent,node_ollama,node_paid_models toneIndigo
```

## Components

### Automatic capture

- [Capture hook](https://github.com/limeflash/quipu/blob/main/cmd/engram-capture/main.go): `cmd/engram-capture/main.go`
- [Secret redaction](https://github.com/limeflash/quipu/blob/main/internal/redact/redact.go): `internal/redact/redact.go`
- [Event spool](https://github.com/limeflash/quipu/blob/main/internal/autocapture/spool.go): `internal/autocapture/spool.go`
- [Batch compressor](https://github.com/limeflash/quipu/blob/main/internal/autocapture/compress/drain.go): `internal/autocapture/compress/drain.go`
- [Model chain](https://github.com/limeflash/quipu/blob/main/internal/autocapture/compress/chain.go): `internal/autocapture/compress/chain.go`

### Memory runtime

- [Project attribution](https://github.com/limeflash/quipu/blob/main/internal/project/detect.go): `internal/project/detect.go`
- [Project profile](https://github.com/limeflash/quipu/blob/main/internal/autocapture/compress/profile.go): `internal/autocapture/compress/profile.go`
- [Memory store](https://github.com/limeflash/quipu/blob/main/internal/store/store.go): `internal/store/store.go`
- [Semantic LLM runner](https://github.com/limeflash/quipu/blob/main/internal/llm/factory.go): `internal/llm/factory.go`

### Synchronization

- [File-based sync](https://github.com/limeflash/quipu/blob/main/internal/sync/sync.go): `internal/sync/sync.go`
- [Cloud sync manager](https://github.com/limeflash/quipu/blob/main/internal/cloud/autosync/manager.go): `internal/cloud/autosync/manager.go`
- [Cloud transport](https://github.com/limeflash/quipu/blob/main/internal/cloud/remote/transport.go): `internal/cloud/remote/transport.go`
- [Cloud service](https://github.com/limeflash/quipu/blob/main/internal/cloud/cloudserver/cloudserver.go): `internal/cloud/cloudserver/cloudserver.go`

### Agent interfaces

- [MCP memory tools](https://github.com/limeflash/quipu/blob/main/internal/mcp/mcp.go): `internal/mcp/mcp.go`
- [HTTP API](https://github.com/limeflash/quipu/blob/main/internal/server/server.go): `internal/server/server.go`
- [CLI entry point](https://github.com/limeflash/quipu/blob/main/cmd/engram/main.go): `cmd/engram/main.go`
- [Obsidian integration](https://github.com/limeflash/quipu/blob/main/plugin/obsidian/src/main.ts): `plugin/obsidian/src/main.ts`
- [Pi integration](https://github.com/limeflash/quipu/blob/main/plugin/pi/index.ts): `plugin/pi/index.ts`
- [OpenCode integration](https://github.com/limeflash/quipu/blob/main/plugin/opencode/engram.ts): `plugin/opencode/engram.ts`
- [Terminal UI](https://github.com/limeflash/quipu/blob/main/internal/tui/update.go): `internal/tui/update.go`

### Operations

- [Agent setup](https://github.com/limeflash/quipu/blob/main/internal/setup/setup.go): `internal/setup/setup.go`
- [Diagnostics](https://github.com/limeflash/quipu/blob/main/internal/diagnostic/checks.go): `internal/diagnostic/checks.go`
- [Claude-mem import](https://github.com/limeflash/quipu/blob/main/cmd/engram/main.go): `cmd/engram/main.go`

### Other components

- **Claude Code / Codex**
- **Ollama Cloud**
- **Codex / Claude models**

## Connections

- Claude Code / Codex → Capture hook: sends hook events (evidence: `README.md`)
- Capture hook → Secret redaction: redacts events (evidence: `README.md`)
- Capture hook → Event spool: writes event file (evidence: `README.md`)
- Event spool → Batch compressor: drains batches (evidence: `README.md`)
- Batch compressor → Model chain: compresses events (evidence: `README.md`)
- Model chain → Ollama Cloud: calls first (evidence: `README.md`)
- Model chain → Codex / Claude models: falls back (evidence: `README.md`)
- Batch compressor → Memory store: writes memories (evidence: `README.md`)
- Claude Code / Codex → MCP memory tools: calls memory tools (evidence: `README.md`)
- Claude Code / Codex → HTTP API: calls memory API (evidence: `internal/server/server.go`)
- MCP memory tools → Memory store: reads and writes (evidence: `internal/mcp/mcp.go`)
- HTTP API → Memory store: reads and writes (evidence: `internal/server/server.go`)
- CLI entry point → Memory store: manages memories (evidence: `cmd/engram/main.go`)
- CLI entry point → Cloud sync manager: starts sync (evidence: `cmd/engram/main.go`)
- Cloud sync manager → Memory store: replicates mutations (evidence: `internal/cloud/autosync/manager.go`)
- Cloud sync manager → Cloud transport: uses transport
- Cloud transport → Cloud service: syncs remotely
- File-based sync → Memory store: imports and exports (evidence: `internal/sync/sync.go`)
- CLI entry point → File-based sync: runs sync (evidence: `cmd/engram/main.go`)
- CLI entry point → Project attribution: resolves projects (evidence: `cmd/engram/main.go`)
- Batch compressor → Project attribution: attributes events (evidence: `internal/autocapture/compress/drain.go`)
- Batch compressor → Project profile: builds profiles
- CLI entry point → Semantic LLM runner: creates runner
- Claude Code / Codex → Obsidian integration: uses plugin
- Obsidian integration → HTTP API: syncs memories
- Claude Code / Codex → Pi integration: uses plugin
- Pi integration → HTTP API: calls API
- Claude Code / Codex → OpenCode integration: uses plugin
- OpenCode integration → HTTP API: calls API
- CLI entry point → Agent setup: configures agents (evidence: `cmd/engram/main.go`)
- CLI entry point → Diagnostics: runs checks (evidence: `cmd/engram/main.go`)
- CLI entry point → Claude-mem import: imports records (evidence: `cmd/engram/main.go`)
- CLI entry point → Terminal UI: launches interface (evidence: `cmd/engram/main.go`)
- Terminal UI → Memory store: reads and updates (evidence: `internal/tui/update.go`)
