Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

structurizrx locate

Find the DSL statements that declare elements, ports, relationships, views and decisions — by name, or straight from a link copied out of the web viewer.

structurizrx locate <file> <reference-or-link>... [--json]
FlagEffect
--jsonEmit {items: [...], unresolved: [...]} instead of a text listing

References

References name things the way the viewer shows them — by path, not by id. Ids are assigned in parse order and change whenever something is declared earlier in the file; a path does not, so a reference keeps pointing at the same element while the workspace is being edited. Paths match case-insensitively.

ReferenceNames
Shop/APIAn element: ancestor names, then its own, joined with /
Production/Server/APIA deployment element, rooted at its environment (here an instance of API)
Shop/API.httpA port
Shop/API->Shop/DBEvery relationship between the two ends
Shop/API->Shop/DB "reads orders"Only the one with that description
view:containersA view, by key
decision:3An imported architecture decision, by id

When no relationship joins two ends directly but relationships between their children do — what a view draws as an implied relationship — the reference resolves to those relationships.

A link from structurizrx serve can be passed as-is. Its view (the workspace page’s #<key>, or the diagram page’s /diagram/<key>) and every reference in its sel= selection are located. If the link’s workspace slug isn’t the one serve would give <file>, locate warns — the link is probably for a different workspace.

structurizrx locate shop.dsl 'http://localhost:3000/workspace/shop#containers&sel=Shop%2FAPI,Shop%2FAPI-%3EShop%2FDatabase'
view  containers
  shop.dsl:12:9 (to line 14)
    container shop "containers" {
container  Shop/API
  shop.dsl:4:13 (to line 6)
    api = container "API" {
relationship  Shop/API -> Shop/Database "reads orders"
  shop.dsl:8:13
    api -> db "reads orders"

Each location is file:line:col of the statement’s first token (an ident = prefix included), with the line its block closes on. Files pulled in with !include are reported as themselves, with their own line numbers.

Some things have no statement of their own, and say so:

  • a relationship replicated onto deployment instances points at the relationship it copies;
  • a view generated by auto is reported as generated;
  • a .json workspace has no source locations at all.

From a running server

structurizrx serve answers the same question at GET /api/workspace/{name}/locate?sel=<references>, with references in the page-hash format (each URI-encoded, joined with ,) and the --json output shape. Each location there also carries absolutePath, which is what the viewer’s “Open in editor” links use.

Unresolved references

A reference that matches nothing is reported on stderr with a suggestion — the closest path, or one with the same name under a different parent (the element was moved) — and locate exits non-zero. Everything that did resolve is still printed.

error: Shop/APX: no element or port with path 'Shop/APX' (did you mean 'Shop/API'?)