Skip to main content

Declarative knowledge graph modeling tool inspired by dbt

Project description

grai.build

Schema-as-code for graph databases — Define schemas in YAML, generate docs like dbt, manage migrations like Alembic.

CI codecov PyPI Python 3.11+ License: MIT

What is grai.build?

grai.build manages your graph schema, not your data. Define entities and relations in YAML, and grai.build:

  • Validates schema for consistency before deployment
  • Compiles to Cypher constraints and indexes
  • Generates interactive documentation (like dbt docs)
  • Tracks lineage with visualizations
  • Manages migrations with version control

What it's not: An ETL tool. Use Airflow, Prefect, or dbt for data loading — grai.build handles the schema layer.

Quick Start

pip install grai-build

# Initialize a project
grai init my-graph-project
cd my-graph-project

# Validate and build
grai build

# Generate documentation
grai docs --serve

# Deploy to Neo4j
grai run --uri bolt://localhost:7687 --user neo4j --password secret

Project Structure

my-graph-project/
├── grai.yml              # Project configuration
├── entities/
│   ├── customer.yml      # Node definitions
│   └── product.yml
├── relations/
│   └── purchased.yml     # Relationship definitions
└── target/
    └── neo4j/
        └── compiled.cypher

Schema Definition

Entity (entities/customer.yml):

entity: customer
source: analytics.customers
keys: [customer_id]
properties:
  - name: customer_id
    type: string
  - name: name
    type: string
  - name: region
    type: string

Relation (relations/purchased.yml):

relation: PURCHASED
from: customer
to: product
source: analytics.orders
mappings:
  from_key: customer_id
  to_key: product_id
properties:
  - name: order_id
    type: string
  - name: order_date
    type: datetime

Compiled output (target/neo4j/compiled.cypher):

MERGE (n:customer {customer_id: row.customer_id})
SET n.name = row.name, n.region = row.region;

MATCH (from:customer {customer_id: row.customer_id})
MATCH (to:product {product_id: row.product_id})
MERGE (from)-[r:PURCHASED]->(to)
SET r.order_id = row.order_id, r.order_date = row.order_date;

Features

Feature Description
Schema validation Catch reference errors and type mismatches before deployment
Cypher compilation Generate constraints, indexes, and merge statements
Documentation Interactive HTML docs with entity catalog and graph visualization
Lineage tracking Dependency graphs and impact analysis
Migrations Version-controlled schema changes with up/down scripts
Build caching Incremental builds for faster iteration

CLI Commands

grai init <name>       # Create new project
grai validate          # Validate schema
grai build             # Compile project
grai run               # Deploy to Neo4j
grai docs              # Generate documentation
grai lineage           # Show dependency graph
grai migrate-generate  # Create migration from changes
grai migrate-apply     # Apply pending migrations

CI/CD Integration

# .github/workflows/deploy-schema.yml
name: Deploy Graph Schema

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Validate Schema
        run: grai validate

      - name: Deploy to Production
        run: |
          grai run --schema-only \
            --uri ${{ secrets.NEO4J_URI }} \
            --user ${{ secrets.NEO4J_USER }} \
            --password ${{ secrets.NEO4J_PASSWORD }}

Development

git clone https://github.com/asantora05/grai.build.git
cd grai.build
pip install -e ".[dev]"
pytest

Roadmap

  • YAML schema definition and validation
  • Cypher compilation for Neo4j
  • Documentation generation
  • Lineage tracking and visualization
  • Schema migrations
  • Gremlin backend support
  • Incremental sync

Contributing

Contributions welcome. See CONTRIBUTING.md for guidelines.

License

MIT — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grai_build-0.4.2.tar.gz (158.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grai_build-0.4.2-py3-none-any.whl (65.5 kB view details)

Uploaded Python 3

File details

Details for the file grai_build-0.4.2.tar.gz.

File metadata

  • Download URL: grai_build-0.4.2.tar.gz
  • Upload date:
  • Size: 158.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for grai_build-0.4.2.tar.gz
Algorithm Hash digest
SHA256 e5bc99ff899618a7e59400bbac63283cf7cddaa05a194f245d3117798d130139
MD5 df3b40bbf88097ca7638af98a4fc9223
BLAKE2b-256 20b834e90a98fb538d604a8a3547bb5035356c54fa7ed7d7d90399b2fba4643c

See more details on using hashes here.

File details

Details for the file grai_build-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: grai_build-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 65.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for grai_build-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0159541bbaf6c5ee0e1afac5e2c2510c56089aff22ea947c4e33d84f84a6f99e
MD5 3d8fdbc0e860f6d93ddba4750628ba05
BLAKE2b-256 d84916648a7211ad364c90d21af7fb7236e81bcc7ab251eff18527a2976afcad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page