How bruju/prec works
PREC converts property graphs into RDF, optionally applying a Turtle context to map graph labels and properties into domain vocabularies. Users can start from Neo4j, Gremlin, or exported JSON; the CLI and library build a PREC-0 intermediate graph, then apply PREC-C or PRSC rules and emit an RDF dataset. It also supports applying contexts to existing RDF and reversing PREC-0 or well-behaved PRSC output back to property graphs. Some subsystem details are represented by their exact source directories because their implementations were not excerpted.
Main entry points: cli_.ts CLI · PGDefinitions.ts PREC-0 model · graph-builder.ts PG graph builder · apply-context.ts Apply context
Components 26
Graph ingestion
- CLI
src/cli_.ts - Cypher adapter
src/prec-0/from-cypher.js - Gremlin adapter
src/prec-0/from-gremlin.js - PG graph builder
src/prec/graph-builder.ts
RDF conversion
- PREC-0 model
src/prec-0/PGDefinitions.ts - RDF dataset
src/dataset/index.ts - RDF parsing
src/rdf/parsing.ts - PREC vocabulary
src/PRECNamespace.ts - RDF path utilities
src/rdf/path-travelling.ts - RDF-star utilities
src/rdf/quad-star.ts
Context mapping
- Apply context
src/prec/apply-context.ts - PREC-C context
src/prec-c/Context.ts - PREC-C rule processing
src/prec-c/context-loader.ts - PREC-C mapping rules
src/prec-c - PRSC context
src/prsc/PrscContext.ts - PRSC rules
src/prsc/PrscRule.ts - Apply PRSC
src/prsc/index.ts - Well-behaved check
src/prsc/well-behaved-check.ts
Reverse conversion
- PREC-0 reversion
src/prec-0/prec-0-reversion.ts - PRSC reversion
src/prsc/prsc-reversion.ts - Cypher output
src/prec-0/from-cypher.js - Gremlin output
src/prec-0/from-gremlin.js
Other components
- User
- Neo4j source
- Gremlin source
- Exported PG JSON
Connections 29
- User → CLI: runs commands
README.md - Neo4j source → CLI: provides graph
README.md - Gremlin source → CLI: provides graph
README.md - Exported PG JSON → CLI: provides export
README.md - CLI → Cypher adapter: loads Cypher data
src/cli_.ts - CLI → Gremlin adapter: loads Gremlin data
src/cli_.ts - CLI → PG graph builder: builds graph
src/cli_.ts - Cypher adapter → PREC-0 model: represents graph
- Gremlin adapter → PREC-0 model: represents graph
- PG graph builder → RDF dataset: builds dataset
src/prec/graph-builder.ts - PG graph builder → PREC-0 model: uses definitions
src/prec/graph-builder.ts - CLI → Apply context: applies context
src/cli_.ts - CLI → RDF parsing: parses RDF
src/cli_.ts - Apply context → PREC-C context: applies PREC-C
src/prec/apply-context.ts - Apply context → Apply PRSC: applies PRSC
src/prec/apply-context.ts - PREC-C context → PREC-C rule processing: configures rules
src/prec-c/Context.ts - PREC-C context → PREC-C mapping rules: uses rule stages
src/prec-c/Context.ts - Apply PRSC → PRSC context: builds context
src/prsc/index.ts - PRSC context → PRSC rules: uses rules
src/prsc/PrscContext.ts - PRSC context → RDF path utilities: follows graph paths
src/prsc/PrscContext.ts - PRSC rules → RDF-star utilities: characterizes triples
src/prsc/PrscRule.ts - Well-behaved check → PRSC rules: checks validity
src/prsc/well-behaved-check.ts - RDF dataset → RDF-star utilities: handles RDF-star
src/dataset/index.ts - CLI → PREC-0 reversion: reverts PREC-0
src/cli_.ts - CLI → PRSC reversion: reverts PRSC
src/cli_.ts - PRSC reversion → Well-behaved check: checks context
src/prsc/prsc-reversion.ts - CLI → Cypher output: prints Cypher
README.md - CLI → Gremlin output: populates Gremlin
README.md - PREC vocabulary → PREC-0 model: defines terms