# The navigation map

> Where every case lives in your app, as a tree of places, and everything that is worked out from it.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://cases.docs.sypnia.com/map/navigation/

For agents: cases/navigation.yaml: roots[] {id, title, actors[], route} (several roots: public site, console, member app; an actor may have several), places[] {id (dotted kebab segments, e.g. shop.order-for-tomorrow, stable), title, kind screen|tab|modal|menu|panel, parent (exactly one), opened_by {label, kind button|link|item|tab} = the actionable on the parent that opens it, route?, permission?}, shortcuts[] {from, to, label} (other ways in; never a second parent). Path = titles from root to place, «Shop › Order for tomorrow», computed, never written. A case with starts: in_app may have where: <place id>. Place ids: kebab-case segments joined by dots, independent of the route and of the tree path (moving a place keeps its id). In the markup: data-sypnia-place on the element that shows a place (set by Sypnia Design's generated pieces and @sypnia/ui from the case's where), data-sypnia-opens=<place> on an actionable; `cases nav --from-code` proposes the tree. Telemetry: every page_view and click carries place (innermost data-sypnia-place); spans carry sypnia.case and sypnia.case.outcome; the navigation check compares moves with the tree (nav-missing-edge, nav-unreached 30 days, nav-unknown-route). Feeds: «how to get there» in docs, the agent («where do I edit X?»), role editors, video breadcrumbs, Design screens.

Inside the app, every case has a **place**: the screen, tab, modal or menu where it happens. The navigation map puts those places in a **tree**, so the way to reach any of them is always known: «Shop › Order for tomorrow».

`cases/navigation.yaml`

```yaml
roots:
  - id: site
    title: La Espiga
    actors: [visitor, customer]
    route: /
  - id: shop
    title: Shop
    actors: [customer]
    route: /shop
  - id: console
    title: Console
    actors: [staff, owner]
    route: /console

places:
  - id: shop.order-for-tomorrow
    title: Order for tomorrow
    kind: screen
    parent: shop
    opened_by: { label: Order for tomorrow, kind: button }
    route: /shop/tomorrow
  - id: shop.order-for-today
    title: Order for today
    kind: screen
    parent: shop
    opened_by: { label: Order for today, kind: button }
    route: /shop/today
  - id: shop.my-orders
    title: My orders
    kind: tab
    parent: shop
    opened_by: { label: My orders, kind: tab }
  - id: shop.my-orders.order-detail
    title: Order
    kind: screen
    parent: shop.my-orders
    opened_by: { label: an order in the list, kind: item }
  - id: console.cash-flow
    title: Cash flow
    kind: screen
    parent: console
    opened_by: { label: Cash flow, kind: item }
  - id: console.cash-flow.new-transaction
    title: New transaction
    kind: modal
    parent: console.cash-flow
    opened_by: { label: New transaction, kind: button }
    permission: payments.create

shortcuts:
  - from: site
    to: shop.order-for-tomorrow
    label: Order now
```

## The parts

| Part           | What it is                                                                                                                                                |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Root**       | Where an actor comes in: the public site, the console, the member app. A map has as many roots as the app has front doors, and an actor may have several. |
| **Place**      | A screen, tab, modal, menu or panel. It has an `id`, a `title`, a `kind`, an optional `route` and an optional `permission`.                               |
| **Parent**     | Every place has **exactly one** parent: a root or another place. That is what makes the path unique.                                                      |
| **Actionable** | The button, link, menu item or tab on the parent that opens the place (`opened_by`). It is what a person clicks.                                          |
| **Shortcut**   | Any other way to reach a place: a link on the home page, a notification, a search result. Shortcuts are ways in, never a second parent.                   |

### Ids and paths

A place id is lowercase words in `kebab-case`, joined by dots: `shop.order-for-tomorrow`. By habit the first part is the root or section it lives under. The id is a name from your code, **independent of the route and of the path in the tree**: the route can change, and moving a place to another parent keeps its id, and every case that points to it.

The **path** is never written by hand. It is the titles from the root to the place, joined with `›`: `console.cash-flow.new-transaction` reads «Console › Cash flow › New transaction». Rename a title and every path that goes through it follows.

### Cases and places

A case that happens inside the app says where with `where`:

`cases/payments/record-transaction.case.yaml`

```yaml
id: record-transaction
starts: in_app
where: console.cash-flow.new-transaction
```

`where` is optional, and only cases that start `in_app` have one. A case that starts when another app calls, on a schedule or on an event has no place; where it changes what people see, that change shows on the places of the cases that show it. Several cases can share a place: «See my orders» and «Cancel an order» both live on `shop.my-orders.order-detail`.

## Generated from the code, checked by real clicks

You can write the tree by hand, but it usually comes from the code. Each place and each actionable carries an id in the markup:

```html
<main data-sypnia-place="shop">
  <a href="/shop/tomorrow" data-sypnia-opens="shop.order-for-tomorrow">Order for tomorrow</a>
</main>

<main data-sypnia-place="shop.order-for-tomorrow">…</main>
```

`data-sypnia-place` goes on the element that shows a place; `data-sypnia-opens` on the actionable that opens one. The pieces [Sypnia Design](https://design.docs.sypnia.com/) generates, and the components of `@sypnia/ui`, set them for you from the case's `where`; in any other markup, write the attributes yourself. Then:

```bash
npx @sypnia/cases nav --from-code     # reads every data-sypnia-place and data-sypnia-opens, proposes the tree
```

The result is a proposal, like any change to the map. Then [Sypnia Telemetry](https://telemetry.docs.sypnia.com/concepts/use-cases-and-places/) confirms the tree with what people really do. Its browser SDK reads the same attribute: every `page_view` and `click` carries `place`, the id of the innermost `data-sypnia-place` around it (an id from your code, never the page's content). On the server side, every run of a case is a span with `sypnia.case` (the case id) and `sypnia.case.outcome` (how it ended). With the project linked, Cases compares people's moves, a click in one place and the next place they see, with the tree:

| Finding             | What it means                                                                         | What to do                                     |
| ------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------- |
| `nav-missing-edge`  | people move between two places with no actionable or shortcut between them in the map | add it as a shortcut, or remove the link       |
| `nav-unreached`     | a place nobody reached in 30 days                                                     | check the way to it, or remove it from the map |
| `nav-unknown-route` | a route people visit that has no place                                                | give it a place, or find out why it exists     |

Each finding is shown on the map, with a proposal ready to accept or dismiss ([Telemetry](https://cases.docs.sypnia.com/links/telemetry)).

## What the tree feeds

The tree is written once and used everywhere a person or an agent needs to know where something is:

- **«How to get there» in your docs and help pages.** Each case shows its path, «Shop › Order for tomorrow», always current.
- **The coding agent.** «Where do I edit the price of a product?» has one answer: the place, its path, its route and the files behind it ([Agent](https://cases.docs.sypnia.com/links/agent)).
- **Role editors.** When you edit a role, the tree shows which places it can reach and which it cannot, by `permission`, so a role never ends up with a button that leads nowhere.
- **Video breadcrumbs.** A tutorial or support video shows the path of each step as it records it ([Sypnia Learn](https://learn.docs.sypnia.com/)).
- **Screens.** [Sypnia Design](https://design.docs.sypnia.com/screens/screens-per-case/) designs one screen for every case with a `where`, and shows its path.

## Rules the check applies

- Every `parent` exists, and following parents always reaches a root (no cycles).
- Ids are unique across roots and places.
- A case's `where` exists, and its `actor` is one of the actors of the place's root.
- A case with `where` starts `in_app`.
- A shortcut points to an existing place and never replaces its parent.
