# 0xranx/opencontext architecture

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

- Interactive diagram: https://gitdiagram.com/0xranx/opencontext
- Repository: https://github.com/0xranx/opencontext

## Overview

OpenContext is a persistent context and knowledge store for people and AI coding agents. Users or agents create and organize documents, then retrieve them through search or stable links; the CLI, MCP tools, web UI, and desktop app expose that library. Desktop and web interfaces also provide document editing, while the product includes an agent GUI that reuses installed coding-agent CLIs. The graph reflects documented capabilities and sampled wiring; unsampled CLI, native-command, and agent-session internals are represented conservatively.

Main entry points: [`src/core/store/index.js`](https://github.com/0xranx/opencontext/blob/main/src/core/store/index.js) (Context Library), [`src/ui/src/App.jsx`](https://github.com/0xranx/opencontext/blob/main/src/ui/src/App.jsx) (Web UI), [`src/ui/server.js`](https://github.com/0xranx/opencontext/blob/main/src/ui/server.js) (Web API), [`src-tauri/src/main.rs`](https://github.com/0xranx/opencontext/blob/main/src-tauri/src/main.rs) (Desktop Shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["oc CLI<br/>[oc.js]"]
  node_web_ui["Web UI<br/>[App.jsx]"]
  node_web_server["Web API<br/>[server.js]"]
  node_desktop["Desktop Shell<br/>[main.rs]"]
  node_mobile["Mobile App<br/>[App.js]"]
end

subgraph group_agent_access["Agent Access"]
  node_mcp["MCP Tools<br/>[server.js]"]
  node_agent_ui["Agent GUI"]
  node_agent_api["Agent RPC<br/>[agent_rpc.rs]"]
end

subgraph group_knowledge["Knowledge Management"]
  node_context_store[("Context Library<br/>[index.js]")]
  node_idea_storage["Ideas Storage"]
  node_doc_editor["Document Editor<br/>[App.jsx]"]
end

subgraph group_search["Search"]
  node_search_api["Search API<br/>[index.js]"]
  node_search_engine["Search Engine<br/>[searcher.rs]"]
  node_indexer["Indexing<br/>[indexer.rs]"]
  node_index_sync["Index Sync<br/>[index_sync.rs]"]
end

subgraph group_native["Native Runtime"]
  node_core["Core Runtime<br/>[lib.rs]"]
  node_native_bridge["Native Bridge<br/>[lib.rs]"]
end

node_user(("User"))
node_coding_agent(("Coding Agent"))
node_coding_cli["Agent CLI"]

node_user -->|"manages library"| node_cli
node_cli -->|"reads and writes"| node_context_store
node_user -->|"browses and edits"| node_web_ui
node_web_ui -->|"calls API"| node_web_server
node_web_server -->|"reads and writes"| node_context_store
node_web_server -->|"runs search"| node_search_api
node_web_ui -->|"edits documents"| node_doc_editor
node_user -->|"uses desktop app"| node_desktop
node_desktop -->|"initializes"| node_core
node_desktop -->|"starts sync"| node_index_sync
node_user -->|"uses mobile app"| node_mobile
node_mobile -->|"manages ideas"| node_idea_storage
node_coding_agent -->|"calls tools"| node_mcp
node_mcp -->|"reads and writes"| node_context_store
node_mcp -->|"searches documents"| node_search_api
node_user -->|"starts agent session"| node_agent_ui
node_agent_ui -->|"requests agent actions"| node_agent_api
node_agent_api -.->|"reuses CLI"| node_coding_cli
node_search_api -->|"searches index"| node_search_engine
node_indexer -->|"reads documents"| node_context_store
node_index_sync -->|"syncs index"| node_indexer
node_core -->|"manages context"| node_context_store
node_native_bridge -->|"exposes core"| node_core

click node_cli "https://github.com/0xranx/opencontext/blob/main/bin/oc.js"
click node_web_ui "https://github.com/0xranx/opencontext/blob/main/src/ui/src/App.jsx"
click node_web_server "https://github.com/0xranx/opencontext/blob/main/src/ui/server.js"
click node_desktop "https://github.com/0xranx/opencontext/blob/main/src-tauri/src/main.rs"
click node_mobile "https://github.com/0xranx/opencontext/blob/main/src-ios/App.js"
click node_mcp "https://github.com/0xranx/opencontext/blob/main/src/mcp/server.js"
click node_agent_ui "https://github.com/0xranx/opencontext/blob/main/src/ui/src/components/agent/hooks/useAgentSessions.js"
click node_agent_api "https://github.com/0xranx/opencontext/blob/main/src-tauri/src/agent_rpc.rs"
click node_context_store "https://github.com/0xranx/opencontext/blob/main/src/core/store/index.js"
click node_idea_storage "https://github.com/0xranx/opencontext/blob/main/src/ui/src/services/idea/LocalStorageAdapter.js"
click node_doc_editor "https://github.com/0xranx/opencontext/blob/main/src/ui/src/App.jsx"
click node_search_api "https://github.com/0xranx/opencontext/blob/main/src/core/search/index.js"
click node_search_engine "https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/search/searcher.rs"
click node_indexer "https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/search/indexer.rs"
click node_index_sync "https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/search/index_sync.rs"
click node_core "https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/lib.rs"
click node_native_bridge "https://github.com/0xranx/opencontext/blob/main/crates/opencontext-node/src/lib.rs"

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_cli,node_web_ui,node_web_server,node_desktop,node_mobile,node_user toneBlue
class node_mcp,node_agent_ui,node_agent_api toneAmber
class node_context_store,node_idea_storage,node_doc_editor toneMint
class node_search_api,node_search_engine,node_indexer,node_index_sync toneRose
class node_core,node_native_bridge,node_coding_agent,node_coding_cli toneIndigo
```

## Components

### User Interfaces

- [oc CLI](https://github.com/0xranx/opencontext/blob/main/bin/oc.js): `bin/oc.js`
- [Web UI](https://github.com/0xranx/opencontext/blob/main/src/ui/src/App.jsx): `src/ui/src/App.jsx`
- [Web API](https://github.com/0xranx/opencontext/blob/main/src/ui/server.js): `src/ui/server.js`
- [Desktop Shell](https://github.com/0xranx/opencontext/blob/main/src-tauri/src/main.rs): `src-tauri/src/main.rs`
- [Mobile App](https://github.com/0xranx/opencontext/blob/main/src-ios/App.js): `src-ios/App.js`

### Agent Access

- [MCP Tools](https://github.com/0xranx/opencontext/blob/main/src/mcp/server.js): `src/mcp/server.js`
- [Agent GUI](https://github.com/0xranx/opencontext/blob/main/src/ui/src/components/agent/hooks/useAgentSessions.js): `src/ui/src/components/agent/hooks/useAgentSessions.js`
- [Agent RPC](https://github.com/0xranx/opencontext/blob/main/src-tauri/src/agent_rpc.rs): `src-tauri/src/agent_rpc.rs`

### Knowledge Management

- [Context Library](https://github.com/0xranx/opencontext/blob/main/src/core/store/index.js): `src/core/store/index.js`
- [Ideas Storage](https://github.com/0xranx/opencontext/blob/main/src/ui/src/services/idea/LocalStorageAdapter.js): `src/ui/src/services/idea/LocalStorageAdapter.js`
- [Document Editor](https://github.com/0xranx/opencontext/blob/main/src/ui/src/App.jsx): `src/ui/src/App.jsx`

### Search

- [Search API](https://github.com/0xranx/opencontext/blob/main/src/core/search/index.js): `src/core/search/index.js`
- [Search Engine](https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/search/searcher.rs): `crates/opencontext-core/src/search/searcher.rs`
- [Indexing](https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/search/indexer.rs): `crates/opencontext-core/src/search/indexer.rs`
- [Index Sync](https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/search/index_sync.rs): `crates/opencontext-core/src/search/index_sync.rs`

### Native Runtime

- [Core Runtime](https://github.com/0xranx/opencontext/blob/main/crates/opencontext-core/src/lib.rs): `crates/opencontext-core/src/lib.rs`
- [Native Bridge](https://github.com/0xranx/opencontext/blob/main/crates/opencontext-node/src/lib.rs): `crates/opencontext-node/src/lib.rs`

### Other components

- **User**
- **Coding Agent**
- **Agent CLI**

## Connections

- User → oc CLI: manages library
- oc CLI → Context Library: reads and writes
- User → Web UI: browses and edits
- Web UI → Web API: calls API
- Web API → Context Library: reads and writes
- Web API → Search API: runs search
- Web UI → Document Editor: edits documents
- User → Desktop Shell: uses desktop app
- Desktop Shell → Core Runtime: initializes
- Desktop Shell → Index Sync: starts sync
- User → Mobile App: uses mobile app
- Mobile App → Ideas Storage: manages ideas
- Coding Agent → MCP Tools: calls tools
- MCP Tools → Context Library: reads and writes
- MCP Tools → Search API: searches documents
- User → Agent GUI: starts agent session
- Agent GUI → Agent RPC: requests agent actions
- Agent RPC → Agent CLI: reuses CLI
- Search API → Search Engine: searches index
- Indexing → Context Library: reads documents
- Index Sync → Indexing: syncs index
- Core Runtime → Context Library: manages context
- Native Bridge → Core Runtime: exposes core
