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:
specification { element actor { style { shape person } } element system element service}
This file defines the top-level elements and landscape view:
model { customer = actor 'Customer' cloud = system 'Cloud System'}views { view index of cloud { title "Cloud System - Landscape" include * }}
We keep definitions of external systems separate, inside the externals/
folder:
model { amazon = system 'Amazon Web Services' { rds = service 'Database' }}
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
:
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:
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' }}