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:
- service1.c4
- service2.c4
- amazon.c4
This file defines the specification:
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.
For instance, we don't want to mess up the landscape.c4 file with the internals of the cloud
.
In a separate cloud/service1.c4 file we define cloud.service1
:
cloud/service1.c4
model {
// cloud is defined in landscape.c4
extend cloud {
// here we 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 file:
cloud/service2.c4
model {
// cloud is defined in landscape.c4
extend cloud {
// define cloud.service2
service2 = service 'Some Service 2' {
-> service1 'delegates some work' // ✅ service1 is known inside 'cloud',
// and resolved even defined in another file
}
}
// service2 unique inside the file
service2 -> service1 // ⛔️ Error: service1 not found
// as can't be resolved from this file
service2 -> cloud.service1 // ✅ OK: Resolved by fully qualified name
}
The target element must be referenced by a fully qualified name.
model {
extend rds // ⛔️ Error: rds not found in the global scope
extend amazon.rds // ✅ Resolved by fully qualified name
}