Skip to content
GitHub

Quickstart

Terminal window
uv add lexigram-graph

Add the optional Neo4j extra for production use:

Terminal window
uv add "lexigram-graph[neo4j]"

The in-memory backend requires no extra dependencies.


import asyncio
from lexigram import Application
from lexigram.contracts.data.graph import GraphStoreProtocol
from lexigram.graph import GraphModule, GraphConfig
async def main() -> None:
async with Application.boot(
name="graph-demo",
modules=[
GraphModule.configure(
GraphConfig(backend="memory")
),
],
) as app:
graph = await app.container.resolve(GraphStoreProtocol)
db = await graph.get_graph()
node = await db.create_node(["Person"], {"name": "Alice"})
print(f"Created node: {node.id}")
asyncio.run(main())

For Neo4j:

Terminal window
uv add "lexigram-graph[neo4j]"
config = GraphConfig(backend="neo4j")

  1. GraphModule.configure() creates a GraphProvider with the given config.
  2. The provider registers GraphStoreProtocol and GraphProtocol in the container.
  3. On boot, it connects to the configured backend (in-memory or Neo4j).
  4. Services receive graph handles via constructor injection.
  • Guide — mental model, core concepts, common patterns
  • How-Tos — task-oriented recipes
  • Configuration — every config key with env-var names