# `Choreo.Lab.DSL.Infrastructure`
[🔗](https://github.com/code-shoily/choreo/blob/v0.14.1/lib/choreo/lab/dsl/infrastructure.ex#L1)

Experimental Livebook-friendly DSL for sketching infrastructure diagrams.

This module is an incubating Lab syntax layer over the stable, pipe-first
`Choreo` infrastructure builders. It returns a normal `%Choreo{}` system, so
the result can be rendered and analysed with the same functions as any other
Choreo graph.

The DSL is intentionally strict about references: bind nodes to variables and
reuse those variables in edges. Typos in labels render as written; typos in
variable names fail during macro expansion.

## Examples

    iex> import Choreo.Lab.DSL.Infrastructure
    ...> system = infrastructure do
    ...>   client = user("API Client")
    ...>   api = gateway("API Gateway")
    ...>   redis = cache("Redis", kind: :redis)
    ...>   db = database("Postgres", kind: :postgres)
    ...>
    ...>   client ~> api
    ...>   api ~> redis |> on("checks quota")
    ...>   edge api ~> db, with: "reads/writes"
    ...> end
    iex> system.graph.nodes[:api].label
    "API Gateway"
    iex> system.graph.nodes[:redis].node_type
    :cache
    iex> system.edge_meta |> Map.values() |> Enum.map(& &1.label) |> Enum.sort()
    [nil, "checks quota", "reads/writes"]

Supported cluster constructors:

  * `cluster/1`
  * `vpc/1`
  * `public_subnet/1`, `subnet_public/1`
  * `private_subnet/1`, `subnet_private/1`

Supported node constructors:

  * `user/1`, `client/1`
  * `gateway/1`, `load_balancer/1`, `lb/1`
  * `service/1`
  * `compute/1`
  * `database/1`, `db/1`
  * `managed_db/1`
  * `cache/1`
  * `queue/1`
  * `storage/1`, `object_store/1`
  * `internet/1`
  * `network/1`, `external/1`
  * `node/1`, `custom/1`

Cluster variables can be used in `parent:` and node `cluster:` options:

    prod = vpc("Production VPC")
    private = private_subnet("Private Subnet", parent: prod)
    api = service("API", cluster: private)

Edge labels can use either pipe modifiers or the explicit `edge` form:

    api ~> db |> on("reads")
    api ~> db |> label("reads")
    edge api ~> db, "reads"
    edge api ~> db, label: "reads"
    edge api ~> db, with: "reads"

# `cluster_decl`

```elixir
@type cluster_decl() :: %{id: String.t(), builder: atom(), opts: keyword()}
```

# `edge_decl`

```elixir
@type edge_decl() :: %{from: Yog.node_id(), to: Yog.node_id(), opts: keyword()}
```

# `node_decl`

```elixir
@type node_decl() :: %{id: Yog.node_id(), builder: atom(), opts: keyword()}
```

# `cache`

# `client`

# `cluster`

# `compute`

# `cost`

# `custom`

# `database`

# `db`

# `edge`

# `external`

# `gateway`

# `infrastructure`
*macro* 

Builds a `%Choreo{}` infrastructure sketch from a compact Lab DSL block.

# `infrastructure`
*macro* 

# `internet`

# `label`

# `lb`

# `load_balancer`

# `managed_db`

# `network`

# `node`

# `object_store`

# `on`

# `private_subnet`

# `protocol`

# `public_subnet`

# `queue`

# `service`

# `storage`

# `subnet_private`

# `subnet_public`

# `taxonomy`

```elixir
@spec taxonomy() :: %{
  clusters: [atom()],
  nodes: [atom()],
  edges: [atom()],
  modifiers: [atom()],
  options: [atom()]
}
```

Returns the vocabulary supported by the infrastructure DSL.

This is meant as a lightweight Livebook discovery helper when autocomplete is
not enough.

    iex> taxonomy = Choreo.Lab.DSL.Infrastructure.taxonomy()
    iex> :vpc in taxonomy.clusters
    true
    iex> :service in taxonomy.nodes
    true
    iex> :~> in taxonomy.edges
    true
    iex> :on in taxonomy.modifiers
    true

# `type`

# `user`

# `verbs`

```elixir
@spec verbs() :: %{
  clusters: [atom()],
  nodes: [atom()],
  edges: [atom()],
  modifiers: [atom()],
  options: [atom()]
}
```

Compatibility alias for `taxonomy/0`.

# `vpc`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
