# Configure structure trees

AI agent getting started? Read [Agents: start here](https://docs.openeng.io/agents/start-here.md) first.

Show direct relationships and product usages as a tree.

Source: https://docs.openeng.io/configure/structures/

A structure tree gives people a route through connected records. A product tree can show a component under its assembly while displaying quantity from the BOM line that connects them.

## Named structure views and decoration

A named structure view turns a path through model relationships into a tree. In the demo's product structure,
an assembly part has a relationship named `itemises` to a BOM line, and that line has a relationship named `uses` to a component part. The tree shows the
component directly beneath the assembly, hiding the middle BOM-line object from the tree rows.
The line still exists and holds properties specific to that use of the component.

For example, the demo's Part type includes this structure declaration:

```json
{
  "relationships": ["has-part"],
  "views": [
    {
      "key": "product",
      "label": "Product structure",
      "steps": ["itemises", "uses"],
      "decoration": [
        { "key": "findNumber", "label": "Find" },
        { "key": "quantity", "label": "Qty" }
      ]
    },
    {
      "key": "has-part",
      "label": "System structure",
      "steps": ["has-part"]
    }
  ]
}
```

`structureDeclaration.relationships` lists, in priority order, the relationship types used to choose parents in the type's default navigation tree. Declaring named views does not erase this
list: it still defines that default, and a one-step view can follow declared relationships on
other types it reaches. When views are declared, the web tree's picker offers their labels;
without views, it offers the declared relationships.

A view's `steps` names the edge types to follow, in order from parent to child, using each edge
type’s `parentEnd` (the endpoint designated as the parent). A one-step view follows a direct relationship. The two-step Product structure
view above follows `part → bom-line → part` and displays the two parts as parent and child.

For a two-step view, each `decoration.key` (a displayed property from the hidden middle record) names a **property of the hidden middle object**:
`findNumber` and `quantity` belong to the BOM line, not the visible component part or either edge. The labels say how those values appear beside the component.

The demo's line from assembly
`FMS-000` to component `FMS-100` holds `findNumber: 10` and `quantity: 2`, so that occurrence shows
**Find 10 · Qty 2**. Another use of the same component can carry different values on its own BOM
line. Missing decoration properties are omitted. Siblings sort by the first decoration key,
numerically when its values are numbers.
