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

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.5.0.tar.gz (160.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.5.0-py3-none-any.whl (65.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: grai_build-0.5.0.tar.gz
  • Upload date:
  • Size: 160.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.5.0.tar.gz
Algorithm Hash digest
SHA256 785cfac7c41b665c34d41c6d4d9f0e5a35b5dbdf7488eab0bc2d3e1f337a140e
MD5 55a66104e94844cb84e9aa6fe89e8f0a
BLAKE2b-256 8fbd00e4fe716521d203d2992234b570ca51f60e4d08a54c11652d5c4f83815f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grai_build-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 65.7 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a705f3e8722d5391a98dc27cd4f87ed95b27507234495529ad901447bc49f713
MD5 5df037d00b1efc74608f0b38515d182f
BLAKE2b-256 2bc46b29d09c66868fd7289d2b8b1c2c0af9dd5ed03c75fd937cec089f649178

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