c4studio Migration Guide#
This guide describes the changes introduced by the 4-phase Structurizr Java compatibility work (PP-31 → PP-35) and how to adapt existing code.
0.5.0 — icons, logos, colours, and renders that match the Studio (PP-217 … PP-264)#
Nothing needs action. The icon browser, Tabler pack, workspace logo and colour editing are additive; see the Studio guide. Rendered output changes, as described below: c4 render, c4 publish and the VS Code preview now draw what the Studio draws.
Renders match the Studio (PP-257 … PP-264)#
Nothing needs action, but rendered SVGs change, each time towards the canvas:
- Boxes shrink to their text (PP-257), where they used to keep a fixed minimum height. Positions are unchanged: the layout reserves the same slot for each box as before.
- Shapes are drawn as the Studio's CSS draws them (PP-258): cylinder, bucket, pipe, folder, browser, window, mobile devices and hexagon.
Diamondis a rounded box, as in the Studio (PP-259). - A boundary's label names its technology (PP-260).
- An
opacityrelationship style fades the line, not its label (PP-262); labels are painted above boxes (PP-263). - The legend is the Studio's size and sits where the Studio puts it (PP-264): columns as wide as their labels, 48px below the layout, rather than fixed 220px columns in a band under the diagram.
- The document's width and height are whole pixels.
Icons (PP-232 … PP-252)#
icon in an element style can name an image file; it is read and embedded when the DSL is parsed, so it shows in every renderer. A style for Workspace:Icon sets the workspace's logo, drawn before each diagram's title. branding { logo } is still parsed but not drawn.
Resizable element boxes (PP-224)#
Nothing needs action. Elements can now be resized in the Studio, as boundaries could. A resized box's size is saved in the layout sidecar's views entry as [x, y, width, height], the form boundaries already used, so older sidecars load unchanged and older versions of c4studio read the position and ignore the size.
Text wraps where the canvas wraps it (PP-223)#
Nothing needs action. c4 render, c4 publish and the VS Code preview used to break a box's text sooner than the Studio, so rendered descriptions often took an extra line. They now break where the canvas does. Box heights are measured the same way, so a box whose text needed fewer lines than was estimated is a little shorter, in the Studio and in renders, and an automatic layout can shift slightly.
c4 render draws the Studio's line style (PP-222)#
Nothing needs action, but rendered SVGs change:
- The default line is now a Bezier curve, as in the Studio. Before,
c4 render,c4 publishand the VS Code preview drew straight lines. Choose Straight in the Studio's toolbar to get them back for a view. - The toolbar's line style is saved per view in the layout sidecar's new
lineStylesection, and all three honour it. A view nobody chose a style for is drawn in each browser's own default, as before. Reset layout keeps the style; named layouts capture it. - Long relationship labels wrap at the Studio's width instead of being cut to one line ending in "…".
- Two relationships between the same pair are bowed apart, as in the Studio, rather than drawn on one line.
Layouts from workspace JSON (PP-220)#
Nothing needs action. A workspace .json that Structurizr laid out is now drawn with that layout: element positions, line bend points, and Structurizr's box sizes. Before, every JSON view was laid out from scratch. The Studio, c4 render and c4 publish all change for such files. A layout sidecar beside the JSON still takes precedence, and --no-layout ignores only the sidecar, not the layout inside the JSON.
Those boxes are drawn with Structurizr's text as well (PP-228): 24px descriptions, names at 1.4 times that and metadata at 0.7, or an element style's fontSize, centred in the box. DSL views are unchanged.
0.4.0 — lint, diff, impact and a published site (PP-182 … PP-215)#
Nothing needs action. The new commands (c4 lint, c4 diff, c4 impact, c4 publish) are additive. Four changes are visible:
- The Source page is gone. Its editor is now a panel on the right of the Diagrams page, opened by the top bar's Source button or
e(PP-214, PP-215). The panel's open state and split ratio start fresh, because the panes swapped sides. - Dynamic-view edge ids changed from
step-<order>-<src>__<dst>tostep-<src>__<dst>__<n>(PP-198). An existing layout sidecar still applies throughpreviousIdsand is rewritten on the next save. Only a client that keys on edge ids from the HTTP API sees the difference. - Some DSL now parses to more than it did. Three things used to drop content and now keep it:
"""text blocks (they read as""before),\line continuation (PP-202), and steps after aparallelblock in a dynamic view (PP-186).!docs/!adrsnow attach to the element they are written inside (PP-185). The rendered output changes for these models, but only because the old output was wrong. workspace extendswith a local file now works (PP-210). It used to fail the whole parse.
0.3.0 — c4studio becomes an editor (PP-119 … PP-142)#
0.2.0 was a viewer. 0.3.0 can author: an in-browser DSL editor, a file tree with create/rename/delete, starter templates, and an optional assistant. Three changes need action; the rest is additive.
c4 webapp now serves a writable app by default#
This is the one that can surprise you. Before 0.3.0 the web app could not write DSL at all, so pointing it at a directory was inherently safe. It now serves Studio — a full editor that saves to disk — unless you ask otherwise:
c4 webapp samples/ # Studio: editable (NEW default)
c4 webapp samples/ --viewer # Viewer: what 0.2.0 always didIf you use c4 webapp for a kiosk, a demo, an embed or anything public-facing, add --viewer. The guarantee is enforced on the server — routes that write DSL answer 403 — so it holds against a crafted request, not just a hidden button. Layout dragging, group collapse and title moves still persist in Viewer: you cannot change the model, but you can arrange the view, and that arrangement is gitignored per-user state either way.
GET /api/capabilities reports which mode is running, so a client can feature-detect rather than guess.
GET /api/files returns objects, not strings#
Only relevant if you call the HTTP API directly; the bundled SPA ships in the same wheel and is always in step.
// 0.2.0
["hedge_fund/workspace.dsl"]
// 0.3.0
[
{"path": "hedge_fund/workspace.dsl", "kind": "workspace"},
{"path": "hedge_fund/model/people.dsl", "kind": "fragment"}
]!include fragments now appear too. They are not loadable — POST /api/load needs a workspace block — but they are editable, which is why hiding them stopped making sense. Filter on kind === "workspace" to get the old list back.
Aliased deploymentEnvironment now parses (PP-138)#
prod = deploymentEnvironment "Production" { … }was silently broken: it was rejected and its body leaked into model scope, so the closing brace ended model early and everything after it vanished from the workspace. If you worked around this by using the plain form, nothing changes — both forms work now. If a workspace of yours was quietly missing elements, this is why, and it is fixed.
Optional extra for the assistant#
The assistant is off by default and needs both a flag and a dependency:
pip install 'c4studio[assistant]'
export ANTHROPIC_API_KEY=...
c4 webapp samples/ --assistantIt is the only feature that sends anything off your machine, and what it sends is the workspace source. Without --assistant the route answers 403; the key is read from the environment at the moment of use and is never stored, logged or echoed back. A default install has no new dependency and no new behaviour.
Renamed to c4studio (PP-106)#
Everything the project was named after itself changed at once. 0.1.0 was published under the old names; the next release is the first as c4studio.
| What | Before | After |
|---|---|---|
| PyPI distribution | pystructurizr-studio | c4studio |
| Command | pystructurizr | c4 |
| Import package | pystructurizr | c4studio |
| npm packages | @pystructurizr/diagram-core, pystructurizr-frontend | @c4studio/diagram-core, c4studio-frontend |
| Node override | PYSTRUCTURIZR_NODE | C4STUDIO_NODE |
| VS Code settings and commands | pystructurizr.* | c4studio.* |
| VS Code extension | pystructurizr-vscode | c4studio-vscode |
To upgrade:
pipx uninstall pystructurizr-studio && pipx install c4studioThen rewrite import pystructurizr → import c4studio and any scripted pystructurizr <command> → c4 <command>. The GitHub Action's version input now defaults to c4studio; a workflow pinning pystructurizr-studio must be repointed.
The git repository moved to geoffkoh/c4studio as well. GitHub redirects the old path, so existing clones, links and uses: references keep working — but repoint them, because the redirect stops the day anything else claims the old name.
The DSL and layout-sidecar formats are untouched, so existing .dsl files and *.layout.json sidecars load as they are. PYSTRUCTURIZR_NODE is still honoured as a fallback — it usually lives in CI configuration — but C4STUDIO_NODE wins when both are set. Browser-held UI preferences (edge style, snap-to-grid, interaction mode, explorer level) are keyed by name and reset once to their defaults.
Phase 1 — Critical fixes (PP-32)#
DeploymentNode.instances: str → int (reverted — see below)#
Before:
DeploymentNode(id="dn", name="EC2", instances="3")After:
DeploymentNode(id="dn", name="EC2", instances=3)JSON parser already casts via int(...); if you constructed DeploymentNode directly with a string literal, update the call.
Reverted (PP-87). This change lost data: Structurizr allows range expressions such as"0..N"and"1..3", which anintcannot hold — the parser fell back to1and discarded the author's intent without a warning.instancesis astragain, defaulting to"1", matching structurizr-java. Compare against"3"rather than3.
parent_id on Container, Component, DeploymentNode, InfrastructureNode#
New read-only field used for hierarchy reconstruction. The JSON and DSL parsers populate it automatically. No action required unless you build these elements by hand and want hierarchy lookup to work — in that case set parent_id to the owning element's id.
AutomaticLayout default separations: 300 → 100#
Aligns with Structurizr Java. If you relied on rank_separation == 300, specify it explicitly.
Perspective.title#
New optional field. Backwards compatible.
Phase 2 — Important fields (PP-33)#
Additive fields with safe defaults — no migration needed:
- Workspace metadata:
id,version,revision,last_modified_date,last_modified_by,created_date,created_by - ViewElement:
title,description,width,height - RelationshipView:
title,link,link_element - View:
owner,disable_automatic_layout(hide_element_metadataandhide_relationship_metadatawere added here too, and removed again in PP-90 — see below) - DeploymentNode / InfrastructureNode:
icon
Terminology defaults changed#
Was empty strings, now Java strings:
Terminology()
# enterprise="Enterprise", person="Person", software_system="Software System", ...If you constructed Terminology() and relied on terminology.person == "", pass Terminology(person="") explicitly.
Phase 3 — Structural refactor (PP-34)#
The biggest change. Workspace is composed of Model and ViewSet instead of holding flat lists.
New structure#
@dataclass
class Workspace:
name: str
description: str = ""
model: Model = field(default_factory=Model)
views: ViewSet = field(default_factory=ViewSet)
# workspace metadata (id, version, revision, ...) unchangedModel owns people, software_systems, relationships, deployment_nodes, deployment_environments, enterprise, plus find_element() and all_relationships_for().
ViewSet owns typed view lists (system_landscape_views, system_context_views, container_views, component_views, dynamic_views, deployment_views, custom_views, filtered_views) plus configuration.
What still works (backward-compatible)#
All of these continue to function via @property delegates on Workspace:
ws.people.append(p) # → ws.model.people
ws.software_systems[0] # → ws.model.software_systems
ws.relationships # → ws.model.relationships
ws.deployment_nodes # → ws.model.deployment_nodes
ws.deployment_environments # → ws.model.deployment_environments
ws.enterprise = Enterprise(...) # ws.model.enterprise = ...
ws.configuration = Configuration(...) # ws.views.configuration = ...
ws.find_element("id") # → ws.model.find_element
ws.all_relationships_for(ids) # → ws.model.all_relationships_forws.views is now a ViewSet but supports the list protocol for back-compat:
len(ws.views)
ws.views[0]
for view in ws.views: ...
ws.views.append(View(type=ViewType.SYSTEM_CONTEXT, key="ctx"))
# append() routes to the typed list matching view.typeWhat stopped working#
Constructing Workspace with the old flat keyword arguments no longer works:
# Before
Workspace(name="W", deployment_nodes=[dn])
Workspace(name="W", enterprise=Enterprise(name="Acme"))
# After
Workspace(name="W", model=Model(deployment_nodes=[dn]))
Workspace(name="W", model=Model(enterprise=Enterprise(name="Acme")))If you have parsers or fixtures that pass element lists or enterprise as keyword arguments to Workspace, wrap them in a Model.
Recommended (new) style#
Prefer accessing through the structured fields:
ws.model.people.append(person)
ws.views.system_context_views.append(view)
ws.views.configuration = configurationPhase 4 — Complete features (PP-35)#
Additive fields with safe defaults:
CustomElement.icon: optional icon name/URLConfiguration.branding: optionalBranding(color, font, logo)Configuration.generators_and_exporters:dict[str, str]Workspace.documentation:list[Documentation](eachDocumentation(content, format="Markdown"))Workspace.decisions:list[str]for architecture decision references
Workspace.validate()#
New method that returns a list of validation issues. Empty list means the workspace is well-formed.
issues = ws.validate()
if issues:
for issue in issues:
print(issue)Currently checks that view keys are non-empty and unique across all view types. Extend as needed.
Removed: View.hide_element_metadata / hide_relationship_metadata (PP-90)#
Breaking, but only in theory. Both fields were added by the PP-33 compatibility pass and neither exists in Structurizr: they are absent from structurizr-core, from the DSL, and from the workspace JSON schema. They were read from JSON keys nothing ever writes, never exported, and never consumed by a renderer. Nothing could have depended on them doing anything.
The real mechanism, now honoured, is the style properties Structurizr actually defines — ElementStyle.metadata / ElementStyle.description and RelationshipStyle.metadata / RelationshipStyle.description, all Optional[bool]:
styles {
element "Datastore" {
metadata false # drops the [Container: PostgreSQL] line
description false # drops the description line
}
relationship "Relationship" {
metadata false # drops the technology from edge labels
}
}Resolution follows the usual cascade — theme styles first, then the workspace's own, later matches overriding earlier ones — and is applied once in graph/view_graph.py, so the Mermaid C4 target, the flowchart target and the web app all honour it.
If you were setting the removed fields in Python, move to a style rule:
# before (did nothing)
View(type=ViewType.CONTAINER, key="c", hide_element_metadata=True)
# after
workspace.views.configuration.styles.element_styles.append(
ElementStyle(tag="Element", metadata=False)
)AutomaticLayout defaults corrected (PP-102)#
node_separation was 100 and edge_separation 0; structurizr-core's AutomaticLayout.DEFAULT_* constants are 100 / 50 / 50. Ours now match.
This is visible: a view declaring autoLayout previously laid out with a hardcoded 90/60 because the separations never reached the renderer at all. It now uses what the view declares, so such diagrams re-layout once — ranks slightly further apart, nodes slightly closer. Views that declare no autoLayout are unchanged, and any view with a saved layout sidecar keeps its stored positions regardless.
Field mapping reference#
| Phase | Class | Field | Type | Default |
|---|---|---|---|---|
| 1 | DeploymentNode | instances | int | 1 |
| 1 | Container/Component/DeploymentNode/InfrastructureNode | parent_id | str | "" |
| 1 | AutomaticLayout | rank_separation | int | 100 |
| 1 | AutomaticLayout | node_separation | int | 100 |
| 1 | Perspective | title | str | "" |
| 2 | Workspace | id | str | "" |
| 2 | Workspace | version | int | 1 |
| 2 | Workspace | revision | int | 1 |
| 2 | Workspace | last_modified_date | str | "" |
| 2 | Workspace | last_modified_by | str | "" |
| 2 | Workspace | created_date | str | "" |
| 2 | Workspace | created_by | str | "" |
| 2 | ViewElement | title, description | str | "" |
| 2 | ViewElement | width, height | Optional[int] | None |
| 2 | RelationshipView | title | str | "" |
| 2 | RelationshipView | link, link_element | Optional[bool]/Optional[int] | None |
| 2 | View | owner | str | "" |
| 2 | View | disable_automatic_layout | bool | False |
| 2 | View | ~~hide_element_metadata~~ | removed in PP-90 | — |
| 2 | View | ~~hide_relationship_metadata~~ | removed in PP-90 | — |
| 2 | DeploymentNode/InfrastructureNode | icon | str | "" |
| 2 | Terminology | (all) | str | Java defaults |
| 3 | Workspace | model | Model | Model() |
| 3 | Workspace | views | ViewSet | ViewSet() |
| 4 | CustomElement | icon | str | "" |
| 4 | Configuration | branding | Optional[Branding] | None |
| 4 | Configuration | generators_and_exporters | dict[str, str] | {} |
| 4 | Workspace | documentation | list[Documentation] | [] |
| 4 | Workspace | decisions | list[str] | [] |
Deliberate divergences from structurizr-java#
These fields exist in c4studio but not in structurizr-java, or differ from it. They are intentional and supported, not oversights, and were reviewed against the Java model in July 2026. Recorded here because a periodic "align with Java" pass keeps proposing their removal.
| Field | Why it stays |
|---|---|
parent_id on Container, Component, DeploymentNode, InfrastructureNode | Load-bearing. The webapp reconstructs element hierarchy from it, and view_graph lifts relationships to their nearest visible ancestor through it — that is what makes a person -> container relationship render as person -> system on a context diagram. Java uses transient back-references instead; c4studio's model is serialised and re-read, so it needs the explicit id. |
Person.location, SoftwareSystem.location | Java deprecated location, but the DSL keyword still exists and this is how external elements get their distinct styling: view_graph._person_kind / _system_kind consult it (falling back to an external tag). Removing it would silently flatten internal and external elements to the same colour. |
Perspective.url, Perspective.title | Additive metadata, parsed from the DSL and round-tripped through workspace JSON. title was added deliberately by the PP-31 compatibility work; a later ticket proposed removing it, which would have undone that. Check the Java model directly before revisiting. |
icon on CustomElement, DeploymentNode, InfrastructureNode | Java carries icon only on ElementStyle. Per-element icons are a convenience the renderer honours. |
By contrast, these are worth aligning and are tracked as bugs rather than parity items, because the current behaviour loses data: DeploymentNode.instances cannot express Structurizr's "0..N" range syntax, and Branding.font drops the font URL.
Terminology defaults are not a divergence in practice: they are populated in the dataclass, but generators/json_export._terminology compares against those defaults and emits only values the workspace actually set, so an undeclared terminology exports as null.