dsl

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dsl implements a Go based DSL that makes it possible to describe softare architecture models following the C4 model (https://c4model.com).

It is recommended to use "dot import" when using this package to write DSLs, for example:

package model

import . "goa.design/structurizr/dsl"

var _ = Workspace("<name>", "[description]", func() {
    // ...
})

The DSL can be executed via the eval package. The resulting data structure JSON representation is suitable for uploading to the Structurizr service (https://structurizr.com). It can also be used to render diagrams in different formats (https://structurizr.com/help/code).

Some DSL functions accept a anonymous function as last argument (such as Workspace above) which makes it possible to define a nesting structure. The general shape of the DSL is:

Workspace                           Workspace
├── Version                         └── Views
├── Enterprise                          ├── SystemLandscapeView
├── Person                              │   ├── Title
│   ├── Tag                             │   ├── AddDefault
│   ├── URL                             │   ├── Add
│   ├── External                        │   ├── AddAll
│   ├── Prop                            │   ├── AddNeighbors
│   ├── Uses                            │   ├── Link
│   └── InteractsWith                   │   ├── Remove
├── SoftwareSystem                      │   ├── RemoveUnreachable
│   ├── Tag                             │   ├── RemoveUnrelated
│   ├── URL                             │   ├── AutoLayout
│   ├── External                        │   ├── Animation
│   ├── Prop                            │   ├── PaperSize
│   ├── Uses                            │   └── EnterpriseBoundaryVisible
│   └── Delivers                        ├── SystemContextView
├── Container                           │   └──  ... (same as SystemLandsapeView)
│   ├── Tag                             ├── ContainerView
│   ├── URL                             │   ├── AddContainers
│   ├── Prop                            │   ├── AddInfluencers
│   ├── Uses                            │   ├── SystemBoundariesVisible
│   └── Delivers                        │   └── ... (same as SystemLandscapeView*)
├── Component                           ├── ComponentView
│   ├── Tag                             │   ├── AddContainers
│   ├── URL                             │   ├── AddComponents
│   ├── Prop                            │   ├── ContainerBoundariesVisible
│   ├── Uses                            │   └── ... (same as SystemLandscapeView*)
│   └── Delivers                        ├── FilteredViee
└── DeploymentEnvironment               │   ├── FilterTag
    ├── DeploymentNode                  │   └── Exclude
    │   ├── Tag                         ├── DynamicView
    │   ├── Instances                   │   ├── Title
    │   ├── URL                         │   ├── AutoLayout
    │   └── Prop                        │   ├── PaperSize
    ├── InfrastructureNode              │   └── Add
    │   ├── Tag                         ├── DeploymentView
    │   ├── URL                         │   └── ... (same as SystemLandscapeView*)
    │   └── Prop                        ├── Style
    └── ContainerInstance               │   ├── ElementStyle
        ├── Tag                         │   └── RelationshipStyle
        ├── HealthCheck                 ├── Theme
        ├── Prop                        └── Branding
        └── RefName                     (* minus EnterpriseBoundaryVisible)

Index

Constants

View Source
const (
	// Synchronous describes a synchronous interaction.
	Synchronous = expr.InteractionSynchronous
	// Asynchronous describes an asynchronous interaction.
	Asynchronous = expr.InteractionAsynchronous
)
View Source
const (
	SymbolSquareBrackets      = expr.SymbolSquareBrackets
	SymbolRoundBrackets       = expr.SymbolRoundBrackets
	SymbolCurlyBrackets       = expr.SymbolCurlyBrackets
	SymbolAngleBrackets       = expr.SymbolAngleBrackets
	SymbolDoubleAngleBrackets = expr.SymbolDoubleAngleBrackets
	SymbolNone                = expr.SymbolNone
)
View Source
const (
	ShapeBox                   = expr.ShapeBox
	ShapeRoundedBox            = expr.ShapeRoundedBox
	ShapeComponent             = expr.ShapeComponent
	ShapeCircle                = expr.ShapeCircle
	ShapeEllipse               = expr.ShapeEllipse
	ShapeHexagon               = expr.ShapeHexagon
	ShapeFolder                = expr.ShapeFolder
	ShapeCylinder              = expr.ShapeCylinder
	ShapePipe                  = expr.ShapePipe
	ShapeWebBrowser            = expr.ShapeWebBrowser
	ShapeMobileDevicePortrait  = expr.ShapeMobileDevicePortrait
	ShapeMobileDeviceLandscape = expr.ShapeMobileDeviceLandscape
	ShapePerson                = expr.ShapePerson
	ShapeRobot                 = expr.ShapeRobot
)
View Source
const (
	BorderSolid  = expr.BorderSolid
	BorderDashed = expr.BorderDashed
	BorderDotted = expr.BorderDotted
)
View Source
const (
	// RankTopBottom indicates a layout that uses top to bottom rank.
	RankTopBottom = expr.RankTopBottom
	// RankBottomTop indicates a layout that uses bottom to top rank.
	RankBottomTop = expr.RankBottomTop
	// RankLeftRight indicates a layout that uses left to right rank.
	RankLeftRight = expr.RankLeftRight
	// RankRightLeft indicates a layout that uses right to left rank.
	RankRightLeft = expr.RankRightLeft
)
View Source
const (
	// SizeA0Landscape defines a render page size of A0 in landscape mode (46-13/16 x 33-1/8).
	SizeA0Landscape = expr.SizeA0Landscape
	// SizeA0Portrait defines a render page size of A0 in portrait mode (33-1/8 x 46-13/16).
	SizeA0Portrait = expr.SizeA0Portrait
	// SizeA1Landscape defines a render page size of A1 in landscape mode (33-1/8 x 23-3/8).
	SizeA1Landscape = expr.SizeA1Landscape
	// SizeA1Portrait defines a render page size of A1 in portrait mode (23-3/8 x 33-1/8).
	SizeA1Portrait = expr.SizeA1Portrait
	// SizeA2Landscape defines a render page size of A2 in landscape mode (23-3/8 x 16-1/2).
	SizeA2Landscape = expr.SizeA2Landscape
	// SizeA2Portrait defines a render page size of A2 in portrait mode (16-1/2 x 23-3/8).
	SizeA2Portrait = expr.SizeA2Portrait
	// SizeA3Landscape defines a render page size of A3 in landscape mode (16-1/2 x 11-3/4).
	SizeA3Landscape = expr.SizeA3Landscape
	// SizeA3Portrait defines a render page size of A3 in portrait mode (11-3/4 x 16-1/2).
	SizeA3Portrait = expr.SizeA3Portrait
	// SizeA4Landscape defines a render page size of A4 in landscape mode (11-3/4 x 8-1/4).
	SizeA4Landscape = expr.SizeA4Landscape
	// SizeA4Portrait defines a render page size of A4 in portrait mode (8-1/4 x 11-3/4).
	SizeA4Portrait = expr.SizeA4Portrait
	// SizeA5Landscape defines a render page size of A5 in landscape mode (8-1/4  x 5-7/8).
	SizeA5Landscape = expr.SizeA5Landscape
	// SizeA5Portrait defines a render page size of A5 in portrait mode (5-7/8 x 8-1/4).
	SizeA5Portrait = expr.SizeA5Portrait
	// SizeA6Landscape defines a render page size of A6 in landscape mode (4-1/8 x 5-7/8).
	SizeA6Landscape = expr.SizeA6Landscape
	// SizeA6Portrait defines a render page size of A6 in portrait mode (5-7/8 x 4-1/8).
	SizeA6Portrait = expr.SizeA6Portrait
	// SizeLegalLandscape defines a render page size of Legal in landscape mode (14 x 8-1/2).
	SizeLegalLandscape = expr.SizeLegalLandscape
	// SizeLegalPortrait defines a render page size of Legal in portrait mode (8-1/2 x 14).
	SizeLegalPortrait = expr.SizeLegalPortrait
	// SizeLetterLandscape defines a render page size of Letter in landscape mode (11 x 8-1/2).
	SizeLetterLandscape = expr.SizeLetterLandscape
	// SizeLetterPortrait defines a render page size of Letter in portrait mode (8-1/2 x 11).
	SizeLetterPortrait = expr.SizeLetterPortrait
	// SizeSlide16X10 defines a render page size ratio of 16 x 10.
	SizeSlide16X10 = expr.SizeSlide16X10
	// SizeSlide16X9 defines a render page size ratio of 16 x 9.
	SizeSlide16X9 = expr.SizeSlide16X9
	// SizeSlide4X3 defines a render page size ratio of 4 x 3.
	SizeSlide4X3 = expr.SizeSlide4X3
)
View Source
const (
	// RoutingDirect draws straight lines between ends of relationships.
	RoutingDirect = expr.RoutingDirect
	// RoutingOrthogonal draws lines with right angles between ends of relationships.
	RoutingOrthogonal = expr.RoutingOrthogonal
	// RoutingCurved draws curved lines between ends of relationships.
	RoutingCurved = expr.RoutingCurved
)
View Source
const Global = 0

Global is the keyword used to define dynamic views with global scope. See DynamicView.

Variables

This section is empty.

Functions

func Add

func Add(element interface{}, dsl ...func())

Add adds a person or an element to a view.

Add must appear in SystemLandscapeView, SystemContextView, ContainerView or ComponentView.

Add takes a person, person name, element or element name as first argument. Add also accepts an optional function as last argument.

Add(PersonOrElement)

Add(PersonOrElement, func())

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Add(System, func() {
                Coord(10, 10)
                NoRelationships()
            })
        })
    })
})

func AddAll

func AddAll()

AddAll includes all elements and relationships in the view scope.

AddAll may appear in SystemLandscapeView, SystemContextView, ContainerView, ComponentView or DeploymentView.

AddAll takes no argument.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Person = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddAll()
        })
    })
})

func AddComponents

func AddComponents()

AddComponents includes all components in scope to the view.

AddComponents must appear in ComponentView.

AddComponents takes no argument

func AddContainers

func AddContainers()

AddContainers includes all containers in scope to the view.

AddContainers may appear in ContainerView or ComponentView.

AddContainers takes no argument.

func AddDefault

func AddDefault()

AddDefault adds default elements that are relevant for the specific view:

  • System landscape view: adds all software systems and people
  • System context view: adds softare system and other related software systems and people.
  • Container view: adds all containers in software system as well as related software systems and people.
  • Component view: adds all components in container as well as related containers, software systems and people.
  • Deployment view: adds all deployment nodes.

AddDefault must appear in SystemLandscapeView, SystemContextView, ContainerView or ComponentView.

AddDefault takes no argument.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddDefault()
        })
    })
})

func AddImpliedRelationships added in v0.0.2

func AddImpliedRelationships()

AddImpliedRelationships creates implied relationships between all valid combinations of parent elements, unless the same relationship already exists between them. For example if a model includes two containers with one component each and the DSL defines a relationship between the two components (Component 1 to Component 2) then AddImpliedRelationships would add the following relationships:

  • Component 1 to Container 2
  • Container 1 to Component 2
  • Container 1 to Container 2

AddImpliedRelationships must appear in Workspace.

func AddInfluencers

func AddInfluencers()

AddInfluencers adds all containers of the ContainerView as well as all external influencers, that is all persons and all other software systems with incoming or outgoing dependencies. Additionally, all relationships of external dependencies are omitted to keep the diagram clean.

AddInfluencers must appear in ContainerView.

AddInfluencers takes no argument.

func AddNeighbors

func AddNeighbors(element interface{})

AddNeighbors Adds all of the permitted elements which are directly connected to the specified element to the view. Permitted elements are software systems and people for system landscape and system context views, software systems, people and containers for container views and software system, people, containers and components for component views.

AddNeighbors must appear in SystemLandscapeView, SystemContextView, ContainerView or ComponentView.

AddNeighbors accept a single argument which is the element that should be added with its direct relationships. It must be a software system or person for system landscape and system context views, a software system, person or container for container views or a software system, person, container or component for component views.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddNeighbors(System)
            AddNeighbors(Customer)
        })
    })
})

func Animation

func Animation(args ...interface{})

Animation defines an animation step consisting of the specified elements.

Animation must appear in SystemLandscapeView, SystemContextView, ContainerView, ComponentView or DeploymentView.

Animation accepts one or more arguments. The arguments must all be an element (SoftwareSystem, Container, Component). The arguments may also be any of DeploymeNode, InfrastructureNode or ContainerInstance in DeploymentView.

Example

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var OtherSystem = SoftwareSystem("Other software System")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddDefault()
            Animation(OtherSystem, Customer) // First OtherSystem and Customer
            Animation(System)                // Then System
        })
    })
})

func AutoLayout

func AutoLayout(rank expr.RankDirectionKind, args ...func())

AutoLayout enables automatic layout mode for the diagram. The first argument indicates the rank direction, it must be one of RankTopBottom, RankBottomTop, RankLeftRight or RankRightLeft

AutoLayout must appear in SystemLandscapeView, SystemContextView, ContainerView, ComponentView, DynamicView or DeploymentView.

AutoLayout accepts one or two arguments: the layout rank direction and an optional function DSL that describes the layout properties.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var OtherSystem = SoftwareSystem("Other software System")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddDefault()
            AutoLayout(RankTopBottom, func() {
                RankSeparation(200)
                NodeSeparation(100)
                EdgeSeparation(10)
                Vertices()
            })
        })
    })
})

func Background

func Background(c string)

Background sets elements background color, default is #dddddd.

Background must appear in ElementStyle.

Background accepts a single argument: the background color encoded as HTML hex value (e.g. "#ffffff").

func Border added in v0.0.5

func Border(b expr.BorderKind)

Border sets elements border style, default is BorderSolid.

Border must appear in ElementStyle.

Border takes a single argument: one of BorderSolid, BorderDashed or BorderDotted.

func Color

func Color(c string)

Color sets elements text color, default is #000000.

Color must appear in ElementStyle or RelationshipStyle.

Color accepts a single argument: the color encoded as HTML hex value (e.g. "#ffffff").

func Component

func Component(name string, args ...interface{}) *expr.Component

Component defines a component.

Component must appear in a Container expression.

Component takes 1 to 4 arguments. The first argument is the component name. The name may be optionally followed by a description. If a description is set then it may be followed by the technology details used by the component. Finally Component may take a func() as last argument to define additional properties of the component.

The valid syntax for Component is thus:

Component("<name>")

Component("<name>", "[description]")

Component("<name>", "[description]", "[technology]")

Component("<name>", func())

Component("<name>", "[description]", func())

Component("<name>", "[description]", "[technology]", func())

Example:

var _ = Workspace(func() {
    SoftwareSystem("My system", "A system with a great architecture", func() {
        Container("My container", "A container with a great architecture", "Go and Goa", func() {
            Component(Container, "My component", "A component", "Go and Goa", func() {
                Tag("bill processing")
                URL("https://goa.design/mysystem")
                Uses("Other Component", "Uses", "gRPC", Synchronous)
                Delivers("Customer", "Delivers emails to", "SMTP", Synchronous)
            })
        })
    })
})

func ComponentView

func ComponentView(container interface{}, args ...interface{})

ComponentView defines a component view.

ComponentView must appear in Views.

ComponentView accepts 2 to 4 arguments: the first argument is the container or the name of the container being described by the component view. The second argument is an optional key for the view which can be used to reference it when creating a fltered views. The third argument is an optional description, the key must be provided when giving a description. The last argument is a function describing the properties of the view.

Valid usage of ComponentView are thus:

ComponentView(Container, func())

ComponentView(Container, "[key]", func())

ComponentView(Container, "[key]", "[description]", func())

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.", func() {
        Container("Container")
    })
    Views(func() {
        ComponentView("Container", "component", "An overview diagram.", func() {
            Title("Overview of container")
            AddAll()
            Remove(Component3)
            AutoLayout()
            Animation(Component1, Component2)
            PaperSize(SizeSlide4X3)
            ContainerBoundariesVisible()
        })
    })
})

func Container

func Container(args ...interface{}) *expr.Container

Container defines a container.

Container must appear in a SoftwareSystem expression.

Container takes 1 to 4 arguments. The first argument is the container name. The name may be optionally followed by a description. If a description is set then it may be followed by the technology details used by the container. Finally Container may take a func() as last argument to define additional properties of the container.

The valid syntax for Container is thus:

Container("<name>")

Container("<name>", "[description]")

Container("<name>", "[description]", "[technology]")

Container("<name>", func())

Container("<name>", "[description]", func())

Container("<name>", "[description]", "[technology]", func())

Container also accepts a Goa service as argument in which case the name and description are taken from the service and the technology is set to "Go and Goa v3"

Container(Service)

Container(Service, func())

Example:

var _ = Workspace(func() {
    SoftwareSystem("My system", "A system with a great architecture", func() {
        Container("My service", "A service", "Go and Goa", func() {
            Tag("bill processing")
            URL("https://goa.design/mysystem")
            Uses("Other Container", "Uses", "gRPC", Synchronous)
            Delivers("Customer", "Delivers emails to", "SMTP", Synchronous)
        })

        // Alternate syntax using a Goa service.
        Container(Service, func() {
            // ...
        })
    })
})

func ContainerBoundariesVisible

func ContainerBoundariesVisible()

ContainerBoundariesVisible makes the enterprise boundary visible to differentiate internal elements from external elements on the resulting diagram.

ContainerBoundariesVisible must appear in ComponentView.

ContainerBoundariesVisible takes no argument

func ContainerInstance

func ContainerInstance(container interface{}, dsl ...func()) *expr.ContainerInstance

ContainerInstance defines an instance of the specified container that is deployed on the parent deployment node.

ContainerInstance must appear in a DeploymentNode expression.

ContainerInstance takes three arguments: the container instance name used to refer to it in deployment views, the container or its name and an optional func() that defines additional properties on the container instance.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        DeploymentNode("US", "US shard", func() {
            ContainerInstance(Container, func() {
                RefName("instance")
                Tag("service")
                InstanceID(1)
                HealthCheck("check", func() {
                    URL("https://goa.design/health")
                    Interval(10)
                    Timeout(1000)
                })
            })
        })
    })
})

func ContainerView

func ContainerView(system interface{}, args ...interface{})

ContainerView defines a container view.

ContainerView must appear in Views.

ContainerView accepts 2 to 4 arguments: the first argument is the software system or the name of the software system the container view applies to. The second argumetn is an optional key for the view which can be used to reference it when creating a fltered views. The third argument is an optional description, the key must be provided when giving a description. The last argument is a function describing the properties of the view.

Valid usage of ContainerView are thus:

ContainerView(SoftwareSystem, func())

ContainerView(SoftwareSystem, "[key]", func())

ContainerView(SoftwareSystem, "[key]", "[description]", func())

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        ContainerView(SoftwareSystem, "container", "An overview diagram.", func() {
            Title("System containers")
            AddAll()
            Remove(Container3)
            // Alternatively to AddAll + Remove: Add
            AutoLayout()
            Animation(Container1, Container2)
            PaperSize(SizeSlide4X3)
            SystemBoundariesVisible()
        })
    })
})

func Coord

func Coord(x, y int)

Coord defines explicit coordinates for where to render a person or element.

Coord must appear in Add.

Coord takes two arguments: the X and Y where the person or element is rendered.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var OtherSystem = SoftwareSystem("Other software System")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Add(Customer, func() {
                Coord(200,200)
            })
        })
    })
})

func Delivers

func Delivers(p interface{}, desc string, args ...interface{})

Delivers adds an interaction between an element and a person.

Delivers must appear in SoftareSystem, Container or Component.

Delivers accepts 2 to 5 arguments. The first argument is the target of the relationship, it must be a person or the name of a person. The target may optionally be followed by a short description of the relationship. The description may optionally be followed by the technology used by the relationship and/or the type of relationship: Synchronous or Asynchronous. Finally Delivers accepts an optional func() as last argument to add further properties to the relationship.

Usage is thus:

Delivers(Person, "<description>")

Delivers(Person, "<description>", "[technology]")

Delivers(Person, "<description>", Synchronous|Asynchronous)

Delivers(Person, "<description>", "[technology]", Synchronous|Asynchronous)

Delivers(Person, "<description>", func())

Delivers(Person, "<description>", "[technology]", func())

Delivers(Person, "<description>", Synchronous|Asynchronous, func())

Delivers(Person, "<description>", "[technology]", Synchronous|Asynchronous, func())

Example:

var _ = Workspace("my workspace", "a great architecture model", func() {
    var Customer = Person("Customer")
    SoftwareSystem("MySystem", func () {
       Delivers(Customer, "Sends requests to", "email")
    })
})

func DeploymentEnvironment

func DeploymentEnvironment(name string, dsl func())

DeploymentEnvironment defines a deployment environment (e.g. development, production).

DeploymentEnvironment must appear in a Workspace expression.

DeploymentEnvironment accepts two arguments: the environment name and a DSL function used to describe the nodes within the environment.

Example:

var _ = Workspace(func() {
     DeploymentEnvironment("production", func() {
         DeploymentNode("AppServer", "Application server", "Go and Goa v3")
         InfrastructureNote("Router", "External traffic router", "AWS Route 53")
         ContainerInstance(Container)
     })
 })

func DeploymentNode

func DeploymentNode(name string, args ...interface{}) *expr.DeploymentNode

DeploymentNode defines a deployment node. Deployment nodes can be nested, so a deployment node can contain other deployment nodes. A deployment node can also contain InfrastructureNode and ContainerInstance elements.

DeploymentNode must appear in a DeploymentEnvironment or DeploymentNode expression.

DeploymentNode takes 1 to 4 arguments. The first argument is the node name. The name may be optionally followed by a description. If a description is set then it may be followed by the technology details used by the component. Finally DeploymentNode may take a func() as last argument to define additional properties of the component.

The valid syntax for DeploymentNode is thus:

DeploymentNode("<name>")

DeploymentNode("<name>", "[description]")

DeploymentNode("<name>", "[description]", "[technology]")

DeploymentNode("<name>", func())

DeploymentNode("<name>", "[description]", func())

DeploymentNode("<name>", "[description]", "[technology]", func())

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        DeploymentNode("US", "US shard", func() {
            Tag("shard")
            Instances(3)
            URL("https://goa.design/docs/shard")
            InfrastructureNode("Gateway", "US gateway", func() {
                Tag("gateway")
                URL("https://goa.design/docs/shards/us")
            })
            ContainerInstance(func() {
                Tag("service")
                InstanceID(1)
                HealthCheck("check", func() {
                    URL("https://goa.design/health")
                    Interval(10)
                    Timeout(1000)
                })
            })
            DeploymentNode("Cluster", "K8 cluster", func() {
                // ...
            })
        })
    })
})

func DeploymentView

func DeploymentView(scope interface{}, env string, args ...interface{})

DeploymentView defines a Deployment view for the specified scope and deployment environment. The first argument defines the scope of the view, and the second argument defines the deployment environment. The combination of these two arguments determines what can be added to the view, as follows:

  • Global scope: All deployment nodes, infrastructure nodes, and container instances within the deployment environment.
  • Software system scope: All deployment nodes and infrastructure nodes within the deployment environment. Container instances within the deployment environment that belong to the software system.

DeploymentView must appear in Views.

DeploymentView accepts 3 to 5 arguments: the first argument is the scope: either the keyword 'Global' or a software system. The second argument is the name of the environment. The third argument is an optional key for the view. The fourth argument is an optional description, the key must be provided when giving a description. The last argument is a function describing the properties of the view.

Valid usage of DeploymentView are thus:

DeploymentView(Scope, "<environment>", func())

DeploymentView(Scope, "<environment>", "[key]", func())

DeploymentView(Scope, "<environment>", "[key]", "[description]", func())

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        DeploymentView(Global, "Production", "deployment", "A deployment overview diagram.", func() {
            Title("Overview of deployment")
            AddAll()
            Remove(Container3)
            AutoLayout()
            Animation(Container1, Container2)
            PaperSize(SizeSlide4X3)
        })
    })
})

func Description added in v0.0.2

func Description(desc string)

Description provides a short description for a relationship displayed in a dynamic view.

Description must appear in Add.

Description takes one argument: the relationship description used in the dynamic view.

func DynamicView

func DynamicView(scope interface{}, args ...interface{})

DynamicView defines a Dynamic view for the specified scope. The first argument defines the scope of the view, and therefore what can be added to the view, as follows:

  • Global scope: People and software systems.
  • Software system scope: People, other software systems, and containers belonging to the software system.
  • Container scope: People, other software systems, other containers, and components belonging to the container.

DynamicView must appear in Views.

DynamicView accepts 2 to 4 arguments: the first argument is the scope: either the keyword 'Global', a software system, the name of a software system, a container or the name of a container. The second argument is an optional key for the view. The third argument is an optional description, the key must be provided when giving a description. The last argument is a function describing the properties of the view.

A dynamic view is created by specifying relationships that should be rendered. See Relationship for additional information.

Valid usage of DynamicView are thus:

DynamicView(Scope, func())

DynamicView(Scope, "[key]", func())

DynamicView(Scope, "[key]", "[description]", func())

Example:

var _ = Workspace(func() {
    var FirstSystem = SoftwareSystem("First system")
    var SecondSystem = SoftwareSystem("Second system", func() {
        Uses(FirstSystem, "Uses")
    })
    Views(func() {
        DynamicView(Global, "dynamic", "A dynamic diagram.", func() {
            Title("Overview of system")
            AutoLayout()
            PaperSize(SizeSlide4X3)
            Relationship(SecondSystem, FirstSystem)
        })
    })
})

func EdgeSeparation

func EdgeSeparation(s int)

EdgeSeparation sets the separation between edges in pixels, defaults to 200.

EdgeSeparation must appear in AutoLayout.

EdgeSeparation takes one argument: the edge separation in pixels.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AutoLayout(func() {
                EdgeSeparation(500)
            })
        })
    })
})

func ElementStyle

func ElementStyle(tag string, dsl func())

ElementStyle defines element styles.

ElementStyle must appear in Styles.

ElementStyle accepts two arguments: the tag that identifies the elements that the style should be applied to and a function describing the style properties.

Example:

var _ = Workspace(func() {
    // ...
    Views(func() {
        // ...
        Styles(func() {
            ElementStyle("default", func() {
                Shape(ShapeBox)
                Icon("https://goa.design/goa-logo.png")
                Width(300)
                Height(450)
                Background("#dddddd")
                Color("#000000")
                Stroke("#000000")
                FontSize(24)
                Border(BorderSolid)
                Opacity(100)
                ShowMetadata()
                ShowDescription()
            })
        })
    })
})

func Enterprise

func Enterprise(e string)

Enterprise defines a named "enterprise" (e.g. an organisation). On System Landscape and System Context diagrams, an enterprise is represented as a dashed box. Only a single enterprise can be defined within a model.

Enterprise must appear in a Workspace expression.

Enterprise takes exactly one argument: the enterprise name.

Example:

var _ = Workspace(func() {
    Enterprise("Goa Design")
})

func EnterpriseBoundaryVisible

func EnterpriseBoundaryVisible()

EnterpriseBoundaryVisible makes the enterprise boundary visible to differentiate internal elements from external elements on the resulting diagram.

EnterpriseBoundaryVisible must appear in SystemLandscapeView or SystemContextView.

EnterpriseBoundaryVisible takes no argument

func External

func External()

External indicates the element is external to the enterprise.

External may appear in Person or SoftwareSystem.

Example:

var _ = Workspace(func() {
    System("My system", func() {
        External()
    })
})

func FilteredView

func FilteredView(view interface{}, dsl func())

FilteredView defines a filtered view on top of the specified view. The base key specifies the key of the System Landscape, System Context, Container, or Component view on which this filtered view should be based.

FilteredView must appear in Views.

FilteredView accepts 2 arguments: the view being filtered and a function describing additional properties.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddAll()
            AutoLayout()
        })
        FilteredView(SystemContextView, func() {
            FilterTag("infra")
            Exclude()
        })
    })
})

func FontSize

func FontSize(s int)

FontSize sets elements or relationships text font size, default is 24.

FontSize must appear in ElementStyle or RelationshipStyle.

FontSize accepts a single argument: the size of the font in pixels.

func Header(n, v string)

Header defines a header name and value to be set in requests sent for health checks.

Header must appear in a HealthCheck expression.

Header takes two arguments: the header name and value.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        ContainerInstance(Container, func() {
            HealthCheck("check", func() {
                Header("X-Foo", "bar")
            })
        })
    })
})

func HealthCheck

func HealthCheck(name string, dsl func())

HealthCheck defines a HTTP-based health check for a container instance.

HealthCheck must appear in a ContainerInstance expression.

HealthCheck accepts two arguments: the health check name and a function used to define additional required properties.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        ContainerInstance(Container, func() {
            HealthCheck("check", func() {
                URL("https://goa.design/health")
                Interval(10)
                Timeout(1000)
                Header("X-Foo", "bar")
            })
        })
    })
})

func Height

func Height(h int)

Height sets elements height, default is 300.

Height must appear in ElementStyle.

Height accepts a single argument: the height in pixel.

func Icon

func Icon(file string)

Icon sets elements icon by URL or data URI (https://css-tricks.com/data-uris/).

Tip: Generating icons programatically can be done using the "image" package (to draw the image), "image/png" to render the image and "encoding/base64" to encode the result into a data URI.

See https://structurizr.com/help/icons.

func InfrastructureNode

func InfrastructureNode(name string, args ...interface{}) *expr.InfrastructureNode

InfrastructureNode defines an infrastructure node, typically something like a load balancer, firewall, DNS service, etc.

InfrastructureNode must appear in a DeploymentNode expression.

InfrastructureNode takes 1 to 4 arguments. The first argument is the infrastructure node name. The name may be optionally followed by a description. If a description is set then it may be followed by the technology details used by the component. Finally InfrastructureNode may take a func() as last argument to define additional properties of the component.

The valid syntax for InfrastructureNode is thus:

InfrastructureNode("<name>")

InfrastructureNode("<name>", "[description]")

InfrastructureNode("<name>", "[description]", "[technology]")

InfrastructureNode("<name>", func())

InfrastructureNode("<name>", "[description]", func())

InfrastructureNode("<name>", "[description]", "[technology]", func())

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        DeploymentNode("US", "US shard", func() {
            InfrastructureNode("Gateway", "US gateway", func() {
                Tag("gateway")
                URL("https://goa.design/docs/shards/us")
            })
        })
    })
})

func InstanceID

func InstanceID(n int)

InstanceID sets the instance number or index of a container instance.

InstanceID must appear in a ContainerInstance expression.

InstanceID accepts a single argument which is the number.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        ContainerInstance(Container, func() {
            InstanceID(3)
        })
    })
})

func Instances

func Instances(n int)

Instances sets the number of instances of the deployment node.

Instances must appear in a DeploymentNode expression.

Instances accepts a single argument which is the number.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        DeploymentNode("Web app", func() {
            Instances(3)
        })
    })
})

func InteractsWith

func InteractsWith(p interface{}, desc string, args ...interface{})

InteractsWith adds an interaction between a person and another.

InteractsWith must appear in Person.

InteractsWith accepts 2 to 5 arguments. The first argument is the target of the relationship, it must be a person or the name of a person. The target may optionally be followed by a short description of the relationship. The description may optionally be followed by the technology used by the relationship and/or the type of relationship: Synchronous or Asynchronous. Finally InteractsWith accepts an optional func() as last argument to add further properties to the relationship.

Usage is thus:

InteractsWith(Person, "<description>")

InteractsWith(Person, "<description>", "[technology]")

InteractsWith(Person, "<description>", Synchronous|Asynchronous)

InteractsWith(Person, "<description>", "[technology]", Synchronous|Asynchronous)

InteractsWith(Person, "<description>", func())

InteractsWith(Person, "<description>", "[technology]", func())

InteractsWith(Person, "<description>", Synchronous|Asynchronous, func())

InteractsWith(Person, "<description>", "[technology]", Synchronous|Asynchronous, func())

Example:

var _ = Workspace("my workspace", "a great architecture model", func() {
    var Employee = Person("Employee")
    Person("Customer", "Customers of enterprise", func () {
       InteractsWith(Employee, "Sends requests to", "email")
    })
})

func Interval

func Interval(n int)

Interval defines a health check polling interval in seconds.

Interval must appear in a HealthCheck expression.

Interval takes one argument: the number of seconds.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        ContainerInstance(Container, func() {
            HealthCheck("check", func() {
                Interval(10)
            })
        })
    })
})
func Link(source, destination interface{}, dsl ...func())

Link adds a relationship to a view.

Link must appear in SystemLandscapeView, SystemContextView, ContainerView, ComponentView or DynamicView.

Link takes the relationship (as defined by the source and destination or their names) as first argument and an optional function as last argument.

Add(Source, Destination)

Add(Source, Destination, func())

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Person = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Add(System, func() {
                Coord(10, 10)
                NoRelationships()
            })
            Link(Person, System, func() {
                Vertices(10, 20, 10, 40)
                Routing(RoutingOrthogonal)
                Position(45)
            })
        })
        DynamicView(SoftwareSystem, "dynamic", func() {
            Title("Customer flow")
            Link(Person, System, func() {
                Vertices(10, 20, 10, 40)
                Routing(RoutingOrthogonal)
                Position(45)
                Description("Customer sends email to support")
                Order("1")
            })
        })
    })
})

func NoRelationship

func NoRelationship()

NoRelationship indicates that no relationship should be rendered to and from the person or element.

NoRelationship must appear in Add.

NoRelationship takes no argument.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var OtherSystem = SoftwareSystem("Other software System")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Add(Customer, func() {
                NoRelationship()
            })
        })
    })
})

func NodeSeparation

func NodeSeparation(s int)

NodeSeparation sets the separation between nodes in pixels, defaults to 600.

NodeSeparation must appear in AutoLayout.

NodeSeparation takes one argument: the node separation in pixels.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AutoLayout(func() {
                NodeSeparation(500)
            })
        })
    })
})

func Opacity

func Opacity(o int)

Opacity sets elements or relationships opacity, default is 100.

Opacity must appear in ElementStyle or RelationshipStyle.

Opacity accepts a single argument: the opacity value between 0 (transparent) and 100 (opaque).

func PaperSize

func PaperSize(size expr.PaperSizeKind)

PaperSize defines the paper size that should be used to render the view.

PaperSize must appear in SystemLandscapeView, SystemContextView, ContainerView, ComponentView, DynamicView or DeploymentView.

PaperSize accepts a single argument: the paper size. The possible values for the argument follow the patterns SizeA[0-6][Portrait|Landscape], SizeLetter[Portrait|Landscape] or SizeLegal[Portrait_Landscape]. Alternatively the argument may be one of SizeSlide4X3, SizeSlide16X9 or SizeSlide16X10.

Example

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var OtherSystem = SoftwareSystem("Other software System")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddDefault()
            PaperSize(SizeSlide4X3)
        })
    })
})

func Person

func Person(name string, args ...interface{}) *expr.Person

Person defines a person (user, actor, role or persona).

Person must appear in a Model expression.

Person takes one to three arguments. The first argument is the name of the person. An optional description may be passed as second argument. The last argument may be a function that defines tags associated with the Person.

The valid syntax for Person is thus:

Person("name")

Person("name", "description")

Person("name", func())

Person("name", "description", func())

Example:

var _ = Workspace(func() {
    Person("Employee")
    Person("Customer", "A customer", func() {
        Tag("system")
        External()
        URL("https://acme.com/docs/customer.html")
        Uses(System)
        InteractsWith(Employee)
    })
})

func Position

func Position(p int)

Position sets the position of a relationship annotation along the line.

Position must appear in a Add expression that adds a relationship or in RelationshipStyle.

Position takes one argument: the position value between 0 (start of line) and 100 (end of line).

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Add(Customer, System, func() {
                Position(40)
            })
        })
    })
})

func Prop

func Prop(name, value string)

Prop defines arbitrary key-value pairs. They are shown in the diagram tooltip and can be used to store metadata (e.g. team name).

Prop must appear in Person, SoftwareSystem, Container, Component, DeploymentNode, InfrastructureNode or ContainerInstance.

Prop accepts two arguments: the name and value of a property.

Example:

var _ = Workspace(func() {
    SoftwareSystem("MySystem", func() {
       Prop("name", "value")
    })
})

func RankSeparation

func RankSeparation(s int)

RankSeparation sets the separation between ranks in pixels, defaults to 300.

RankSeparation must appear in AutoLayout.

RankSeparation takes one argument: the rank separation in pixels.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AutoLayout(func() {
                RankSeparation(500)
            })
        })
    })
})

func RefName added in v0.0.2

func RefName(name string)

RefName provides a name to a container instance that can be used to reference it in deployment views (as an alternative to using a variable).

RefName must appear in a ContainerInstance expression.

RefName accepts a single argument which is the name that can be used to reference the container instance.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        DeploymentNode("US", "US shard", func() {
            ContainerInstance("container", func() {
                RefName("instance")
            })
        })
    })
})

func RelationshipStyle

func RelationshipStyle(tag string, dsl func())

RelationshipStyle defines relationship styles.

RelationshipStyle must appear in Styles.

RelationshipStyle accepts two arguments: the tag that identifies the relationships that the style should be applied to and a function describing the style properties.

Example:

var _ = Workspace(func() {
    // ...
    Views(func() {
        // ...
        Styles(func() {
            RelationshipStyle("default", func() {
                Thickness(2)
                Color("#000000")
                Solid()
                Routing(RoutingOrthogonal)
                FontSize(24)
                Width(300)
                Position(50)
                Opacity(100)
            })
        })
    })
})

func Remove

func Remove(e interface{}, dest ...interface{})

Remove given person, element or relationship from view. Alternatively remove all persons, elements and relationships tagged with the given tag.

Remove must appear in SystemLandscapeView, SystemContextView, ContainerView or ComponentView.

Remove takes one or two argument: the first argument must be a person, an element or a tag value. The second argument is needed when removing relationships and indicates the destination of the relationship (the first argument is the source in this case).

Usage:

Remove(PersonOrElement)

Remove(Source, Destination)

Remove("<tag>")

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Container(System, "Unwanted", func() {
        Tag("irrelevant")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddDefault()
            Remove(Customer)
            Remove(Customer, System)
            Remove("irrelevant")
        })
    })
})

func RemoveUnreachable

func RemoveUnreachable(e interface{})

RemoveUnreachable removes all elements and people that cannot be reached by traversing the graph of relationships starting with the given element or person.

RemoveUnreachable must appear in SystemLandscapeView, SystemContextView, ContainerView or ComponentView.

RemoveUnreachable takes one argument: the person or element from which the graph traversal should be initiated.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var OtherSystem = SoftwareSystem("Other software System")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddDefault()
            RemoveUnreachable(System) // Removes OtherSystem
        })
    })
})

func RemoveUnrelated

func RemoveUnrelated()

RemoveUnrelated removes all elements that have no relationship to other elements in the view.

RemoveUnrelated must appear in SystemLandscapeView, SystemContextView, ContainerView or ComponentView.

RemoveUnrelated takes no argument.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var OtherSystem = SoftwareSystem("Other software System")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AddDefault()
            RemoveUnrelated()) // Removes OtherSystem
        })
    })
})

func RenderVertices

func RenderVertices()

RenderVertices indicates that vertices should be created during automatic layout, false by default.

RenderVertices must appear in AutoLayout.

RenderVertices takes no argument.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            AutoLayout(func() {
                RenderVertices()
            })
        })
    })
})

func Revision added in v0.0.7

func Revision(r int)

Revision specifies a revision number for the workspace. The revision number enforces a sequence with workspace updates. Updating a workspace requires incrementing the revision number which helps alleviate the risk for concurrent uploads clobbering each other.

Revision must appear in a Workspace expression.

Revision takes exactly one argument: the revision number.

Example:

var _ = Workspace(func() {
    Revision(2)
})

func Routing

func Routing(k expr.RoutingKind)

Routing algorithm used when rendering relationship, defaults to RoutingDirect.

Routing must appear in a Add expression that adds a relationship or in a RelationshipStyle expression.

Routing takes one argument: one of RoutingDirect, RoutingCurved or RoutingOrthogonal.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Add(Customer, System, func() {
                Routing(RoutingDirect)
            })
        })
    })
})

func Shape

func Shape(s expr.ShapeKind)

Shape defines element shapes, default is ShapeBox.

Shape must apear in ElementStyle.

Shape accepts one argument, one of: ShapeBox, ShapeRoundedBox, ShapeCircle, ShapeEllipse, ShapeHexagon, ShapeCylinder, ShapePipe, ShapePerson ShapeRobot, ShapeFolder, ShapeWebBrowser, ShapeMobileDevicePortrait, ShapeMobileDeviceLandscape or ShapeComponent.

See https://structurizr.com/help/shapes.

func ShowDescription

func ShowDescription()

ShowDescription shows the elements description.

ShowDescription must appear in ElementStyle.

ShowDescription takes no argument.

func ShowMetadata

func ShowMetadata()

ShowMetadata shows the elements metadata.

ShowMetadata must appear in ElementStyle.

ShowMetadata takes no argument.

func SoftwareSystem

func SoftwareSystem(name string, args ...interface{}) *expr.SoftwareSystem

SoftwareSystem defines a software system.

SoftwareSystem must appear in a Workspace expression.

Software system takes 1 to 3 arguments. The first argument is the software system name and the last argument a function that contains the expressions that defines the content of the system. An optional description may be given after the name.

The valid syntax for SoftwareSystem is thus:

SoftwareSystem("<name>")

SoftwareSystem("<name>", "[description]")

SoftwareSystem("<name>", func())

SoftwareSystem("<name>", "[description]", func())

Example:

var _ = Workspace(func() {
    SoftwareSystem("My system", "A system with a great architecture", func() {
        Tag("bill processing")
        URL("https://goa.design/mysystem")
        External()
        Uses("Other System", "Uses", "gRPC", Synchronous)
        Delivers("Customer", "Delivers emails to", "SMTP", Synchronous)
    })
})

func Solid added in v0.0.12

func Solid()

Solid makes relationship lines solid (non-dashed).

Solid must appear in RelationshipStyle.

Solid takes no argument.

func Stroke

func Stroke(c string)

Stroke sets elements stroke color.

Stroke must appear in ElementStyle.

Stroke accepts a single argument: the background color encoded as HTML hex value (e.g. "#ffffff").

func Styles

func Styles(dsl func())

Styles is a wrapper for one or more element/relationship styles, which are used when rendering diagrams.

Styles must appear in Views.

Styles accepts a single argument: a function that defines the styles.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "Great system.", func() {
        Tag("blue")
    })

    var User = Person("User", "A user of my software system.", func() {
        Tag("blue", "person")
        Uses(System, "Uses", func() {
            Tag("client")
        })
    })

    Views(func() {
        SystemContext(MySystem, "SystemContext", "Context diagram.", func() {
            AddAll()
            AutoLayout(RankTopBottom)
        })
        Styles(func() {
            ElementStyle("blue", func() {
                Background("#1168bd")
                Color("#3333ee")
             })
            ElementStyle("person", func() {
                Shape("ShapePerson")
            })
            RelationshipStyle("client", func() {
                Routing(RoutingCurved)
                Thickness(42)
            })
        })
    })
})

func SystemBoundariesVisible

func SystemBoundariesVisible()

SystemBoundariesVisible makes the system boundaries visible for "external" containers (those outside the software system in scope)

SystemBoundariesVisible must appear in ContainerView.

SystemBoundariesVisible takes no argument

func SystemContextView

func SystemContextView(system interface{}, args ...interface{})

SystemContextView defines a system context view.

SystemContextView must appear in Views.

SystemContextView accepts 2 to 4 arguments: the first argument is the system or the name of the system the view applies to. The second argument is an optional key for the view which can be used to reference it when creating a fltered views. The third argument is an optional description, the key must be provided when giving a description. The last argument is a function describing the properties of the view.

Valid usage of SystemContextView are thus:

SystemContextView(SoftwareSystem, func())

SystemContextView(SoftwareSystem, "[key]", func())

SystemContextView(SoftwareSystem, "[key]", "[description]", func())

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Title("Overview of system")
            AddAll()
            Remove(Container3)
            AutoLayout()
            Animation(Container1, Container2)
            PaperSize(SizeSlide4X3)
            EnterpriseBoundaryVisible()
        })
    })
})

func SystemLandscapeView

func SystemLandscapeView(args ...interface{})

SystemLandscapeView defines a system landscape view.

SystemLandscapeView must appear in Views.

SystemLandscapeView accepts 1 to 3 arguments: the first argument is an optional key for the view which can be used to reference it when creating a fltered views. The second argument is an optional description, the key must be provided when giving a description. The last argument is a function describing the properties of the view.

Valid usage of SystemLandscapeView are thus:

SystemLandscapeView(func())

SystemLandscapeView("[key]", func())

SystemLandscapeView("[key]", "[description]", func())

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemLandscapeView("landscape", "An overview diagram.", func() {
            Title("Overview of system")
            AddAll()
            Remove(Container3)
            AutoLayout()
            Animation(Container1, Container2)
            PaperSize(SizeSlide4X3)
            EnterpriseBoundaryVisible()
        })
    })
})

func Tag

func Tag(first string, t ...string)

Tag defines a set of tags on the given element. Tags are used in views to identify group of elements that should be rendered together for example.

Tag may appear in Person, SoftwareSystem, Container, Component, DeploymentNode, InfrastructureNode, ContainerInstance.

Tag accepts the set of tag values as argument. Tag may appear multiple times in the same expression in which case the tags accumulate.

Example:

var _ = Workspace(func() {
    System("My system", func() {
        Tag("sharded", "critical")
        Tag("blue team")
     })
})

func Thickness

func Thickness(t int)

Thickness sets relationships thickness.

Thickness must appear in RelationshipStyle.

Thickness takes one argument: the thickness in pixels.

func Timeout

func Timeout(n int)

Timeout defines a health check timeout in milliseconds.

Timeout must appear in a HealthCheck expression.

Timeout takes one argument: the number of milliseconds.

Example:

var _ = Workspace(func() {
    DeploymentEnvironment("Production", func() {
        ContainerInstance(Container, func() {
            HealthCheck("check", func() {
                Timeout(1000)
            })
        })
    })
})

func Title

func Title(t string)

Title sets the view diagram title.

Title may appear in SystemLandscapeView, SystemContextView, ContainerView, ComponentView, DynamicView or DeploymentView.

Title accepts one argument: the view title.

func URL

func URL(u string)

URL where more information about this element can be found. Or URL of health check when used within a HealthCheck expression.

URL may appear in Person, SoftwareSystem, Container, Component, DeploymentNode, InfrastructureNode or HealthCheck.

URL takes exactly one argument: a valid URL.

Example:

var _ = Workspace(func() {
    System("My system", func() {
        URL("https://goa.design/docs/mysystem")
    })
})

func Uses

func Uses(element interface{}, desc string, args ...interface{})

Uses adds a uni-directional relationship between two elements.

Uses may appear in Person, SoftwareSystem, Container or Component.

Uses tags 2 to 5 arguments. The first argument is the target of the relationship, it must be a software system, container, component or the name of one of these. The second argument is a short description for the relationship. The description may optionally be followed by the technology used by the relationship and/or the type of relationship: Synchronous or Asynchronous. Finally Uses accepts an optional func() as last argument to define additional properties on the relationship.

Usage is thus:

Uses(Element, "<description>")

Uses(Element, "<description>", "[technology]")

Uses(Element, "<description>", Synchronous|Asynchronous)

Uses(Element, "<description>", "[technology]", Synchronous|Asynchronous)

Uses(Element, "<description>", func())

Uses(Element, "<description>", "[technology]", func())

Uses(Element, "<description>", Synchronous|Asynchronous, func())

Uses(Element, "<description>", "[technology]", Synchronous|Asynchronous, func())

Example:

var _ = Workspace("my workspace", "a great architecture model", func() {
    var MySystem = SoftwareSystem("My system")
    Person("Customer", "Customers of enterprise", func () {
       Uses(MySystem, "Access", "HTTP", Synchronous)
    })
    Person("Staff", "Back office staff", func() {
       InteractsWith("Customer", "Sends invoices to", Synchronous)
    })
})

func Version

func Version(v string)

Version specifies a version number for the workspace. The version number is shown in the Structurizr UI but has otherwise no effect on the model.

Version must appear in a Workspace expression.

Version takes exactly one argument: the version number.

Example:

var _ = Workspace(func() {
    Version("1.0")
})

func Vertices

func Vertices(args ...int)

Vertices lists the x and y coordinate of the vertices used to render the relationship.

Vertices must appear in Add when adding relationships.

Vertices takes the x and y coordinates of the vertices as argument. The number of arguments must be even.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    var Customer = Person("Customer", func() {
        External()
        Uses(System, "Sends emails", "SMTP")
    })
    Views(func() {
        SystemContextView(SoftwareSystem, "context", "An overview diagram.", func() {
            Add(Customer, System, func() {
                Vertices(300, 100, 400, 200)
            })
        })
    })
})

func Views

func Views(dsl func())

Views defines one or more views.

Views takes one argument: the function that defines the views.

Views must appear in Workspace.

Example:

var _ = Workspace(func() {
    var System = SoftwareSystem("Software System", "My software system.")
    Views(func() {
        SystemContext(MySystem, "SystemContext", "An example of a System Context diagram.", func() {
            AddAll()
            AutoLayout()
        })
    })
})

func Width

func Width(w int)

Width sets elements or a relationships width, default is 450.

Width must appear in ElementStyle or RelationshipStyle.

Width accepts a single argument: the width in pixel.

func Workspace

func Workspace(args ...interface{}) *expr.Workspace

Workspace defines the workspace containing the models and views. Workspace must appear exactly once in a given design. A name must be provided if a description is.

Workspace is a top-level DSL function.

Workspace takes one to three arguments. The first argument is either a string or a function. If the first argument is a string then an optional description may be passed as second argument. The last argument must be a function that defines the models and views.

The valid syntax for Workspace is thus:

Workspace(func())

Workspace("name", func())

Workspace("name", "description", func())

Examples:

// Default workspace, no description
var _ = Workspace(func() {
    SoftwareSystem("My Software System")
})

// Workspace with given name, no description
var _ = Workspace("name", func() {
    SoftwareSystem("My Software System")
})

// Workspace with given name and description
var _ = Workspace("My Workspace", "A great architecture.", func() {
    SoftwareSystem("My Software System")
})

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL