# `PhiaUiDesign.Canvas.Persistence`
[🔗](https://github.com/charlenopires/PhiaUI/blob/v0.1.17/lib/phiaui_design/canvas/persistence.ex#L1)

Save and load design scenes to/from `.phia.json` files.

Scenes are serialized as JSON containing a flat list of nodes with their
parent-child relationships. On load, the nodes are inserted back into a
fresh ETS scene table.

## File format

    {
      "version": 1,
      "name": "My Dashboard",
      "theme": "zinc",
      "nodes": [
        {
          "id": "abc123",
          "type": "phia_component",
          "component": "button",
          "attrs": {"variant": ":default"},
          "slots": {"inner_block": "Click me"},
          "parent_id": null,
          "children": ["def456"],
          "name": "My Button"
        }
      ],
      "root_children": ["abc123"]
    }

# `list_projects`

```elixir
@spec list_projects(Path.t()) :: [map()]
```

List all `.phia.json` files in a directory.

# `load`

```elixir
@spec load(Path.t()) :: {:ok, reference(), map()} | {:error, term()}
```

Load a scene from a `.phia.json` file.

Returns `{:ok, scene, metadata}` where metadata includes `:theme` and `:name`.

# `save`

```elixir
@spec save(reference(), Path.t(), keyword()) :: :ok | {:error, term()}
```

Save a scene to a `.phia.json` file.

Options:
- `:theme` — current theme atom (default: `:zinc`)

---

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