# daniel-ddv/cortexdb architecture

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

- Interactive diagram: https://gitdiagram.com/daniel-ddv/cortexdb
- Repository: https://github.com/daniel-ddv/cortexdb

## Overview

CortexDB is an embedded AI-memory and knowledge-graph product, with SQLite by default and optional PostgreSQL or shared gRPC access. Users capture or import knowledge, then retrieve memories and graph/RAG context through a library, MCP tools, REST, or remote clients. The graph preserves documented product capabilities and relationships visible in the excerpts or README; several internal implementations are represented by their exact package directories because their source was not sampled.

Main entry points: [`pkg/cortexdb/cortexdb.go`](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/cortexdb.go) (CortexDB facade), [`pkg/core/store.go`](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/core/store.go) (Core store and search), [`pkg/httpapi/routes.go`](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/httpapi/routes.go) (REST API), [`pkg/cortexdb/graphrag_tool_ingest.go`](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/graphrag_tool_ingest.go) (GraphRAG ingest and search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_mcp["MCP tools<br/>[main.go]"]
  node_facade["CortexDB facade<br/>[cortexdb.go]"]
  node_http["REST API<br/>[routes.go]"]
  node_grpc["gRPC API<br/>[server.go]"]
  node_clients["Language clients<br/>[client.py]"]
end

subgraph group_knowledge["Knowledge Workflows"]
  node_memory["Memory operations<br/>[memory_api.go]"]
  node_memoryflow["Memory lifecycle<br/>[service.go]"]
  node_agentmem["Scoped agent memory<br/>[search.go]"]
  node_import["Agent-memory import"]
  node_connectors["Data connectors"]
  node_ontology["Governed ontology"]
end

subgraph group_retrieval["Retrieval and Graph"]
  node_graphrag["GraphRAG ingest and search"]
  node_graphflow["Graph organization<br/>[pipeline.go]"]
  node_graph["Knowledge graph engine"]
  node_query["Hybrid query and retrieval<br/>[query_api.go]"]
  node_vectors["Vector indexes<br/>[hnsw.go]"]
end

subgraph group_storage["Persistence"]
  node_core["Core store and search<br/>[store.go]"]
  node_database[("SQLite or PostgreSQL<br/>[store_init.go]")]
end

subgraph group_services["Serving and Integrations"]
  node_liveview["Live graph view<br/>[server.go]"]
  node_grpcserver["Shared-brain server<br/>[main.go]"]
end

node_user(("Agent or user"))

node_user -->|"uses tools"| node_mcp
node_user -->|"uses library"| node_facade
node_user -.->|"calls REST"| node_http
node_user -->|"uses client"| node_clients
node_mcp -->|"registers tools"| node_graphflow
node_http -->|"routes calls"| node_memory
node_http -->|"routes calls"| node_facade
node_grpcserver -->|"creates server"| node_grpc
node_grpc -->|"delegates RPCs"| node_facade
node_clients -.->|"sends RPCs"| node_grpcserver
node_memoryflow -->|"uses memory APIs"| node_facade
node_agentmem -->|"searches store"| node_core
node_graphflow -->|"builds and analyzes"| node_facade
node_graphrag -->|"reads and writes"| node_graph
node_graphrag -->|"uses storage"| node_core
node_facade -.->|"uses store"| node_core
node_core -.->|"persists data"| node_database
node_query -.->|"retrieves vectors"| node_vectors
node_query -.->|"retrieves graph context"| node_graph
node_ontology -->|"stores schemas"| node_core
node_liveview -->|"serves graph view"| node_user
node_connectors -->|"imports knowledge"| node_facade
node_import -->|"imports memories"| node_facade

click node_mcp "https://github.com/daniel-ddv/cortexdb/blob/main/cmd/cortexdb-mcp-stdio/main.go"
click node_facade "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/cortexdb.go"
click node_http "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/httpapi/routes.go"
click node_grpc "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/rpcserver/server.go"
click node_clients "https://github.com/daniel-ddv/cortexdb/blob/main/clients/python/cortexdb_client/client.py"
click node_memory "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/memory_api.go"
click node_memoryflow "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/memoryflow/service.go"
click node_agentmem "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/agentmem/search.go"
click node_import "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/import_agent_memory.go"
click node_connectors "https://github.com/daniel-ddv/cortexdb/tree/main/pkg/connector"
click node_graphrag "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/graphrag_tool_ingest.go"
click node_graphflow "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/graphflow/pipeline.go"
click node_graph "https://github.com/daniel-ddv/cortexdb/tree/main/pkg/graph"
click node_query "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/query_api.go"
click node_vectors "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/index/hnsw.go"
click node_ontology "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/ontology_storage.go"
click node_liveview "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/liveview/server.go"
click node_core "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/core/store.go"
click node_database "https://github.com/daniel-ddv/cortexdb/blob/main/pkg/core/store_init.go"
click node_grpcserver "https://github.com/daniel-ddv/cortexdb/blob/main/cmd/cortexdb-grpc/main.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_mcp,node_facade,node_http,node_grpc,node_clients,node_user toneBlue
class node_memory,node_memoryflow,node_agentmem,node_import,node_connectors,node_ontology toneAmber
class node_graphrag,node_graphflow,node_graph,node_query,node_vectors toneMint
class node_core,node_database toneRose
class node_liveview,node_grpcserver toneIndigo
```

## Components

### User Interfaces

- [MCP tools](https://github.com/daniel-ddv/cortexdb/blob/main/cmd/cortexdb-mcp-stdio/main.go): `cmd/cortexdb-mcp-stdio/main.go`
- [CortexDB facade](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/cortexdb.go): `pkg/cortexdb/cortexdb.go`
- [REST API](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/httpapi/routes.go): `pkg/httpapi/routes.go`
- [gRPC API](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/rpcserver/server.go): `pkg/rpcserver/server.go`
- [Language clients](https://github.com/daniel-ddv/cortexdb/blob/main/clients/python/cortexdb_client/client.py): `clients/python/cortexdb_client/client.py`

### Knowledge Workflows

- [Memory operations](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/memory_api.go): `pkg/cortexdb/memory_api.go`
- [Memory lifecycle](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/memoryflow/service.go): `pkg/memoryflow/service.go`
- [Scoped agent memory](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/agentmem/search.go): `pkg/agentmem/search.go`
- [Agent-memory import](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/import_agent_memory.go): `pkg/cortexdb/import_agent_memory.go`
- [Data connectors](https://github.com/daniel-ddv/cortexdb/tree/main/pkg/connector): `pkg/connector`
- [Governed ontology](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/ontology_storage.go): `pkg/cortexdb/ontology_storage.go`

### Retrieval and Graph

- [GraphRAG ingest and search](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/graphrag_tool_ingest.go): `pkg/cortexdb/graphrag_tool_ingest.go`
- [Graph organization](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/graphflow/pipeline.go): `pkg/graphflow/pipeline.go`
- [Knowledge graph engine](https://github.com/daniel-ddv/cortexdb/tree/main/pkg/graph): `pkg/graph`
- [Hybrid query and retrieval](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/cortexdb/query_api.go): `pkg/cortexdb/query_api.go`
- [Vector indexes](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/index/hnsw.go): `pkg/index/hnsw.go`

### Persistence

- [Core store and search](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/core/store.go): `pkg/core/store.go`
- [SQLite or PostgreSQL](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/core/store_init.go): `pkg/core/store_init.go`

### Serving and Integrations

- [Live graph view](https://github.com/daniel-ddv/cortexdb/blob/main/pkg/liveview/server.go): `pkg/liveview/server.go`
- [Shared-brain server](https://github.com/daniel-ddv/cortexdb/blob/main/cmd/cortexdb-grpc/main.go): `cmd/cortexdb-grpc/main.go`

### Other components

- **Agent or user**

## Connections

- Agent or user → MCP tools: uses tools (evidence: `README.md`)
- Agent or user → CortexDB facade: uses library (evidence: `README.md`)
- Agent or user → REST API: calls REST (evidence: `README.md`)
- Agent or user → Language clients: uses client (evidence: `README.md`)
- MCP tools → Graph organization: registers tools (evidence: `cmd/cortexdb-mcp-stdio/main.go`)
- REST API → Memory operations: routes calls (evidence: `pkg/httpapi/routes.go`)
- REST API → CortexDB facade: routes calls (evidence: `pkg/httpapi/routes.go`)
- Shared-brain server → gRPC API: creates server (evidence: `cmd/cortexdb-grpc/main.go`)
- gRPC API → CortexDB facade: delegates RPCs (evidence: `pkg/rpcserver/server.go`)
- Language clients → Shared-brain server: sends RPCs (evidence: `clients/python/cortexdb_client/client.py`)
- Memory lifecycle → CortexDB facade: uses memory APIs (evidence: `pkg/memoryflow/service.go`)
- Scoped agent memory → Core store and search: searches store (evidence: `pkg/agentmem/search.go`)
- Graph organization → CortexDB facade: builds and analyzes (evidence: `pkg/graphflow/pipeline.go`)
- GraphRAG ingest and search → Knowledge graph engine: reads and writes (evidence: `pkg/cortexdb/graphrag_tool_ingest.go`)
- GraphRAG ingest and search → Core store and search: uses storage (evidence: `pkg/cortexdb/graphrag_tool_ingest.go`)
- CortexDB facade → Core store and search: uses store
- Core store and search → SQLite or PostgreSQL: persists data
- Hybrid query and retrieval → Vector indexes: retrieves vectors
- Hybrid query and retrieval → Knowledge graph engine: retrieves graph context
- Governed ontology → Core store and search: stores schemas (evidence: `pkg/cortexdb/ontology_storage.go`)
- Live graph view → Agent or user: serves graph view (evidence: `README.md`)
- Data connectors → CortexDB facade: imports knowledge
- Agent-memory import → CortexDB facade: imports memories (evidence: `README.md`)
