> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Developer Knowledge Base

> Turn an engineer's profile, past copilot conversations, and a coding-principles document into one memory you can question across all three

Everything you know about how an engineer works is scattered: a short profile, months of assistant conversations full of code, and a team document of coding principles nobody cross-references. Answering "does the code I wrote actually follow the principles we agreed on?" means holding all three in your head at once.

## What You'll Build

Three heterogeneous sources — a plain-text developer profile, a JSON export of human/assistant coding conversations, and a Markdown guide to the Zen of Python — go into memory under two node sets, with an OWL ontology grounding the entities that get extracted. A `memify()` pass then consolidates the graph, and you get two interactive HTML snapshots (before and after) plus answers to two questions: one that has to reach across the conversations and the principles document at once, and one deliberately scoped to the principles alone.

The complete runnable script is
[`examples/demos/comprehensive_example/cognee_comprehensive_example.py`](https://github.com/topoteretes/cognee/blob/main/examples/demos/comprehensive_example/cognee_comprehensive_example.py) —
this page walks through its key moments rather than reproducing it.

## Features in Play

* [NodeSet Grouping](/guides/nodeset-grouping) — labels the profile and conversations as `developer_data` and the Zen guide as `principles_data`, so the second question can be answered from the principles alone
* [Ontology Quickstart](/guides/ontology-support) — the bundled OWL file grounds extraction in a shared vocabulary instead of letting each source invent its own entity names
* [Memify](/core-concepts/main-operations/legacy-operations/memify) — the consolidation pass that runs between the two snapshots and enriches the connections across sources
* [Graph Visualization](/guides/graph-visualization) — renders the graph twice, so the effect of consolidation is something you can look at rather than infer
* [Recall](/core-concepts/main-operations/recall) — answers both questions with `GRAPH_COMPLETION`, once across the whole graph and once filtered to one node set

## Before You Start

* Complete [Quickstart](/getting-started/quickstart) to understand basic operations
* Ensure you have [LLM Providers](/setup-configuration/llm-providers) and [Embedding Providers](/setup-configuration/embedding-providers) configured
* The script sets `os.environ["LLM_API_KEY"] = "your_api_key"` at the top as a placeholder — replace it with your own key, or delete the line if your `.env` already carries one
* Run it from a cognee repo checkout rather than a copy-paste: it reads three bundled files from the sibling `data/` folder — `copilot_conversations.json`, `zen_principles.md`, and `basic_ontology.owl`
* The run starts with `cognee.forget(everything=True)`, which wipes all existing Cognee data — use a setup you can afford to reset

## How It Works

### Stage 1: Locate the Bundled Sources

```python theme={null}
data_dir = Path(__file__).resolve().parent / "data"
asset_paths = {
    "human_agent_conversations": str(data_dir / "copilot_conversations.json"),
    "python_zen_principles": str(data_dir / "zen_principles.md"),
    "ontology": str(data_dir / "basic_ontology.owl"),
}
```

The three inputs are resolved relative to the script file, so the demo works from any working directory as long as it runs inside the repo checkout. Two of them are data to ingest; the third is the ontology that shapes how that data is read.

### Stage 2: Ground Extraction in the OWL Ontology

```python theme={null}
os.environ["ONTOLOGY_FILE_PATH"] = ontology_path
```

The ontology is configured through the environment rather than passed as an argument, and this assignment happens **before** `import cognee` — Cognee reads env-backed settings at import time, so setting it afterwards would not take effect. Every source ingested below is extracted against this shared vocabulary.

### Stage 3: Ingest Three Sources into Two Node Sets

```python theme={null}
    await cognee.forget(everything=True)

    await cognee.remember(developer_intro, node_set=["developer_data"], self_improvement=False)
    await cognee.remember(
        human_agent_conversations,
        node_set=["developer_data"],
        self_improvement=False,
    )
    await cognee.remember(
        python_zen_principles,
        node_set=["principles_data"],
        self_improvement=False,
    )
```

A clean slate, then three `remember()` calls that differ in what they take — an inline string, a JSON path, and a Markdown path — but land in the same graph. The node sets do the sorting: the engineer's profile and their conversations become `developer_data`, the Zen guide becomes `principles_data`. `self_improvement=False` skips the automatic enrichment pass so that the `memify()` call in the next stage is the only consolidation step, and its effect is visible in isolation.

### Stage 4: Snapshot the Graph Before and After Consolidation

```python theme={null}
    # generate the initial graph visualization showing nodesets and ontology structure
    initial_graph_visualization_path = os.path.join(
        os.path.dirname(__file__), artifacts_path, "graph_visualization_nodesets_and_ontology.html"
    )
    await cognee.visualize_graph(initial_graph_visualization_path)

    # enhance the knowledge graph with memory consolidation for improved connections
    await cognee.memify()

    # generate the second graph visualization after memory enhancement
    enhanced_graph_visualization_path = os.path.join(
        os.path.dirname(__file__), artifacts_path, "graph_visualization_after_memify.html"
    )
    await cognee.visualize_graph(enhanced_graph_visualization_path)
```

The same render runs on either side of `memify()`. The first file shows what ingestion alone produced — the two node sets and the ontology-grounded entities under them; the second shows the graph after consolidation has enriched the connections between them. Opening both is the point of the stage.

### Stage 5: Ask a Question That Spans Sources

```python theme={null}
    results = await cognee.recall(
        query_text="How does my AsyncWebScraper implementation align with Python's design principles?",
        query_type=cognee.SearchType.GRAPH_COMPLETION,
    )
```

`AsyncWebScraper` appears only in the conversation export; "Python's design principles" only in the Zen guide. Neither source answers this question alone, and with no node-set filter the recall traverses the whole graph — so the answer has to be assembled from both.

### Stage 6: Scope Recall to One Node Set

```python theme={null}
    results = await cognee.recall(
        query_text="How should variables be named?",
        query_type=cognee.SearchType.GRAPH_COMPLETION,
        node_name=["principles_data"],
    )
```

The same search type, now restricted to `principles_data` via `node_name`. This is what the tagging in Stage 3 bought: a question about conventions answered from the principles document, without the engineer's own past code influencing the answer.

## Run It

```bash theme={null}
uv run python examples/demos/comprehensive_example/cognee_comprehensive_example.py
```

A successful run prints two lines after the ingestion and consolidation progress: `Python Pattern Analysis:` followed by an answer that connects the scraper implementation to specific Zen principles, and `Filtered search result:` followed by a naming-convention answer drawn from the principles document. It also leaves two HTML files in an `.artifacts` folder next to the script — `graph_visualization_nodesets_and_ontology.html` and `graph_visualization_after_memify.html` — which you open in a browser to compare the graph before and after `memify()`.

<Columns cols={2}>
  <Card title="NodeSet Grouping" icon="layers" href="/guides/nodeset-grouping">
    Learn the tagging this demo uses to keep two topics apart in one graph.
  </Card>

  <Card title="Ontology Quickstart" icon="git-branch" href="/guides/ontology-support">
    Step through grounding extraction in your own OWL vocabulary.
  </Card>

  <Card title="Graph Visualization" icon="network" href="/guides/graph-visualization">
    Render and bound the graph snapshots this demo compares.
  </Card>

  <Card title="Recall" icon="search" href="/core-concepts/main-operations/recall">
    See the full set of recall parameters behind both questions.
  </Card>
</Columns>
