GQLite is an educational, light-weight graph database implemented in plain C on top of RocksDB.
It supports a minimal subset of Cypher (Neo4j’s query language) and ships with a small CLI for experimentation, a public C API, and an automated test-suite.
- RocksDB key-value storage – no server process required (fully embedded)
- Nodes & directed, typed edges
- Simple label & id properties per node
- Sub-set of Cypher:
- CREATE – create nodes and/or a single edge in one statement
- MATCH – pattern matching on one hop (or single node) with optional WHERE
- DELETE – delete nodes or one edge that was previously matched
- RETURN – project any of var.id, var.label, or rel.type
- Thread-safe internal queues for neighbor pre-fetching
- Portable Makefile (tested on macOS)
- Unity-based unit tests
⚠️ This project is not intended for production but as a minimal, hackable playground for learning how graph stores work internally.
| C compiler | build C code (C11) | clang (or gcc) | build-essential |
| RocksDB | storage engine | brew install rocksdb | sudo apt install librocksdb-dev |
| pthreads | threading | included | included |
The Makefile assumes RocksDB headers live in one of:
- /opt/homebrew/opt/rocksdb/include (default Homebrew prefix on Apple-Silicon)
- /usr/include or /usr/local/include (typical Linux)
If your headers / libs are in a different path, override at build time:
Artifacts:
- graph – tiny demo that hard-codes some graph logic (see main.c)
- benchmark – inserts random data & measures throughput
- gqlite_cli – interactive Cypher shell (see below)
If db-path is omitted the CLI defaults to ./graphdb in the current directory.
See graphdb.h & cypher_parser.h for the full API surface.
GQLite intentionally supports only a single hop (one relationship) per pattern to stay tiny.
Limitations
• Only id & label properties on nodes (no dynamic properties)
• Single relationship per pattern
• No multi-hop, OPTIONAL MATCH, SET, MERGE, transactions, etc.
All tests reside in test/ and cover core graph primitives as well as the Cypher parser.
The benchmark inserts random nodes & edges and continuously measures insertion throughput using multiple threads.
Results on a MacBook Pro M1 Pro (10-core CPU, 16-GB RAM):
Key prefixes inside RocksDB:
| N | Node | N<node_id> → label |
| O | Edge | O<from>:<type>:<to> → "" |
| I | Edge (incoming) | I<to>:<type>:<from> → "" |
This dual-write pattern (O for outgoing, I for incoming) allows O(1) neighbor look-ups in either direction.
Licensed under the WTFPL license. See LICENSE for details.
.png)
![GPT-5.1 Instant and GPT-5.1 Thinking System Card Addendum [pdf]](https://news.najib.digital/site/assets/img/broken.gif)
