How Stategraph
really works
Terraform state as a directed acyclic graph (DAG) stored in PostgreSQL, enabling row-level locking, MVCC, and SQL queryability through a REST API.
System Overview
Stategraph fundamentally reimagines how Terraform state is managed by representing it as a directed acyclic graph in a PostgreSQL database with intelligent resource management.
Stategraph transforms how Terraform manages infrastructure state by representing it as a graph database structure. This enables parallel operations, granular locking, and intelligent dependency management - all while maintaining full compatibility with your existing Terraform code.
The Stategraph CLI
The Stategraph CLI seamlessly integrates with your existing Terraform workflow.
CLI Commands Mirror Terraform
Drop-in replacement for the Terraform CLI with enhanced state management capabilities.
Core Components
CLI / Web UI
REST API
Plan Analyzer
PostgreSQL
API Layer
Modern API for infrastructure operations and management.
- Resource management
- State operations
- Query interface
- Real-time updates
Plan Analyzer
Advanced analysis of infrastructure changes and dependencies.
- Change detection
- Dependency mapping
- Impact analysis
- Optimization logic
Graph Engine
Sophisticated graph operations for state management.
- Dependency resolution
- Parallel execution planning
- Conflict detection
- Resource isolation
Data Layer
Enterprise-grade database storage for infrastructure state.
- ACID compliance
- High availability
- Instant queries
- Audit trail
State Optimizer
Intelligent state reconstruction for efficient operations.
- Minimal state building
- Query result caching
- Performance optimization
- Resource efficiency
Concurrency Control
Advanced parallel execution for independent operations.
- Granular locking
- Parallel execution
- Conflict resolution
- Transaction management
How It Works
Stategraph transforms traditional state management into a modern, scalable architecture.
State History
Locks & Transactions
Concurrency Model
Stategraph enables multiple teams to work on independent infrastructure changes simultaneously.
Parallel Execution
- Analyze: Identify resource dependencies
- Isolate: Determine independent changes
- Lock: Secure only required resources
- Execute: Run changes in parallel
- Commit: Apply updates atomically
- Release: Free resources for others
Parallel Operations Example
All three transactions execute in parallel because they operate on non-overlapping subgraphs
Performance Characteristics
Capability | Traditional Backend | Stategraph |
---|---|---|
Concurrent Operations | Sequential only | Full parallelization |
State Queries | Download entire state | Instant targeted queries |
Lock Granularity | Entire state file | Individual resources |
Performance at Scale | Degrades with size | Consistently fast |
Audit Trail | External solutions | Built-in history |
Recovery | Manual restoration | Point-in-time recovery |
Technology Stack
Application
Data
Operations
Application Layer
Type-safe OCaml core with REST API for CLI and web dashboard integration
Data Layer
PostgreSQL with MVCC for concurrent operations and graph traversal via CTEs
Operations Layer
Full observability with distributed tracing, metrics, and containerized deployment
Learn More
Stop coordinating. Start shipping.
Resource-level locking. Graph-based state. SQL queries on your infra.
Teams work in parallel. No more lock contention.
// Zero spam. Just progress updates as we build Stategraph.