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]
| Flag | Effect |
|---|---|
--json | Emit {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.
| Reference | Names |
|---|---|
Shop/API | An element: ancestor names, then its own, joined with / |
Production/Server/API | A deployment element, rooted at its environment (here an instance of API) |
Shop/API.http | A port |
Shop/API->Shop/DB | Every relationship between the two ends |
Shop/API->Shop/DB "reads orders" | Only the one with that description |
view:containers | A view, by key |
decision:3 | An 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.
Viewer links
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
autois reported as generated; - a
.jsonworkspace 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'?)