neo4j-labs/create-context-graph
AI agents with graph based reasoning memory, scaffolded in seconds
What is Create Context Graph?
Create Context Graph is a command‑line wizard that scaffolds a complete, domain‑specific “knowledge‑graph‑backed” AI application. You tell the tool:
- the industry you care about (healthcare, finance, wildlife management, …),
- which LLM‑agent framework you want (e.g., Strands, PydanticAI, LangGraph, Claude SDK), and
- whether you want a hosted memory service (NAMS) or a self‑hosted Neo4j instance.
The CLI then generates a ready‑to‑run full‑stack project:
- FastAPI backend with an LLM agent that stores conversation context in a Neo4j graph (or in Neo4j‑backed NAMS).
- Next.js + Chakra UI frontend that shows a chat window, an interactive graph view, a document browser and a decision‑trace viewer.
- Neo4j schema and optional demo data for the chosen domain.
- Optional connectors that import real data from SaaS tools (GitHub, Slack, Notion, etc.) into the graph.
All of this is produced in a few minutes, letting you experiment with a “context graph” – a graph that stores entities extracted from the LLM’s dialogue and links them to documents, tools, and decisions.
Who Might Use It?
| Audience | Why it helps |
|---|---|
| Product teams building a domain‑specific AI assistant (e.g., a medical‑record chatbot) | One‑click scaffolding of the whole stack – backend, frontend, Neo4j schema, and data import. |
| Data engineers / knowledge‑graph specialists who want to try LLM‑driven entity extraction on existing SaaS data | Built‑in connectors pull data from GitHub, Slack, Notion, Linear, etc., and automatically map it into a graph. |
| Researchers / students exploring graph‑augmented LLM agents | Ready‑made demo domains and synthetic data let you focus on the agent logic rather than wiring infrastructure. |
| Neo4j customers looking for a reference implementation of “agent memory” | Shows how to combine Neo4j, LiteLLM, and various agent SDKs in a production‑style FastAPI service. |
How Does It Work?
- Wizard –
create-context-graphasks a few prompts (domain, framework, memory backend, demo data, connectors). You can also run it non‑interactively with flags. - Domain ontology – A YAML file describing entity types, relationships, and tool definitions is selected (or generated from a free‑text description). This drives code generation.
- Template rendering – Jinja2 templates turn the ontology into:
- Neo4j schema (
schema.cypher) - Pydantic models for the FastAPI API
- Agent‑specific tool wrappers
- Front‑end components that visualise the graph.
- Neo4j schema (
- Memory layer – The generated backend wires the neo4j‑agent‑memory library (v0.4). It can talk to:
- NAMS – a hosted Neo4j‑backed memory service (default). Only a NAMS API key is needed.
- Self‑hosted Neo4j – bolt connection to a local or Aura instance, giving full Cypher, GDS, and relationship support.
- LLM integration – The agent uses LiteLLM‑compatible provider strings, so you can plug in Anthropic, OpenAI, Bedrock, Ollama, etc. Entity extraction defaults to Claude‑haiku or GPT‑4o‑mini.
- Frontend – A Next.js app shows:
- Streaming chat (Server‑Sent Events)
- Real‑time tool‑call visualisation
- Interactive graph view (expand nodes, drag/zoom, property panel)
- Document browser and a trace viewer for the agent’s reasoning steps.
- Data import – If you selected connectors, the scaffold includes scripts (
import_data.py) and amake importtarget to pull data from the chosen SaaS services into Neo4j.
What’s Inside a Generated Project?
my-app/
├─ backend/ # FastAPI service
│ ├─ app/main.py # entry point
│ ├─ app/agent.py # LLM agent (framework‑specific)
│ ├─ app/memory.py # Neo4j‑or‑NAMS memory integration
│ ├─ app/context_graph_client.py # CRUD helpers for Neo4j
│ ├─ app/gds_client.py # optional Graph Data Science calls
│ └─ connectors/ # SaaS import code (if selected)
├─ frontend/ # Next.js + Chakra UI UI
│ ├─ components/ChatInterface.tsx # streaming chat UI
│ ├─ components/ContextGraphView.tsx # interactive graph
│ └─ …
├─ data/ontology.yaml # domain definition used for generation
├─ data/fixtures.json # synthetic demo entities (if --demo)
├─ cypher/schema.cypher # constraints & indexes
├─ docker‑compose.yml # optional Neo4j container for self‑hosted mode
├─ Makefile # install, start, seed, import, test …
└─ README.md # project‑specific docs
When to Choose Hosted vs Self‑Hosted Memory
| Feature | NAMS (hosted) | Self‑hosted Neo4j |
|---|---|---|
| Setup | No Neo4j install, just an API key | Run Docker/Aura, configure bolt URL |
| Write capabilities | Only entity creation; relationships are stored as markdown blocks inside description |
Full Cypher writes, native edges, GDS algorithms |
| Scalability | Managed service, limited to Neo4j‑backed REST API | You control cluster size, replication, etc. |
| Cost | Pay‑as‑you‑go on Neo4j Labs memory service | Depends on your Neo4j deployment |
| Use case | Quick demos, prototyping, personal knowledge bases | Production‑grade apps needing complex graph queries or analytics |
Quick‑Start Example (Python, NAMS)
uvx create-context-graph my‑app \
--domain healthcare \
--framework strands \
--nams‑api‑key sk‑nams‑…
cd my‑app
make install # pip install + npm install
make start # launches FastAPI + Next.js
Visit http://localhost:3000 for the UI and http://localhost:8000/docs for the API.
Limitations & Caveats
- The NAMS backend cannot create native Neo4j relationships or run arbitrary Cypher; the generated app works around this by encoding edges in markdown.
- Some advanced Graph Data Science (GDS) features are only available in self‑hosted mode.
- Memory providers other than the defaults require you to supply LiteLLM strings and possibly API keys.
- The project is experimental – it is maintained by Neo4j Labs but not officially supported.
Bottom Line
Create Context Graph turns a handful of choices (domain, agent framework, memory backend) into a fully‑functional AI‑augmented graph application in minutes. It is ideal for anyone who wants to explore how LLM agents can store and reason over a Neo4j knowledge graph without writing the plumbing from scratch.
Useful Links (from the repo)
- Docs site – https://create-context-graph.dev/
- Neo4j‑agent‑memory – https://github.com/neo4j-labs/agent-memory
- Community help – GitHub Issues, Neo4j Community Forum
- License – see repository (MIT‑style typical for Neo4j Labs projects)
Related
- Project
- Project
- Project
- Project