Architecture

Monorepo Architecture

Cortex is organized as a monorepo with eight focused packages, each with a clear responsibility.

Data Flow

Files
ingest
llm
graph
core (SQLite)
core
cli
mcp
server
web

@gzoo/core

Shared types, configuration management, and SQLite database layer. The foundation everything else builds on.

SQLitebetter-sqlite3TypeScript

@gzoo/ingest

File watching, content parsing, and entity extraction pipeline. Turns raw files into structured knowledge.

ChokidarTree-sitterLLM APIs
Depends on: core, llm

@gzoo/graph

Knowledge graph construction, relationship inference, and contradiction detection engine.

LanceDBVector embeddings
Depends on: core

@gzoo/llm

Multi-provider LLM abstraction with intelligent routing between cloud and local models.

AnthropicGoogle AIOpenAIOllama
Depends on: core

@gzoo/cli

Command-line interface for all Cortex operations. The primary user-facing entry point.

Commander.js
Depends on: core, ingest, graph, llm

@gzoo/mcp

Model Context Protocol server for integration with Claude Code and other MCP-compatible tools.

MCP SDK
Depends on: core, graph, llm

@gzoo/server

HTTP API and WebSocket server powering the web dashboard with real-time updates.

ExpressWebSocket
Depends on: core, graph, llm

@gzoo/web

Interactive web dashboard with knowledge graph visualization and query explorer.

ReactViteD3.js
Depends on: server