styles.addElementStyle("Box").shape(Shape.Box); styles.addElementStyle("RoundedBox").shape(Shape.RoundedBox); styles.addElementStyle("Ellipse").shape(Shape.Ellipse); styles.addElementStyle("Circle").shape(Shape.Circle); styles.addElementStyle("Cylinder").shape(Shape.Cylinder); styles.addElementStyle("Web Browser").shape(Shape.WebBrowser); styles.addElementStyle("Mobile Device Portrait").shape(Shape.MobileDevicePortrait).width(400).height(650); styles.addElementStyle("Mobile Device Landscape").shape(Shape.MobileDeviceLandscape); styles.addElementStyle("Pipe").shape(Shape.Pipe); styles.addElementStyle("Folder").shape(Shape.Folder); styles.addElementStyle("Hexagon").shape(Shape.Hexagon); styles.addElementStyle("Robot").shape(Shape.Robot).width(550); styles.addElementStyle("Person").shape(Shape.Person).width(550);
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
public ElementStyle findElementStyle(Element element) { ElementStyle style = new ElementStyle("").background("#dddddd").color("#000000").shape(Shape.Box); if (element != null) { for (String tag : element.getTagsAsSet()) { ElementStyle elementStyle = findElementStyle(tag); if (elementStyle != null) { if (elementStyle.getBackground() != null && elementStyle.getBackground().trim().length() > 0) { style.setBackground(elementStyle.getBackground()); } if (elementStyle.getColor() != null && elementStyle.getColor().trim().length() > 0) { style.setColor(elementStyle.getColor()); } if (elementStyle.getShape() != null) { style.setShape(elementStyle.getShape()); } } } } return style; }
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
styles.addElementStyle(Tags.PERSON).background("#519823").color("#ffffff").shape(Shape.Person); styles.addElementStyle(Tags.CONTAINER).background("#91D366").color("#ffffff"); styles.addElementStyle("Database").shape(Shape.Cylinder); styles.addElementStyle("Spring MVC Controller").background("#D4F3C0").color("#000000"); styles.addElementStyle("Spring Service").background("#6CB33E").color("#000000");
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); ViewSet views = workspace.getViews(); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#08427b").color("#ffffff").shape(Shape.Person); PlantUMLWriter plantUMLWriter = new PlantUMLWriter(); // if you're using dark background colours, you might need to explicitly set the foreground colour using skin params // e.g. rectangleFontColor, rectangleFontColor<<Software System>>, etc plantUMLWriter.addSkinParam("rectangleFontColor", "#ffffff"); plantUMLWriter.addSkinParam("rectangleStereotypeFontColor", "#ffffff"); // write to a specific writer StringWriter stringWriter = new StringWriter(); plantUMLWriter.write(workspace, stringWriter); System.out.println(stringWriter.toString()); // or just output directly to stdout // plantUMLWriter.toStdOut(workspace); }
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Documentation - Automatic", "An empty software architecture document using the Structurizr template."); Model model = workspace.getModel(); ViewSet views = workspace.getViews(); Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.PERSON).shape(Shape.Person); // this directory includes a mix of Markdown and AsciiDoc files File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/automatic"); AutomaticDocumentationTemplate template = new AutomaticDocumentationTemplate(workspace); template.addSections(softwareSystem, documentationRoot); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
styles.addElementStyle(Tags.ELEMENT).shape(Shape.RoundedBox).color("#ffffff"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#18ADAD").color("#ffffff"); styles.addElementStyle(Tags.PERSON).shape(Shape.Person).background("#008282").color("#ffffff"); styles.addElementStyle(Tags.CONTAINER).background("#6DBFBF"); styles.addElementStyle(FILE_SYSTEM_TAG).shape(Shape.Folder);
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Corporate Branding", "This is a model of my software system."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); ViewSet views = workspace.getViews(); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.PERSON).shape(Shape.Person); StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); template.addContextSection(softwareSystem, Format.Markdown, "Here is some context about the software system...\n\n![](embed:SystemContext)"); Branding branding = views.getConfiguration().getBranding(); branding.setLogo(ImageUtils.getImageAsDataUri(new File("./docs/images/structurizr-logo.png"))); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Filtered Views", "An example of using filtered views."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A description of the user."); SoftwareSystem softwareSystemA = model.addSoftwareSystem("Software System A", "A description of software system A."); SoftwareSystem softwareSystemB = model.addSoftwareSystem("Software System B", "A description of software system B."); softwareSystemB.addTags(FUTURE_STATE); user.uses(softwareSystemA, "Uses for tasks 1 and 2").addTags(CURRENT_STATE); user.uses(softwareSystemA, "Uses for task 1").addTags(FUTURE_STATE); user.uses(softwareSystemB, "Uses for task 2").addTags(FUTURE_STATE); ViewSet views = workspace.getViews(); SystemLandscapeView systemLandscapeView = views.createSystemLandscapeView("SystemLandscape", "An example System Landscape diagram."); systemLandscapeView.addAllElements(); views.createFilteredView(systemLandscapeView, "CurrentState", "The current system landscape.", FilterMode.Exclude, FUTURE_STATE); views.createFilteredView(systemLandscapeView, "FutureState", "The future state system landscape after Software System B is live.", FilterMode.Exclude, CURRENT_STATE); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.ELEMENT).color("#ffffff"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#91a437").shape(Shape.RoundedBox); styles.addElementStyle(Tags.PERSON).background("#6a7b15").shape(Shape.Person); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
public static void main(String[] args) throws Exception { // all software architecture models belong to a workspace Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); Model model = workspace.getModel(); // create a model to describe a user using a software system Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); // create a system context diagram showing people and software systems ViewSet views = workspace.getViews(); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); // add some styling to the diagram elements Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#08427b").color("#ffffff").shape(Shape.Person); // upload to structurizr.com (you'll need your own workspace ID, API key and API secret) StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Client-side encrypted workspace", "This is a client-side encrypted workspace. The passphrase is 'password'."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); ViewSet views = workspace.getViews(); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#d34407").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#f86628").color("#ffffff").shape(Shape.Person); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password")); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
@Test public void test_findElementStyle_ReturnsTheCorrectStyle_WhenStylesAreDefined() { SoftwareSystem element = model.addSoftwareSystem("Name", "Description"); element.addTags("Some Tag"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#ff0000").color("#ffffff"); styles.addElementStyle("Some Tag").color("#0000ff").shape(Shape.RoundedBox); ElementStyle style = styles.findElementStyle(element); assertEquals("#ff0000", style.getBackground()); assertEquals("#0000ff", style.getColor()); assertEquals(Shape.RoundedBox, style.getShape()); }
styles.addElementStyle(Tags.PERSON).background("#ffbf00").shape(Shape.Person); styles.addElementStyle(Tags.CONTAINER).background("#facc2E"); styles.addElementStyle(MESSAGE_BUS_TAG).width(1600).shape(Shape.Pipe); styles.addElementStyle(MICROSERVICE_TAG).shape(Shape.Hexagon); styles.addElementStyle(DATASTORE_TAG).background("#f5da81").shape(Shape.Cylinder); styles.addRelationshipStyle(Tags.RELATIONSHIP).routing(Routing.Orthogonal);
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("HTTP-based health checks example", "An example of how to use the HTTP-based health checks feature"); Model model = workspace.getModel(); ViewSet views = workspace.getViews(); SoftwareSystem structurizr = model.addSoftwareSystem("Structurizr", "A publishing platform for software architecture diagrams and documentation based upon the C4 model."); Container webApplication = structurizr.addContainer("structurizr.com", "Provides all of the server-side functionality of Structurizr, serving static and dynamic content to users.", "Java and Spring MVC"); Container database = structurizr.addContainer("Database", "Stores information about users, workspaces, etc.", "Relational Database Schema"); database.addTags(DATABASE_TAG); webApplication.uses(database, "Reads from and writes to", "JDBC"); DeploymentNode amazonWebServices = model.addDeploymentNode("Amazon Web Services", "", "us-east-1"); DeploymentNode pivotalWebServices = amazonWebServices.addDeploymentNode("Pivotal Web Services", "Platform as a Service provider.", "Cloud Foundry"); ContainerInstance liveWebApplication = pivotalWebServices.addDeploymentNode("www.structurizr.com", "An open source Java EE web server.", "Apache Tomcat") .add(webApplication); ContainerInstance liveDatabaseInstance = amazonWebServices.addDeploymentNode("Amazon RDS", "Database as a Service provider.", "MySQL") .add(database); // add health checks to the container instances, which return a simple HTTP 200 to say everything is okay liveWebApplication.addHealthCheck("Web Application is running", "https://www.structurizr.com/health"); liveDatabaseInstance.addHealthCheck("Database is accessible from Web Application", "https://www.structurizr.com/health/database"); // the pass/fail status from the health checks is used to supplement any deployment views that include the container instances that have health checks defined DeploymentView deploymentView = views.createDeploymentView(structurizr, "Deployment", "A deployment diagram showing the live environment."); deploymentView.setEnvironment("Live"); deploymentView.addAllDeploymentNodes(); views.getConfiguration().getStyles().addElementStyle(Tags.ELEMENT).color("#ffffff"); views.getConfiguration().getStyles().addElementStyle(DATABASE_TAG).shape(Shape.Cylinder); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
styles.addElementStyle(DATA_STORE_TAG).shape(Shape.Cylinder);