Skip to content
Business Agile
← Work
Open source · Python models for graph databases · In development

CypherModel

Pydantic models for graph databases that speak Cypher, asynchronous and strongly typed.

Key figures

target databases, Memgraph and Neo4j2
target Python versions3.11+
licence, designed in the openMIT

CypherModel is a Python library for working with graph databases that speak Cypher, Memgraph and Neo4j, from Python objects. It is designed to be asynchronous end to end, strictly typed, and to keep Cypher one step away rather than hiding it.

The project in detail

It is aimed at FastAPI applications that read and write a graph, like the knowledge graph projects where I use Neontology today, ScienceProtect first among them. It follows the path SQLModel opened for SQL databases: a thin layer on top of Pydantic and a solid driver, here the asynchronous Neo4j Python driver, which both Neo4j and Memgraph recommend. It also stands on what others built: Neontology, which I contributed to, for Pydantic first graph models and relationship classes, and neomodel for a complete asynchronous OGM on Neo4j.

A node is a Pydantic model: the same class validates a request, documents the OpenAPI schema and maps to the graph. A relationship is a model in its own right, with its properties, its source and its target, not an attribute hidden in a node. A typed query builder covers the common cases, and hand written Cypher with typed results covers the rest. Writes are batched with `UNWIND`, and concurrent writers that share a node can be serialized instead of fighting over it.

The library is designed in the open: its site describes the target API before the first version, so the choices are discussed before they are set. It will be published on PyPI under the MIT licence, for Python 3.11 and above, and its code is public on GitHub.

What was done

  1. 01

    Nodes and relationships described as Pydantic models

  2. 02

    Asynchronous end to end, on the driver Neo4j and Memgraph recommend

  3. 03

    Relationships are models in their own right

  4. 04

    A typed query builder, and hand written Cypher when needed

  5. 05

    Designed in the open: the target API is described before the first version

Frequently asked questions

Can CypherModel be used already?

Not yet. Its site describes the target API, and the first version will be published on PyPI once that API is built and tested. Designing in the open lets the choices be discussed before they are set.

How does it differ from Neontology?

CypherModel takes up its idea of Pydantic graph models and relationship classes, and pushes it towards a library that is asynchronous end to end, strongly typed and built on the asynchronous Neo4j Python driver, the way SQLModel works for SQL databases.

Does it work with FastAPI?

That is its home ground: the same models validate requests, document the OpenAPI schema and talk to the graph, and every route stays async def.

Does it work with embedded graph databases such as LadybugDB or Relate?

Not in the first version. CypherModel targets databases reachable over the Bolt protocol first, Memgraph and Neo4j, through the asynchronous Neo4j driver. Relate can expose a Bolt server and could be reached that way, which is still to be tested. Purely embedded engines such as LadybugDB, which do not speak Bolt, will come later, behind a dedicated engine interface, as the design page plans.

Other work

FabArto
fabarto.eu
Web
Ti Kosmeo
tikosmeo.fr
Web
Antiquité Mallarmé
antiquitemallarme.fr
Web
Maison Ozaé
maisonozae.eu
Web
ScienceProtect
scienceprotect.com
AI
Neontology
github.com/ontolocy/neontology
Open source
Pousses & Plantes
Plant marketplace
App
Arbre Agile
Artificial intelligence consulting and development
Web
Groupe BERREBI
Holding company and corporate website
Web
SNCF
Rail transport, internal applications
API
Pitchichi
guide.pitchichi.com
App
Appétit
Independent bookshop, cookbooks and photography
Web
Good Day
Media, consumer mobile application
App
Fondation Nestlé France
Corporate foundation, food and health
Web
DMD Prices
Art, canvas printing, online quoting
Web
IoTBox
Connected devices, industrial solutions
Web
PrevenFit
Services for fitness clubs, subscriber area
App
Securicate
Security equipment, online shop
E-commerce
WeChamp
Sport, corporate events
Web
Jaco
Media monitoring, subscription software
App
AWA
Education and film, project with an international reach
Web
Quizz Paris
Risk prevention, public awareness
App
La Gestion en Ligne
Rental management, online service
Web
Quotidien Libre
Online press, daily news
Web
Ophtalmologie Percy
Healthcare, military hospital
Web
Flashing Records
Music, label and event programming
Web
Apérothérapie
Wine and fine food, online retail
E-commerce
Arnaud CANIZARES
Contemporary art, artist portfolio
Web
Montebello Psychologue
Psychology and neuropsychology practice
Web
TapToSupport
Donation collection for non-profits
API
24hprojects
MVP delivery platform
App
Eco-Actives
Ecological transition and DIY workshops
E-commerce

A project? Let's talk this week.

A short brief, an answer within 48 hours, a firm estimate after scoping.

Describe my project