Skip to content

Workspace

Workspace is a directory with LikeC4 source files.
When parsed, these files are “merged” into a single architecture model.
You are free to organize the workspace as you want.

Example

Assume we have the following workspace:

  • Directorycloud
    • service1.c4
    • service2.c4
  • Directoryexternals
    • amazon.c4
  • landscape.c4
  • specs.c4

This file defines the specification:

specs.c4
specification {
element actor {
style {
shape person
}
}
element system
element service
}

Extend element

extend is a way to enrich the model and define nested elements in a separate file.

We don’t want to mess up the landscape.c4 file with the internals of the cloud.
In a separate file we extend cloud and define cloud.service1:

cloud/service1.c4
model {
// cloud is defined in landscape.c4
extend cloud {
// extend and define cloud.service1
service1 = service 'Service 1'
}
}

The element extension inherits the scope of the target (or better say parent).
For example:

cloud/service2.c4
model {
// cloud is defined in landscape.c4
extend cloud {
// extend and define cloud.service2
service2 = service 'Some Service 2'
service2 -> service1 // ✅ service1 is known inside 'cloud'
}
}