Choreo.Infrastructure (Choreo v0.9.0)

Copy Markdown View Source

Cloud network and infrastructure topology preset built on top of Choreo's rendering primitives.

Choreo.Infrastructure is a domain-specific vocabulary layer that adds cloud-network concepts — VPCs, subnets, compute, load balancers, managed databases, storage — on top of the same graph, cluster, and rendering stack used by Choreo. It is not a parallel implementation: it shares Choreo.Theme, Choreo.Internal, and the Yog rendering pipeline directly.

The key additions over plain Choreo are:

  • Typed cluster boundaries:vpc, :subnet_public, :subnet_private carry security semantics (e.g. databases should not be in public subnets) that generic clusters do not.
  • Choreo.Infrastructure.Analysis — structural audit rules that inspect topology against those security semantics (direct internet-to-private-subnet links, misplaced databases, etc.).
  • Network vocabularyadd_vpc/3, add_compute/3, add_managed_db/3 etc. as intent-revealing builders instead of the generic add_cluster/3 / add_service/3.

Node colors and shapes are resolved through Choreo.Theme (:internet, :compute, and :managed_db are first-class theme types), so the full theme system — including :dark, :warm, :forest, :ocean — applies to infrastructure diagrams without any extra configuration.

Element types

  • :internet — public gateway or client zone
  • :load_balancer — traffic proxy (e.g. ALB, ingress)
  • :compute — application runner (EC2, ECS task, Kubernetes pod)
  • :managed_db — stateful database (RDS, Aurora)
  • :storage — blob/file storage (S3, EFS)

Network boundaries (Clusters)

  • :vpc — Virtual Private Cloud container
  • :subnet_public — Public subnet zone (internet-facing)
  • :subnet_private — Private subnet zone (isolated)

Quick Start

infra =
  Choreo.Infrastructure.new()
  |> Choreo.Infrastructure.add_internet(:gateway, label: "Internet Gateway")
  |> Choreo.Infrastructure.add_vpc("vpc_main", label: "Production VPC")
  |> Choreo.Infrastructure.add_subnet_public("subnet_dmz", label: "Public Subnet", parent: "vpc_main")
  |> Choreo.Infrastructure.add_subnet_private("subnet_app", label: "Private Subnet", parent: "vpc_main")
  |> Choreo.Infrastructure.add_load_balancer(:alb, label: "ALB", cluster: "subnet_dmz")
  |> Choreo.Infrastructure.add_compute(:api, label: "API Service", cluster: "subnet_app")
  |> Choreo.Infrastructure.add_managed_db(:db, label: "Postgres RDS", cluster: "subnet_app")
  |> Choreo.Infrastructure.connect(:gateway, :alb)
  |> Choreo.Infrastructure.connect(:alb, :api)
  |> Choreo.Infrastructure.connect(:api, :db)

# Check for architecture warning violations
warnings = Choreo.Infrastructure.Analysis.warnings(infra)

dot = Choreo.Infrastructure.to_dot(infra)
mermaid = Choreo.Infrastructure.to_mermaid(infra)

Summary

Functions

Adds a compute workload runner node (EC2, ECS task, Kubernetes pod).

Adds an internet gateway or public internet entrypoint node.

Adds a load balancer proxy node (ALB, Ingress Controller).

Adds a managed database node (RDS, Aurora, DynamoDB).

Adds a storage bucket or block storage node (S3, EFS).

Adds a private subnet cluster boundary.

Adds a public subnet cluster boundary.

Adds a VPC cluster network boundary.

Connects two infrastructure nodes together.

Returns all edges.

Creates a new empty cloud infrastructure diagram.

Returns all node IDs.

Renders the infrastructure topology to DOT format.

Renders the infrastructure topology to Mermaid.js syntax.

Types

t()

@type t() :: %Choreo.Infrastructure{
  clusters: %{required(String.t()) => map()},
  edge_meta: %{optional(Yog.Multi.Graph.edge_id()) => map()},
  graph: Yog.Multi.Graph.t()
}

Functions

add_compute(infra, id, opts \\ [])

@spec add_compute(t(), Yog.node_id(), keyword()) :: t()

Adds a compute workload runner node (EC2, ECS task, Kubernetes pod).

add_internet(infra, id, opts \\ [])

@spec add_internet(t(), Yog.node_id(), keyword()) :: t()

Adds an internet gateway or public internet entrypoint node.

add_load_balancer(infra, id, opts \\ [])

@spec add_load_balancer(t(), Yog.node_id(), keyword()) :: t()

Adds a load balancer proxy node (ALB, Ingress Controller).

add_managed_db(infra, id, opts \\ [])

@spec add_managed_db(t(), Yog.node_id(), keyword()) :: t()

Adds a managed database node (RDS, Aurora, DynamoDB).

add_storage(infra, id, opts \\ [])

@spec add_storage(t(), Yog.node_id(), keyword()) :: t()

Adds a storage bucket or block storage node (S3, EFS).

add_subnet_private(infra, name, opts \\ [])

@spec add_subnet_private(t(), String.t(), keyword()) :: t()

Adds a private subnet cluster boundary.

add_subnet_public(infra, name, opts \\ [])

@spec add_subnet_public(t(), String.t(), keyword()) :: t()

Adds a public subnet cluster boundary.

add_vpc(infra, name, opts \\ [])

@spec add_vpc(t(), String.t(), keyword()) :: t()

Adds a VPC cluster network boundary.

connect(infra, from, to, opts \\ [])

@spec connect(t(), Yog.node_id(), Yog.node_id(), keyword()) :: t()

Connects two infrastructure nodes together.

edges(infrastructure)

@spec edges(t()) :: [{Yog.node_id(), Yog.node_id(), any()}]

Returns all edges.

new()

@spec new() :: t()

Creates a new empty cloud infrastructure diagram.

nodes(infrastructure)

@spec nodes(t()) :: [Yog.node_id()]

Returns all node IDs.

to_choreo(infra)

to_dot(infra, opts \\ [])

@spec to_dot(
  t(),
  keyword()
) :: String.t()

Renders the infrastructure topology to DOT format.

Options

  • :theme:default, :dark, :warm, :forest, :ocean, or a Choreo.Theme struct
  • :highlighted_nodes — list of node IDs to highlight
  • :highlighted_edges — list of edge IDs or {from, to} tuples to highlight

to_mermaid(infra, opts \\ [])

@spec to_mermaid(
  t(),
  keyword()
) :: String.t()

Renders the infrastructure topology to Mermaid.js syntax.

Options

  • :theme:default, :dark, :warm, :forest, :ocean, or a Choreo.Theme struct
  • :direction:td (default), :lr, :rl, :bt
  • :highlighted_nodes — list of node IDs to highlight
  • :highlighted_edges — list of edge IDs or {from, to} tuples to highlight