Architecture

How Stategraph works

Stategraph stores infrastructure state as a dependency graph in PostgreSQL instead of a JSON state file, which is how Terraform stores state.

Infrastructure as a Database Dependency Graph PostgreSQL Backend Drop-in Terraform Replacement

Schedule a call to discover how Stategraph can unlock your team

Request Access
DB
rows: 2,847
tables: 14
indexes: 31
Infrastructure as a Database
State stored as structured data, not flat files.
DAG
nodes: 2,847
edges: 4,201
depth: 8
Dependency Graph
Resources and their relationships modelled as a graph.
SQL
SELECT *
FROM resources
WHERE provider = 'aws'
PostgreSQL Backend
Real SQL queries against normalized infrastructure state.
TF
init
plan
apply
Drop-in Replacement
Same commands and workflow. No code changes required.

Terraform flattens your infrastructure graph into a JSON file. Stategraph keeps it as a graph.

Traditional Backend

terraform.tfstate
{
"resources": [
{ "type": "aws_vpc", "name": "main",
"instances": [{ "attributes": {
"id": "vpc-a1b2c3",
"cidr_block": "10.0.0.0/16"
}}] },
{ "type": "aws_subnet", "name": "web",
"instances": [{ "attributes": {
"id": "subnet-d4e5f6",
"vpc_id": "vpc-a1b2c3" ← buried ref
}}] },
{ "type": "aws_instance", "name": "app",
"instances": [{ "attributes": {
"id": "i-7g8h9i",
"subnet_id": "subnet-d4e5f6" ← buried ref
}}] }
]
}
...2,844 more resources
LOCKED Entire file locked by Team A
  • All resources in one JSON blob
  • Global lock blocks all teams
  • Refresh reads every resource
  • Dependencies buried in attribute strings

Stategraph

stategraph-query
stategraph> SELECT r.type, r.name, array_agg(d.depends_on)
FROM resources r
JOIN edges d ON r.id = d.resource_id
GROUP BY r.type, r.name;
type name depends_on aws_instance app {aws_subnet.web} aws_subnet web {aws_vpc.main} aws_vpc main {}
✓ 3 resources, 2 dependency edges
aws_vpc.main
aws_subnet.web LOCK
aws_instance.app
blast radius
aws_subnet.api
aws_rds.db
unaffected
✓ 1 affected · 2,845 unaffected
12 LOCKED 2,835 FREE
  • State stored as structured data
  • Resource-level locking
  • Query only affected subgraph
  • Dependencies are queryable edges

What this means

Because infrastructure state is structured in a dependency graph, rather than as files within files, it is:

Queryable
SELECT type, count(*) AS total
FROM resources
WHERE provider = 'aws'
GROUP BY type LIMIT 4;
type
total
aws_instance
47
aws_s3_bucket
23
aws_lambda_function
18
aws_iam_role
12
Analyzable
$ stategraph blast-radius aws_security_group.api
Root: aws_security_group.api
├── aws_instance.api-1
├── aws_instance.api-2
├── aws_lb.api
├── aws_lb_target_group.api
├── aws_route53_record.api
└── aws_cloudfront.cdn
⚠ 7 resources in blast radius
Composable
$ stategraph plan --states networking,compute,data
Resolving cross-state graph...
networking → aws_vpc.main
↳ compute → aws_subnet.a, aws_subnet.b
↳ data → aws_rds.primary
✓ 3 states, 1 unified graph
Auditable
$ stategraph tx list --tenant $TENANT_ID
ID STATE CREATED BY TAGS
a3f7b21.. committed josh@company.com pipeline=github-actions branch=main
9e1c405.. committed ci-bot commit=abc123 env=production
d82fa19.. aborted sarah@company.com desc=staging rollback
3 transactions

See the difference

Watch how Stategraph parallelizes your infrastructure operations

Traditional Backend

terraform apply 00:00
[VPC ] waiting
[Subnets ] waiting
[Security ] waiting
[RDS ] waiting
[ALB ] waiting
[ASG ] waiting
[Route53 ] waiting
[CloudFront ] waiting

Stategraph

stategraph apply 00:00
[VPC ] waiting
[Subnets ] waiting
[Security ] waiting
[RDS ] waiting
[ALB ] waiting
[ASG ] waiting
[Route53 ] waiting
[CloudFront ] waiting
Parallel Team execution
Graph Dependency aware
SQL Queryable state

What Stategraph unlocks

Stategraph stores infrastructure as structured data, changing how infrastructure systems operate and enabling:

$ stategraph plan
Change cone: 12 of 2,847
✓ Plan ready in 2.3s

Faster infrastructure operations

Operations run only against the relevant nodes in the graph, not the entire state file.

Team A Team B Team C
All deploying simultaneously →
0 lock conflicts · 3.1s total wall time

Concurrent deployments

Multiple teams deploy simultaneously without waiting on global locks.

SELECT type, count(*)
FROM resources
WHERE provider = 'aws';

Infrastructure queries and analysis

Query your infrastructure like a database. Trace dependencies and run compliance checks with real SQL.

dev staging prod
One unified data model →

Cross-environment visibility

See all environments in one structured data model. No more switching between fragmented state files.

STATE CHANGE POLICY CHECK AUTOMATE

New automation and AI workflows

Structured state unlocks automation and AI workflows that flat files simply cannot support.

The key benefits of Stategraph

Stategraph operates only on the relevant portion of the infrastructure graph. Traditional tools must scan and lock entire state files. Stategraph does not.

Faster plans and applies

Plans and applies run only against the relevant nodes in the graph, not the full state. What used to take minutes now completes in seconds — even at 2,847 resources.

stategraph-plan
$ stategraph plan
Subgraph: 12 of 2,847 resources
Plan ready in 2.3s
Skipped 2,835 unchanged resources

Multiple teams deploy simultaneously

No global lock means no queue. Three teams run three transactions on disjoint resource sets with zero contention — total wall time is the slowest single operation, not the sum.

deploy-status
✓ Team A: networking (3.1s)
✓ Team B: api-gateway (2.8s)
✓ Team C: cdn (1.9s)
3 teams, 0 lock conflicts, 3.1s total

Workflows that scale with your team

The graph scales with your infrastructure. Operations stay fast as your system and team grow — 20,000 resources imported in 3 seconds, queries in under 5.

20K
Resources
3s
Import
<5s
Query

Run multi-state transactions

A single transaction can span multiple Terraform states. Stategraph resolves cross-state dependencies automatically — one plan, one apply, full blast radius visibility.

multi-state-plan
$ stategraph plan
Planning across 3 states...
✓ 25 resources across 3 states
One atomic transaction

Drop-in replacement, zero code changes

Import your state. Replace terraform with stategraph. Done.

quickstart
# import your existing state
$ stategraph import --name prod terraform.tfstate
State imported — 847 resources
# plan and apply, same as before
$ stategraph plan --out plan.json
3 to add, 1 to change, 0 to destroy
$ stategraph apply plan.json
Apply complete! 3 added, 1 changed

Request access to Stategraph today

Stategraph supercharges parallel plan/apply for Terraform. Schedule an activation call to get started.

Request Access