> ## 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.

# Ladybug Graph Store

> Store your knowledge graph in Ladybug, cognee's embedded graph database, and search it with recall

A minimal guide to using Ladybug — cognee's default, embedded graph database — as the graph store. Ladybug ships with cognee and runs in-process, so this is the fastest way to build a knowledge graph on your own machine without standing up a database server.

## Before You Start

* Complete [Quickstart](/getting-started/quickstart) to understand basic operations
* Ensure you have [LLM Providers](/setup-configuration/llm-providers) configured (`LLM_API_KEY` in `.env`)
* Ensure you have [Embedding Providers](/setup-configuration/embedding-providers) configured, since `remember()` embeds the text it ingests
* Read [Graph Stores](/setup-configuration/graph-stores) for the full list of graph backends and their settings
* Nothing to install: Ladybug is embedded and ships with cognee — no server to start and no pip extra to add

## Code in Action

```python theme={null}
import asyncio
import pathlib

import cognee
from cognee import SearchType


async def main():
    # Configure Ladybug as the graph database provider
    cognee.config.set_graph_db_config(
        {
            "graph_database_provider": "ladybug",  # Specify Ladybug as provider
        }
    )

    # Set up data directories for storing documents and system files
    # You should adjust these paths to your needs
    current_dir = pathlib.Path(__file__).parent
    data_directory_path = str(current_dir / "data_storage")
    cognee.config.data_root_directory(data_directory_path)

    cognee_directory_path = str(current_dir / "cognee_system")
    cognee.config.system_root_directory(cognee_directory_path)

    # Clean any existing data (optional)
    # await cognee.forget(everything=True)

    # Create a dataset
    dataset_name = "ladybug_example"

    # Add sample text to the dataset
    sample_text = """Ladybug is a graph database system optimized for running complex graph analytics.
    It is designed to be a high-performance graph database for data science workloads.
    Ladybug is built with modern hardware optimizations in mind.
    It provides support for property graphs and offers a Cypher-like query language.
    Ladybug can handle both transactional and analytical graph workloads.
    The database now includes vector search capabilities for AI applications and semantic search."""

    # Add the sample text to the dataset
    await cognee.remember([sample_text], dataset_name=dataset_name, self_improvement=False)

    # Now let's perform some searches
    # 1. Search for insights related to "Ladybug"
    insights_results = await cognee.recall(
        query_type=SearchType.GRAPH_COMPLETION, query_text="Ladybug"
    )
    print("\nInsights about Ladybug:")
    for result in insights_results:
        print(f"- {result}")

    # 2. Search for text chunks related to "graph database"
    chunks_results = await cognee.recall(
        query_type=SearchType.CHUNKS, query_text="graph database", datasets=[dataset_name]
    )
    print("\nChunks about graph database:")
    for result in chunks_results:
        print(f"- {result}")

    # 3. Get graph completion related to databases
    graph_completion_results = await cognee.recall(
        query_type=SearchType.GRAPH_COMPLETION, query_text="database"
    )
    print("\nGraph completion for databases:")
    for result in graph_completion_results:
        print(f"- {result}")

    # Clean up (optional)
    # await cognee.forget(everything=True)


if __name__ == "__main__":
    asyncio.run(main())
```

## What Just Happened

### Step 1: Select Ladybug as the Graph Provider

```python theme={null}
cognee.config.set_graph_db_config(
    {
        "graph_database_provider": "ladybug",  # Specify Ladybug as provider
    }
)
```

`set_graph_db_config()` updates cognee's graph configuration, and `graph_database_provider` decides which database the knowledge graph is written to. Ladybug is already the default, so this call is explicit rather than required — it documents the choice and makes the script behave the same way even if `GRAPH_DATABASE_PROVIDER` is set in your environment.

### Step 2: Point Cognee at Local Directories

```python theme={null}
current_dir = pathlib.Path(__file__).parent
data_directory_path = str(current_dir / "data_storage")
cognee.config.data_root_directory(data_directory_path)

cognee_directory_path = str(current_dir / "cognee_system")
cognee.config.system_root_directory(cognee_directory_path)
```

The data root holds the copies of ingested documents; the system root holds cognee's databases, including the embedded Ladybug graph file. Setting both next to the script keeps this example's graph separate from your default cognee directories, so you can delete the two folders to start over.

### Step 3: Remember the Sample Text

```python theme={null}
# Create a dataset
dataset_name = "ladybug_example"

# Add sample text to the dataset
sample_text = """Ladybug is a graph database system optimized for running complex graph analytics.
It is designed to be a high-performance graph database for data science workloads.
Ladybug is built with modern hardware optimizations in mind.
It provides support for property graphs and offers a Cypher-like query language.
Ladybug can handle both transactional and analytical graph workloads.
The database now includes vector search capabilities for AI applications and semantic search."""

# Add the sample text to the dataset
await cognee.remember([sample_text], dataset_name=dataset_name, self_improvement=False)
```

`remember()` ingests the text, extracts entities and relationships from it, and writes the resulting nodes and edges into Ladybug. `dataset_name` groups everything this call produces under one dataset so later searches can be scoped to it.

### Step 4: Ask the Graph a Question

```python theme={null}
insights_results = await cognee.recall(
    query_type=SearchType.GRAPH_COMPLETION, query_text="Ladybug"
)
print("\nInsights about Ladybug:")
for result in insights_results:
    print(f"- {result}")
```

`SearchType.GRAPH_COMPLETION` retrieves the triplets Ladybug stores around the query and asks the LLM to answer from them. This is the search type that actually exercises the graph, so it is the quickest way to confirm the store is populated.

### Step 5: Read the Underlying Chunks

```python theme={null}
chunks_results = await cognee.recall(
    query_type=SearchType.CHUNKS, query_text="graph database", datasets=[dataset_name]
)
print("\nChunks about graph database:")
for result in chunks_results:
    print(f"- {result}")
```

`SearchType.CHUNKS` skips the answer generation and returns the raw text chunks behind a query, which is useful for checking what was ingested. `datasets=[dataset_name]` limits the search to the dataset created above instead of everything in the store.

<Columns cols={2}>
  <Card title="Graph Stores" icon="network" href="/setup-configuration/graph-stores">
    Configure a different graph backend when you outgrow the embedded one.
  </Card>

  <Card title="Graph Engine and Adapters" icon="share-2" href="/guides/graph-engine-adapters">
    See how cognee talks to whichever graph database is configured.
  </Card>
</Columns>
