Object Model And Relations
This page explains the main structural pieces of the ASCII Diagram file format.
Shared object fields
All diagram objects share a few base properties:
idtypepositionzIndex- optional
label - optional
groupId
position is stored in character-grid coordinates.
Box objects
Boxes are rectangular nodes with optional title and body content.
Important fields include:
widthheighttitlecontenttextAlignverticalAlignborder- optional
borderStyle
Example:
{
"id": "box-1",
"type": "box",
"position": {"x": 4, "y": 2},
"width": 16,
"height": 5,
"title": "API",
"content": "POST /events",
"zIndex": 1
}
Text objects
Text objects are freeform text blocks with dimensions and alignment controls.
Important fields include:
contentwidthheight- optional
showBorder textAlignverticalAlign
Arrow objects
Arrows connect points on the grid.
Important fields include:
positionfor the start pointendfor the end point- optional
waypoints startHeadendHead- optional
routing - optional
lineStyle
Routing currently supports:
directorthogonalstepped
Ports and relations
Relations connect a source object port to a target object port.
This is how ASCII Diagram preserves attachment semantics instead of treating every arrow as a loose line.
Two main port forms exist:
anchorfor rectangular object edgesendpointfor arrow start, end, or waypoint indices
At a high level, a relation says:
- which object follows
- which point on that object follows
- which object it is attached to
- which point on the target it is attached to
Groups
Groups are named collections of objects.
They are useful for:
- moving a cluster together
- keeping diagram fragments organized
- preserving intent in more complex documents
Z-order
Objects also carry zIndex, which controls drawing order.
That matters when objects overlap and when you want the object list to reflect the current stacking order.
Why this structure exists
The schema is designed to support three things at once:
- visual editing
- durable file storage
- future migrations and tooling
It is intentionally richer than raw pasted ASCII because the app needs enough structure to support editing without turning the file into an opaque binary format.