Developer/Products/graph-builder

graph-builder

@cognipeer/graph-builder  ·  Utilities
stable

An API-first TypeScript library that turns text sources into a queryable graph. Build it from texts, providers, or change streams — and persist, update, or replay the result.

License  ·  MITTypeScript  ·  100%Audience  ·  Teams modelling documentFits  ·  Knowledge graphs
Knowledge graphsIncremental ingestionPath queriesBrowse recipes
Production install
$npm install @cognipeer/graph-builder

What's in the box

Teams modelling document relationships, knowledge graphs, or multi-step reasoning over a corpus that needs to update over time without re-ingesting everything. Each capability is opt-in — use the parts that fit, leave the rest.

API-first design

Embed it inside any app — no CLI required. The entire graph lifecycle is exposed as composable functions.

Many input modes

Build from inline texts, from a custom provider, or from a change stream that yields updates over time.

Incremental updates

`fromChanges` and `updateGraph` evolve an existing graph without re-processing the whole corpus.

Built-in analysis

Identify god nodes, run path queries, and inspect link clusters with the included query helpers.

Serializable

Load and persist graphs as plain JSON — easy to ship across services, store in a DB, or diff in a PR.

Adapters included

Out-of-the-box adapters for to-markdown sources and OpenAI-compatible providers; bring your own for anything else.

How it runs

Turn a corpus into a queryable graph in two ways: build from inline texts, or stream changes through a provider. Inspect, persist, and update incrementally.

Step 1
Source
texts · provider
Step 2
Build
graphBuilder()
Step 3
Analyse
god nodes · paths
Step 4
Persist
JSON snapshot
Step 5
Update
fromChanges()

Builders

  • fromTexts(records)
  • fromProvider(provider)
  • fromChanges(prev, provider)
  • updateGraph(prev, patch)

Adapters

  • to-markdown
  • OpenAI-compatible
  • Custom providers
  • Change streams

Query

  • analysis.godNodes
  • query.path(a, b)
  • artifacts.report
  • loadGraph(json)

Quickstart

Install, configure, run. The example below is the smallest piece of code that does something useful in production.

1import { graphBuilder } from "@cognipeer/graph-builder";
2 
3const result = await graphBuilder.fromTexts([
4  { id: "docs/overview.md", title: "Overview",
5    text: "# Overview\n\nSee [Guide](guide.md)." },
6  { id: "docs/guide.md", title: "Guide",
7    text: "# Guide\n\nThis explains the flow." },
8]);
9 
10console.log(result.analysis.godNodes);
11console.log(result.query.path("Overview", "Guide"));

How it compares

Against the utilities options teams most often weigh — focused on operational concerns, not feature inventories.

Capabilitygraph-builderLangChain GraphIndexCreatorNeo4j + bespoke pipelineLlama-Index KnowledgeGraph
Text → graph●  native●  native●  native●  native
Incremental updates●  native○  missing●  native◐  partial
Path queries●  native◐  partial●  native◐  partial
Provider adapters●  native◐  partial○  missing◐  partial
TypeScript●  native◐  partial◐  partial○  missing
Open source●  native●  native◐  partial●  native

Next steps