What JSON Structure Is Used for Archify Architecture Diagrams?
Archify architecture diagrams rely on a strict JSON schema defined in architecture.schema.json that requires the top-level fields schema_version, diagram_type, meta, and components, while optionally accepting layout, boundaries, connections, and cards to define grid placement, visual groupings, and component relationships.
The tt-a1i/archify repository implements a schema-driven validation system where understanding the specific JSON structure used for Archify architecture diagrams is essential for generating valid visualizations. This formal schema, located at archify/schemas/architecture.schema.json, enforces strict typing on diagram metadata, component definitions, and spatial relationships to ensure predictable rendering across environments.
Root Schema Requirements
At the root level, the JSON structure must include four mandatory fields:
schema_version: Integer value fixed at1diagram_type: String set to"architecture"meta: Object containing human-readable diagram informationcomponents: Array of diagram elements (servers, databases, frontend services, etc.)
Optional root-level collections include layout for grid-based positioning, boundaries for visual groupings like security groups, connections for linking components, and cards for reusable UI elements.
Metadata Configuration
The meta object requires a title field and supports additional descriptive properties:
title(required): String describing the diagramsubtitle: Optional secondary descriptionoutput: Optional output path or format configurationanimation: Enum string, either"trace"or"none"viewBox: Array specifying canvas dimensions as[width, height]with a minimum size of 320 × 240 pixels
Grid Layout System
When mode is set to "grid", the optional layout object controls component placement with the following properties:
mode: Must be"grid"cols: Number of grid columnsgapXandgapY: Horizontal and vertical spacing between cellscellWandcellH: Individual cell width and heightorigin: Optional[x, y]point defining the grid origin
Component Definitions
Each item in the components array represents a visual element with strict identification requirements.
Required fields for every component:
id: Unique identifier referenced byboundariesandconnectionstype: Component category (e.g.,"frontend","database","cache")label: Display text rendered on the diagram
Optional component fields include:
sublabel: Secondary text displayed below the primary labeltag: Classification or grouping tagrowandcol: Grid coordinates when using layout modepos: Explicit[x, y]point coordinates for absolute positioningsize: Dimensions specified as[width, height]
Visual Boundaries
The boundaries array defines logical groupings such as AWS regions or security zones. Each boundary object requires:
kind: Either"region"or"security-group"label: Boundary display namewraps: Array of componentids to visually enclosepad: Optional padding value around the grouped components
Connection Specifications
Connections link components through the connections array with detailed routing controls:
fromandto: Componentids specifying start and end pointslabel: Text description of the connectionvariant: Styling variant identifierfromSideandtoSide: Attachment sides on source and target componentsroute: Routing algorithm specificationvia: Array of[x, y]points defining custom path routinglabelAt,labelDx,labelDy: Precise label positioning controlslabelSegment: Which path segment carries the labelwidth: Line thickness in pixels
Schema References and Shared Definitions
All identifier formats, point definitions, and base types are pulled from the shared common.schema.json via JSON Schema $ref references. This centralized approach ensures that component id validation, coordinate systems, and other fundamental types remain consistent across all diagram types in the Archify ecosystem.
Practical Example
The following JSON demonstrates a valid architecture diagram configuration using grid layout:
{
"schema_version": 1,
"diagram_type": "architecture",
"meta": {
"title": "Sample Microservice Architecture",
"subtitle": "v1.0",
"animation": "trace"
},
"layout": {
"mode": "grid",
"cols": 6,
"gapX": 20,
"gapY": 20,
"cellW": 80,
"cellH": 50
},
"components": [
{
"id": "web",
"type": "frontend",
"label": "Web UI",
"col": 0,
"row": 0
},
{
"id": "api",
"type": "backend",
"label": "API Gateway",
"col": 1,
"row": 0
}
]
}
Summary
- Archify architecture diagrams require a specific JSON structure defined in
archify/schemas/architecture.schema.jsonwith mandatory fieldsschema_version(set to1),diagram_type(set to"architecture"),meta, andcomponents. - The
metaobject requires atitlestring and optionally acceptssubtitle,output,animationsettings ("trace"or"none"), andviewBoxdimensions with a minimum of 320×240 pixels. - Components must define
id,type, andlabel, with optional positioning viarow/colindices when using grid layout or absolute coordinates via theposarray. - Optional
boundariescreate visual groupings usingkindvalues of"region"or"security-group", enclosing components listed in thewrapsarray. - Connections support complex routing through
viapoint arrays, side attachments (fromSide,toSide), and detailed label positioning parameters. - Type consistency is maintained through references to
common.schema.jsonfor all identifier and point definitions.
Frequently Asked Questions
What is the minimum required JSON structure for an Archify architecture diagram?
The minimum valid structure must include four top-level fields: schema_version set to the integer 1, diagram_type set to the string "architecture", a meta object containing at least a title string, and a components array with at least one object defining id, type, and label properties. Omitting any of these required fields will cause validation errors against the architecture.schema.json schema.
How does Archify handle component positioning in the JSON structure?
Archify supports two positioning strategies within the JSON structure used for Archify architecture diagrams: grid-based placement using the optional layout object with mode: "grid" combined with component row and col indices, or absolute positioning using the pos array property containing [x, y] coordinates. The layout approach also allows configuring gapX, gapY, cellW, and cellH to control spacing and cell dimensions.
What are boundaries and how are they defined in the schema?
Boundaries are optional visual groupings defined in the boundaries array that logically enclose related components, such as AWS regions or security groups. Each boundary requires a kind property (either "region" or "security-group"), a label for display purposes, and a wraps array listing the component ids to be enclosed, with optional pad values for spacing adjustments.
Where are the base type definitions stored for Archify schemas?
Archify centralizes base type definitions—including identifiers, points, and common structures—in common.schema.json, which the architecture schema references via JSON Schema $ref pointers. This shared approach ensures that component id formats, coordinate systems, and other fundamental types remain consistent across all diagram types in the tt-a1i/archify repository.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →