Skip to main content
Infrahub is built on a foundation of interconnected concepts that work together to provide a powerful infrastructure data management platform. This page introduces the core principles and features that make Infrahub unique.

The three pillars

Infrahub’s architecture rests on three fundamental pillars that enable its unique approach to infrastructure management:

Flexible schema

Infrahub schema The schema is a versioned data model that defines the structure of your infrastructure: the nodes (objects), their attributes (properties), and relationships between them. Unlike traditional databases with rigid schemas, Infrahub’s schema is:
  • Fully customizable: Define any node type, attribute, or relationship your infrastructure needs
  • Version controlled: Schema changes are tracked in branches and can be tested before merging
  • YAML-based: Easy to read, write, and manage in Git alongside your code
  • Self-documenting: Schema definitions include labels, descriptions, and validation rules

Schema components

A schema consists of:
  • Nodes: The primary objects in your infrastructure (e.g., Device, Site, VLAN)
  • Attributes: Properties of nodes (e.g., name, IP address, status)
    • Types: Text, Number, Boolean, Dropdown, JSON, DateTime, URL, etc.
    • Validation: Unique, optional, regex patterns, min/max values
  • Relationships: Connections between nodes
    • Attribute relationships: Simple foreign keys (many-to-one)
    • Component relationships: Parent-child with cascading deletion
    • Generic relationships: Many-to-many associations
    • Hierarchy relationships: For modeling organizational structures

Example schema

version: '1.0'
nodes:
  - name: Device
    namespace: Infra
    description: "A network device"
    display_label: "{{ name__value }}"
    attributes:
      - name: name
        kind: Text
        unique: true
      - name: role
        kind: Dropdown
        choices:
          - name: router
            color: "#0099ff"
          - name: switch
            color: "#00cc66"
      - name: status
        kind: Dropdown
        choices:
          - name: active
          - name: planned
        default_value: "active"
    relationships:
      - name: site
        peer: InfraSite
        cardinality: one
        kind: Attribute
      - name: interfaces
        peer: InfraInterface
        cardinality: many
        kind: Component
This schema defines a Device node with attributes and relationships. Once loaded, Infrahub automatically generates:
  • GraphQL mutations for creating/updating devices
  • UI forms for data entry
  • Validation rules
  • Database indexes

Create a Schema

Step-by-step guide to defining your own schema.

Schema Topic

Deep dive into schema design and capabilities.

Version control

Infrahub Version Control Infrahub integrates Git-like version control directly into the graph database, enabling unprecedented control over infrastructure data changes.

Branching and merging

Create isolated branches to:
  • Test schema changes without affecting production
  • Stage infrastructure updates for review
  • Experiment with network designs
  • Prepare changes for maintenance windows
Branches can be created via:
  • Web UI: Click “Create Branch” from any page
  • GraphQL API: BranchCreate mutation
  • CLI: infrahubctl branch create
Each branch maintains its own view of the data graph. Changes in a branch are invisible to other branches until merged.

Proposed changes

A proposed change is similar to a pull request in Git. It provides:
  • Diff view: See exactly what will change when merging
  • Comments and threads: Collaborate on changes with your team
  • Reviews and approvals: Require sign-off before merging
  • CI checks: Run automated validation and artifact generation
  • Conflict detection: Identify conflicts before merging

Immutable history

Infrahub’s storage engine is immutable: every change creates a new version, preserving the complete history. You can:
  • Query the state of your infrastructure at any point in time
  • Track who made what changes and when
  • Audit compliance and troubleshoot issues
  • Restore previous states if needed

Version Control Topic

Learn about branching, merging, and proposed changes.

Branching Topic

Understand how branches work in Infrahub.

Unified storage

Infrahub combines graph database (for data) with Git (for code) to provide unified storage for everything needed to manage infrastructure.

Graph database foundation

Infrahub uses Neo4j, a production-grade graph database, to store infrastructure data. The graph model enables:
  • Rich relationships: Model complex dependencies between infrastructure components
  • Fast traversals: Query relationships efficiently (e.g., “find all devices in site X with status Y”)
  • Natural modeling: Infrastructure is inherently a graph (devices connect to interfaces, which connect to VLANs, etc.)
  • Temporal branching: Version control is implemented directly in the graph structure

Git integration

Infrahub syncs with Git repositories to store:
  • Schema definitions: Your data model in YAML
  • Transformations: Jinja2 templates and Python code to generate configurations
  • Generators: Python code to automate object creation
  • GraphQL queries: Reusable queries for data retrieval
  • Python scripts: Custom automation and integrations
When you push changes to Git, Infrahub automatically syncs and applies them. This enables:
  • Version control for code and data: Both evolve together in branches
  • GitOps workflows: Treat infrastructure as code
  • Collaboration: Use Git workflows for code review and collaboration

Architecture Topic

Deep dive into Infrahub’s technical architecture.

Repository Guide

Connect a Git repository to Infrahub.

Key capabilities

Transformations

Transformations Transformations convert graph data into any text-based format using Jinja2 templates or Python code. Use cases include:
  • Device configurations: Generate vendor-specific configs from unified data
  • Documentation: Create network diagrams, cable plans, runbooks
  • API payloads: Transform data for external systems (CloudFormation, Terraform, etc.)
  • Reports: Generate compliance or inventory reports

How Transformations work

A Transformation consists of:
  1. GraphQL query: Defines what data to retrieve
  2. Transformation logic: Jinja2 template or Python class that processes the data
Example Jinja2 Transformation for a router config:
hostname {{ device.name.value }}
!
{% for interface in device.interfaces.edges %}
interface {{ interface.node.name.value }}
  description {{ interface.node.description.value }}
  {% if interface.node.enabled.value %}no shutdown{% else %}shutdown{% endif %}
{% endfor %}
Example Python Transformation:
from infrahub_sdk.transforms import InfrahubTransform

class CustomTransform(InfrahubTransform):
    async def transform(self, data: dict) -> dict:
        # Process data and return transformed output
        return {
            "devices": [
                {"name": d["name"]["value"], "role": d["role"]["value"]}
                for d in data["InfraDevice"]["edges"]
            ]
        }

Transformation Topic

Learn about Jinja2 and Python transformations.

Jinja2 Transform Guide

Create your first Jinja2 transformation.

Artifacts

Artifacts are the output of Transformations, stored in Infrahub’s object storage. Artifacts provide:
  • Version tracking: Each artifact has a version tied to a branch and commit
  • Storage: Stored in local filesystem or S3-compatible object storage
  • Access control: Artifacts can be retrieved via REST API or webhooks
  • Change detection: Compare artifacts across branches or over time
Artifacts are typically used to:
  • Store generated device configurations
  • Trigger deployments via webhooks
  • Archive compliance snapshots
  • Provide audit trails

Generators

Generators automate the creation of infrastructure objects based on templates and business logic. They enable design-driven automation:
  1. Define a high-level design (e.g., “Deploy a new site”)
  2. Generator creates all necessary objects (devices, interfaces, IP addresses, BGP peers)
  3. Transformations generate configurations
  4. Review and merge in a proposed change
Generators are written in Python and can:
  • Create complex object hierarchies
  • Implement business logic and policies
  • Allocate resources from pools (IP addresses, VLANs, ASNs)
  • Link generated objects back to the design for lifecycle management
Example use cases:
  • Provision a new data center site
  • Deploy a new service instance
  • Onboard a new customer
  • Roll out a new device type

Generator Topic

Understand how Generators work.

Generator Guide

Create your first Generator.

Resource pools

Resource Manager provides pools for allocating finite resources:
  • IP Prefixes and Addresses: RFC 1918 and public IP space
  • VLANs: 802.1Q VLAN IDs
  • ASNs: BGP autonomous system numbers
  • Number pools: Generic integer allocation
Pools support:
  • Namespaces: Isolate allocations by region, tenant, or environment
  • Hierarchical allocation: Allocate subnets from parent prefixes
  • Automatic allocation: Request next available resource
  • Conflict detection: Prevent overlapping allocations

Interfaces and APIs

Web UI

The web interface provides:
  • Object management: Create, read, update, delete objects
  • Schema explorer: Browse loaded schema and relationships
  • Branch management: Create branches, view diffs, merge changes
  • GraphQL sandbox: Test queries and mutations interactively
  • Global search: Find objects, documentation, and schema elements
  • Proposed change workflows: Review, comment, approve changes

GraphQL API

The GraphQL API is the primary programmatic interface. It provides:
  • Schema-driven: Automatically generated from your schema
  • Strongly typed: Type-safe queries and mutations
  • Flexible querying: Request exactly the data you need
  • Relationship traversal: Query across relationships efficiently
  • Metadata access: Query created_by, updated_by, timestamps
Example query:
query GetDevices {
  InfraDevice(role__value: "router") {
    edges {
      node {
        id
        name { value }
        site {
          node {
            name { value }
          }
        }
        interfaces {
          edges {
            node {
              name { value }
              enabled { value }
            }
          }
        }
      }
    }
  }
}

Python SDK

The Infrahub Python SDK simplifies programmatic access:
  • Object-oriented interface for creating and querying data
  • Schema introspection and validation
  • Batch operations for performance
  • Async support for concurrent operations
from infrahub_sdk import InfrahubClient

client = InfrahubClient()

# Create a device
device = await client.create(
    kind="InfraDevice",
    name="router-01",
    role="router",
    status="active"
)
await device.save()

# Query devices
devices = await client.filters(kind="InfraDevice", role__value="router")
for device in devices:
    print(device.name.value)

REST API

The REST API provides endpoints for:
  • Schema loading and retrieval
  • Artifact access and download
  • Object storage operations
  • Saved GraphQL query execution
Swagger documentation: http://localhost:8000/api/docs

Integrations

Infrahub integrates with popular automation tools:
  • Ansible: Use Infrahub as a dynamic inventory source
  • Nornir: Python-based network automation with Infrahub inventory
  • Webhooks: Trigger external systems on events (branch merge, artifact generation)
  • Git: Sync schemas and code bidirectionally

Ansible Integration

Use Infrahub with Ansible playbooks.

Nornir Integration

Integrate with Nornir automation framework.

Webhooks

Configure event-driven automation.

Putting it all together

These concepts work together to enable powerful workflows:

Design-driven automation example

  1. Define a service in the schema: Model a “VPN Service” node
  2. Create a Generator: Automate creation of routers, interfaces, BGP peers, etc.
  3. Create Transformations: Generate device configs from the service data
  4. Work in a branch:
    • Create a branch for the new service deployment
    • Run the Generator to create all objects
    • Review generated artifacts
    • Run CI checks
  5. Propose the change: Create a proposed change for review
  6. Collaborate: Team reviews diffs, comments, requests changes
  7. Merge: Approved changes merge to main
  8. Deploy: Webhook triggers Ansible playbook to deploy configs

Agility in infrastructure management example

  1. Plan a major upgrade (e.g., OS version across 100 routers)
  2. Create a branch to stage the changes
  3. Update the schema (add new OS version attribute)
  4. Update Transformations to use new OS version in configs
  5. Update data in the branch (set OS version for devices)
  6. Generate artifacts for all devices
  7. Run tests in the branch (syntax checks, lab deployments)
  8. Review in proposed change (diff shows config changes)
  9. Merge during maintenance window
  10. Deploy configs to production

Next steps

Quickstart

Get hands-on with Infrahub in minutes.

Installation

Install Infrahub for development or production.

Create a Schema

Design your infrastructure data model.

GraphQL API

Query and mutate data programmatically.

Build docs developers (and LLMs) love