Skip to content

LikeC4 Project Spec

Source: likec4.project.json

This schema describes the Project project spec for the LikeC4 backend.

Properties

Properties

Field Type Description
render_options LikeC4RenderOptionsSchema
backend(required) string Required discriminator for the LikeC4 project JSON format. Must be exactly likec4.
deployment LikeC4DeploymentSchema
model LikeC4ModelSchema
name string | null Optional project title.
specification LikeC4SpecificationSchema
views LikeC4ViewsSchema
Examples
JSON source
{
  "backend": "likec4",
  "name": "Shop",
  "specification": {
    "elements": [
      {
        "name": "actor",
        "style": {
          "shape": "person"
        }
      },
      {
        "name": "system"
      }
    ]
  },
  "model": {
    "elements": [
      {
        "id": "customer",
        "alias": "customer",
        "kind": "actor",
        "title": "Customer"
      },
      {
        "id": "shop",
        "alias": "shop",
        "kind": "system",
        "title": "Online Shop"
      }
    ],
    "relationships": [
      {
        "from": "customer",
        "to": "shop",
        "title": "buys goods"
      }
    ]
  },
  "views": {
    "items": [
      {
        "type": "element",
        "key": "index",
        "title": "Landscape",
        "rules": [
          {
            "rule": "include",
            "items": [
              {
                "type": "wildcard"
              }
            ]
          }
        ]
      }
    ]
  }
}
Rendered LikeC4 DSL source
specification {
  element actor { style { shape person } }
  element system
}

model {
  customer = actor "Customer"
  shop = system "Online Shop"
  customer -> shop "buys goods"
}

views {
  view index {
    title "Landscape"
    include *
  }
}
Rendered image

Project minimal example

JSON source
{
  "backend": "likec4",
  "name": "Shop",
  "render_options": {
    "view_key": "index"
  },
  "specification": {
    "colors": [
      {
        "name": "brand",
        "value": "#0b5fff"
      }
    ],
    "elements": [
      {
        "name": "actor",
        "notation": "Person",
        "style": {
          "color": "brand",
          "shape": "person"
        }
      },
      {
        "name": "system",
        "style": {
          "color": "primary"
        }
      },
      {
        "name": "service",
        "technology": "Python",
        "style": {
          "shape": "component"
        }
      },
      {
        "name": "database",
        "style": {
          "shape": "storage",
          "color": "amber"
        }
      }
    ],
    "relationships": [
      {
        "name": "async",
        "style": {
          "line": "dotted",
          "head": "diamond"
        }
      }
    ],
    "tags": [
      {
        "name": "critical",
        "color": "red"
      },
      {
        "name": "deprecated"
      }
    ],
    "deployment_nodes": [
      {
        "name": "environment",
        "notation": "Environment",
        "style": {
          "color": "gray"
        }
      },
      {
        "name": "vm"
      }
    ]
  },
  "model": {
    "elements": [
      {
        "id": "customer",
        "alias": "customer",
        "kind": "actor",
        "title": "Customer",
        "description": "Buys goods in the **shop**."
      },
      {
        "id": "shop",
        "alias": "shop",
        "kind": "system",
        "title": "Online Shop",
        "summary": "Sells goods online",
        "metadata": {
          "owner": "team-shop",
          "tiers": [
            "web",
            "api"
          ]
        },
        "links": [
          {
            "url": "https://example.com/shop",
            "title": "Docs"
          }
        ],
        "elements": [
          {
            "id": "web",
            "alias": "web",
            "kind": "service",
            "title": "Web",
            "icon": "tech:react"
          },
          {
            "id": "api",
            "alias": "api",
            "kind": "service",
            "title": "API",
            "tags": [
              "critical"
            ],
            "description": "Handles [[orders]] and payments."
          },
          {
            "id": "db",
            "alias": "db",
            "kind": "database",
            "title": "Database",
            "tags": [
              "deprecated"
            ]
          }
        ]
      },
      {
        "id": "queue",
        "alias": "queue",
        "kind": "service",
        "title": "Order Queue"
      }
    ],
    "relationships": [
      {
        "from": "customer",
        "to": "web",
        "title": "opens",
        "technology": "HTTPS"
      },
      {
        "from": "web",
        "to": "api",
        "title": "calls",
        "technology": "REST",
        "tags": [
          "critical"
        ]
      },
      {
        "from": "api",
        "to": "db",
        "title": "reads and writes",
        "technology": "SQL"
      },
      {
        "from": "api",
        "to": "queue",
        "title": "publishes orders",
        "kind": "async",
        "navigate_to": "checkout"
      }
    ]
  },
  "deployment": {
    "nodes": [
      {
        "id": "prod",
        "alias": "prod",
        "kind": "environment",
        "title": "Production",
        "nodes": [
          {
            "id": "app",
            "alias": "app",
            "kind": "vm",
            "title": "App VM",
            "instances": [
              {
                "element": "api",
                "name": "primary"
              },
              {
                "element": "api",
                "name": "secondary"
              },
              {
                "element": "web"
              }
            ]
          },
          {
            "id": "data",
            "alias": "data",
            "kind": "vm",
            "title": "Data VM",
            "instances": [
              {
                "element": "db"
              }
            ]
          }
        ]
      }
    ],
    "relationships": [
      {
        "from": "app",
        "to": "data",
        "title": "queries",
        "technology": "TCP/5432"
      }
    ]
  },
  "views": {
    "items": [
      {
        "type": "element",
        "key": "index",
        "title": "Landscape",
        "rules": [
          {
            "rule": "include",
            "items": [
              {
                "type": "wildcard"
              }
            ]
          },
          {
            "rule": "style",
            "targets": [
              {
                "type": "element",
                "id": "customer"
              }
            ],
            "properties": {
              "color": "brand"
            }
          },
          {
            "rule": "auto_layout",
            "direction": "LeftRight",
            "rank_sep": 80,
            "node_sep": 100
          }
        ]
      },
      {
        "type": "element",
        "key": "shop-detail",
        "title": "Shop",
        "of": "shop",
        "tags": [
          "critical"
        ],
        "rules": [
          {
            "rule": "include",
            "items": [
              {
                "type": "wildcard"
              },
              {
                "type": "where",
                "item": {
                  "type": "children",
                  "of": "shop"
                },
                "tag": "critical"
              },
              {
                "type": "between",
                "source": {
                  "type": "element",
                  "id": "web"
                },
                "target": {
                  "type": "element",
                  "id": "api"
                }
              }
            ]
          },
          {
            "rule": "exclude",
            "items": [
              {
                "type": "element",
                "id": "db"
              }
            ]
          },
          {
            "rule": "include",
            "items": [
              {
                "type": "element",
                "id": "api"
              }
            ],
            "navigate_to": "checkout"
          }
        ]
      },
      {
        "type": "element",
        "key": "critical",
        "rules": [
          {
            "rule": "include",
            "items": [
              {
                "type": "raw",
                "text": "shop.** where tag is #critical"
              }
            ]
          }
        ]
      },
      {
        "type": "deployment",
        "key": "production",
        "title": "Production",
        "rules": [
          {
            "rule": "include",
            "items": [
              {
                "type": "element",
                "id": "prod"
              },
              {
                "type": "children",
                "of": "prod"
              }
            ]
          },
          {
            "rule": "style",
            "targets": [
              {
                "type": "element",
                "id": "prod"
              }
            ],
            "properties": {
              "color": "green"
            }
          }
        ]
      },
      {
        "type": "dynamic",
        "key": "checkout",
        "title": "Checkout",
        "variant": "sequence",
        "steps": [
          {
            "from": "customer",
            "to": "web",
            "title": "opens checkout",
            "technology": "HTTPS"
          },
          {
            "from": "web",
            "to": "api",
            "title": "places order",
            "notes": "Validates the **cart**."
          },
          {
            "from": "web",
            "to": "api",
            "title": "order id",
            "backward": true
          },
          {
            "from": "api",
            "to": "queue",
            "title": "enqueues",
            "color": "amber"
          }
        ]
      }
    ]
  }
}
Rendered LikeC4 DSL source
specification {
  color brand #0b5fff
  element actor {
    notation "Person"
    style {
      color brand
      shape person
    }
  }
  element system { style { color primary } }
  element service {
    technology "Python"
    style { shape component }
  }
  element database {
    style {
      color amber
      shape storage
    }
  }
  relationship async {
    line dotted
    head diamond
  }
  tag critical { color red }
  tag deprecated
  deploymentNode environment {
    notation "Environment"
    style { color gray }
  }
  deploymentNode vm
}

model {
  customer = actor "Customer" { description '''Buys goods in the **shop**.''' }
  shop = system "Online Shop" {
    summary "Sells goods online"
    metadata {
      owner "team-shop"
      tiers ["web", "api"]
    }
    link https://example.com/shop "Docs"
    web = service "Web" { icon tech:react }
    api = service "API" {
      #critical
      description '''Handles \\[\\[orders]] and payments.'''
    }
    db = database "Database" { #deprecated }
  }
  queue = service "Order Queue"
  customer -> shop.web "opens" { technology "HTTPS" }
  shop.web -> shop.api "calls" {
    #critical
    technology "REST"
  }
  shop.api -> shop.db "reads and writes" { technology "SQL" }
  shop.api -[async]-> queue "publishes orders" { navigateTo checkout }
}

deployment {
  prod = environment "Production" {
    app = vm "App VM" {
      primary = instanceOf shop.api
      secondary = instanceOf shop.api
      instanceOf shop.web
    }
    data = vm "Data VM" { instanceOf shop.db }
  }
  prod.app -> prod.data "queries" { technology "TCP/5432" }
}

views {
  view index {
    title "Landscape"
    include *
    style customer { color brand }
    autoLayout LeftRight 80 100
  }
  view shop-detail of shop {
    #critical
    title "Shop"
    include *
    include shop.* where tag is #critical
    include shop.web -> shop.api
    exclude shop.db
    include shop.api with { navigateTo checkout }
  }
  view critical { include shop.** where tag is #critical }
  deployment view production {
    title "Production"
    include prod, prod.*
    style prod { color green }
  }
  dynamic view checkout {
    title "Checkout"
    variant sequence
    customer -> shop.web "opens checkout" { technology "HTTPS" }
    shop.web -> shop.api "places order" { notes '''Validates the **cart**.''' }
    shop.web <- shop.api "order id"
    shop.api -> queue "enqueues" { color amber }
  }
}
Rendered image

Project advanced example

Definitions

LikeC4AutoLayoutRuleSchema

autoLayout direction [rank_sep [node_sep]] rule.

Properties

Field Type Description
direction enum[TopBottom | LeftRight | BottomTop | RightLeft] Direction Default: TopBottom.
node_sep integer | null Node Sep
rank_sep integer | null Rank Sep
rule(required) string Rule Must be exactly auto_layout.

LikeC4BetweenSchema

Relationship predicate source -> target (<-> with both).

Properties

Field Type Description
type(required) string Type Must be exactly between.
both boolean Both Default: false.
source(required) object Source
target(required) object Target

LikeC4ChildrenSchema

The direct children of an item (item.*).

Properties

Field Type Description
type(required) string Type Must be exactly children.
of(required) string Of

LikeC4ColorSchema

A custom named color.

Properties

Field Type Description
name(required) string Name
value(required) string Value

LikeC4DeploymentNodeSchema

A deployment node; nodes nest and hold instances.

Properties

Field Type Description
title string | null Title
alias string | null Alias
description string | null Description
id(required) string Id
instances array[LikeC4InstanceSchema] Instances
kind(required) string Kind
links array[LikeC4LinkSchema] Links
metadata object Metadata
nodes array[LikeC4DeploymentNodeSchema] Nodes
style object Style
tags array[string] Tags
technology string | null Technology

LikeC4DeploymentRelationshipSchema

A relationship between deployment nodes or instances.

Properties

Field Type Description
title string | null Title
bidirectional boolean Bidirectional Default: false.
description string | null Description
from(required) string From
kind string | null Kind
links array[LikeC4LinkSchema] Links
metadata object Metadata
style object Style
tags array[string] Tags
technology string | null Technology
to(required) string To

LikeC4DeploymentSchema

The deployment nodes, instances and relationships of a project.

Properties

Field Type Description
relationships array[LikeC4DeploymentRelationshipSchema] Relationships
nodes array[LikeC4DeploymentNodeSchema] Nodes

LikeC4DeploymentViewSchema

A view over deployment nodes and instances.

Properties

Field Type Description
type(required) string Type Must be exactly deployment.
title string | null Title
description string | null Description
key(required) string Key
links array[LikeC4LinkSchema] Links
rules array[
 LikeC4IncludeRuleSchema
 |LikeC4ExcludeRuleSchema
 |LikeC4StyleRuleSchema
 |LikeC4AutoLayoutRuleSchema
]
Rules
tags array[string] Tags

LikeC4DescendantsSchema

All nested items of an item (item.**).

Properties

Field Type Description
type(required) string Type Must be exactly descendants.
of(required) string Of

LikeC4DynamicStepSchema

One flat interaction of a dynamic view; blocks are not supported.

Properties

Field Type Description
title string | null Title
backward boolean Backward Default: false.
color string | null Color
description string | null Description
from(required) string From
navigate_to string | null Navigate To
notes string | null Notes
technology string | null Technology
to(required) string To

LikeC4DynamicViewSchema

A dynamic view: an ordered, flat list of steps.

Properties

Field Type Description
type(required) string Type Must be exactly dynamic.
title string | null Title
description string | null Description
key(required) string Key
links array[LikeC4LinkSchema] Links
steps array[LikeC4DynamicStepSchema] Steps
tags array[string] Tags
variant enum[diagram | sequence] Variant Default: diagram.

LikeC4ElementKindSchema

A declared element or deployment node kind.

Properties

Field Type Description
title string | null Title
description string | null Description
name(required) string Name
notation string | null Notation
style object Style
tags array[string] Tags
technology string | null Technology

LikeC4ElementRefSchema

A reference to a model element, node or instance by id.

Properties

Field Type Description
type(required) string Type Must be exactly element.
id(required) string Id

LikeC4ElementSchema

A model element; children nest without limit.

Properties

Field Type Description
title string | null Title
elements array[LikeC4ElementSchema] Elements
alias string | null Alias
description string | null Description
icon string | null Icon
id(required) string Id
kind(required) string Kind
links array[LikeC4LinkSchema] Links
metadata object Metadata
style object Style
summary string | null Summary
tags array[string] Tags
technology string | null Technology

LikeC4ElementViewSchema

A view over model elements.

Properties

Field Type Description
type(required) string Type Must be exactly element.
title string | null Title
description string | null Description
key(required) string Key
links array[LikeC4LinkSchema] Links
of string | null Of
rules array[
 LikeC4IncludeRuleSchema
 |LikeC4ExcludeRuleSchema
 |LikeC4StyleRuleSchema
 |LikeC4AutoLayoutRuleSchema
]
Rules
tags array[string] Tags

LikeC4ExcludeRuleSchema

exclude items rule.

Properties

Field Type Description
items(required) array[
 LikeC4WildcardSchema
 |LikeC4ElementRefSchema
 |LikeC4ChildrenSchema
 |LikeC4DescendantsSchema
 |LikeC4WhereSchema
 |LikeC4BetweenSchema
 |LikeC4IncomingSchema
 |LikeC4OutgoingSchema
 |LikeC4InOutSchema
 |LikeC4RawPredicateSchema
]
Items
rule(required) string Rule Must be exactly exclude.

LikeC4InOutSchema

Relationship predicate -> item ->.

Properties

Field Type Description
type(required) string Type Must be exactly inout.
item(required) object Item

LikeC4IncludeRuleSchema

include items [with { navigateTo key }] rule.

Properties

Field Type Description
items(required) array[
 LikeC4WildcardSchema
 |LikeC4ElementRefSchema
 |LikeC4ChildrenSchema
 |LikeC4DescendantsSchema
 |LikeC4WhereSchema
 |LikeC4BetweenSchema
 |LikeC4IncomingSchema
 |LikeC4OutgoingSchema
 |LikeC4InOutSchema
 |LikeC4RawPredicateSchema
]
Items
navigate_to string | null Navigate To
rule(required) string Rule Must be exactly include.

LikeC4IncomingSchema

Relationship predicate -> item.

Properties

Field Type Description
type(required) string Type Must be exactly incoming.
item(required) object Item

LikeC4InstanceSchema

An instance of a model element deployed on a node.

Properties

Field Type Description
title string | null Title
description string | null Description
element(required) string Element
id string | null Id
links array[LikeC4LinkSchema] Links
metadata object Metadata
name string | null Name
style object Style
tags array[string] Tags
technology string | null Technology

LikeC4LinkSchema

A hyperlink attached to an element, relationship or view.

Properties

Field Type Description
title string | null Title
url(required) string Url

LikeC4ModelSchema

The element hierarchy and relationships of a project.

Properties

Field Type Description
elements array[LikeC4ElementSchema] Elements
relationships array[LikeC4RelationshipSchema] Relationships

LikeC4OutgoingSchema

Relationship predicate item ->.

Properties

Field Type Description
type(required) string Type Must be exactly outgoing.
item(required) object Item

LikeC4RawPredicateSchema

Predicate text emitted verbatim.

Properties

Field Type Description
type(required) string Type Must be exactly raw.
text(required) string Text

LikeC4RelationshipKindSchema

A declared relationship kind.

Properties

Field Type Description
description string | null Description
name(required) string Name
style object Style
technology string | null Technology

LikeC4RelationshipSchema

A model relationship using c4-diagrams from/to spelling.

Properties

Field Type Description
title string | null Title
bidirectional boolean Bidirectional Default: false.
description string | null Description
from(required) string From
kind string | null Kind
links array[LikeC4LinkSchema] Links
metadata object Metadata
navigate_to string | null Navigate To
style object Style
tags array[string] Tags
technology string | null Technology
to(required) string To

LikeC4RenderOptionsSchema

LikeC4 renderer options.

Properties

Field Type Description
view_key string | null View exported as an image when none is chosen otherwise.

LikeC4SpecificationSchema

The vocabulary of a project: kinds, tags and custom colors.

Properties

Field Type Description
elements array[LikeC4ElementKindSchema] Elements
relationships array[LikeC4RelationshipKindSchema] Relationships
colors array[LikeC4ColorSchema] Colors
deployment_nodes array[LikeC4ElementKindSchema] Deployment Nodes
tags array[LikeC4TagSchema] Tags

LikeC4StyleRuleSchema

style targets { ... } rule.

Properties

Field Type Description
properties(required) object Properties
rule(required) string Rule Must be exactly style.
targets(required) array[
 LikeC4WildcardSchema
 |LikeC4ElementRefSchema
 |LikeC4ChildrenSchema
 |LikeC4DescendantsSchema
 |LikeC4WhereSchema
 |LikeC4BetweenSchema
 |LikeC4IncomingSchema
 |LikeC4OutgoingSchema
 |LikeC4InOutSchema
 |LikeC4RawPredicateSchema
]
Targets

LikeC4TagSchema

A declared tag; the name is written without #.

Properties

Field Type Description
color string | null Color
name(required) string Name

LikeC4ViewsSchema

Declared views in authoring order.

Properties

Field Type Description
items array[LikeC4ElementViewSchema|LikeC4DeploymentViewSchema|LikeC4DynamicViewSchema] Items

LikeC4WhereSchema

item where tag is #tag and kind is kind filter.

Properties

Field Type Description
type(required) string Type Must be exactly where.
item(required) object Item
kind string | null Kind
tag string | null Tag

LikeC4WildcardSchema

The * predicate.

Properties

Field Type Description
type(required) string Type Must be exactly wildcard.