Skip to content

Architecture Overview

apps/
server/ → Runnable Fastify server
packages/
core/ → @intentweave/core — shared types, predicates, interfaces
analyzer/ → @intentweave/analyzer — pipeline stages (AX, KWX, COX, TCG, FX, KX, GX)
index/ → @intentweave/index — CARI SQLite engine (writer, annotator, IDF, queries)
cli/ → @intentweave/cli — `iw` commands + MCP server
server-core/ → @intentweave/server-core — Fastify + Neo4j + middleware
server-open/ → @intentweave/server-open — open track API routes
profiles/ → @intentweave/profiles — extraction profile packs
ast-extractor/ → @intentweave/ast-extractor — tree-sitter TS/JS extraction
swift-parser/ → @intentweave/swift-parser — tree-sitter Swift extraction

The CARI index is built by a sequence of pipeline stages, orchestrated by packages/cli/src/commands/indexBuild.ts:

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ AX │ │ KWX │ │ COX │
│ AST Extract │───►│ Keywords │───►│ Co-occur │
│ (symbols) │ │ (mentions) │ │ (pairs) │
└─────────────┘ └─────────────┘ └──────┬──────┘
┌─────────────┐ ┌─────────────┐ ┌──────▼──────┐
│ TCG │ │ Annotate │ │ Write │
│ Git History │───►│ (match + │───►│ (SQLite) │
│ (co-change) │ │ IDF filter)│ │ .iw/index.db│
└─────────────┘ └─────────────┘ └─────────────┘
StagePackageInputOutput
AXast-extractorSource filesSymbol registry (classes, functions, exports)
KWXanalyzerDocs + symbol dictionaryKeyword mentions per document
COXanalyzerMentionsEntity pair co-occurrence scores
TCGanalyzerGit logCo-change Jaccard, hotspot, ownership, staleness
AnnotateindexMentions + symbolsGrounded annotations with IDF scores
WriteindexAll aboveSQLite database (.iw/index.db)

For LLM-powered semantic extraction:

Documents ──► IN (chunk) ──► FX (extract) ──► KX (canonicalize) ──► GX (merge)
Neo4j ◄──── Persist
StagePurpose
INChunk documents (semantic markdown splitting, ~16k chars/chunk)
FXLLM extracts raw entity-relationship triples per chunk
KXCanonicalize entities and predicates (30 predicate types)
GXCross-document entity deduplication (exact + fuzzy merge)
┌──────────────────────────────────────────┐
│ @intentweave/server-core │
│ Fastify 5 + Neo4j pool + context MW │
│ Health + SSE + OpenAPI (Swagger) │
└──────────┬───────────────────────────────┘
┌──────────▼───────────────────────────────┐
│ @intentweave/server-open │
│ POST /api/query — KG query │
│ POST /api/context — RAG context │
│ POST /api/run — pipeline execution │
│ POST /api/persist — Neo4j persistence │
│ POST /api/impact — impact analysis │
│ GET /api/entities — entity listing │
│ GET /api/schema — graph schema │
└──────────────────────────────────────────┘
LayerTechnology
LanguageTypeScript 5.6, ESM, strict mode
Monorepopnpm workspaces + Turbo
CLICommander.js
ServerFastify 5
Database (CARI)SQLite via better-sqlite3
Database (KG)Neo4j 5
AST parsingtree-sitter (TS/JS/Swift)
LLMOpenAI (gpt-4o-mini), pluggable
TestingVitest (800+ tests)
MCPstdio transport