public void Test_AddAllDeploymentNodes_DoesNothing_WhenThereAreNoTopLevelDeploymentNodes() { deploymentView = Views.CreateDeploymentView("deployment", "Description"); deploymentView.AddAllDeploymentNodes(); Assert.Equal(0, deploymentView.Elements.Count); }
public void Test_AddAllDeploymentNodes_DoesNothing_WhenThereAreTopLevelDeploymentNodesButNoContainerInstances() { deploymentView = Views.CreateDeploymentView("deployment", "Description"); Model.AddDeploymentNode("Deployment Node", "Description", "Technology"); deploymentView.AddAllDeploymentNodes(); Assert.Equal(0, deploymentView.Elements.Count); }
public void Test_AddAllDeploymentNodes_DoesNothing_WhenThereNoDeploymentNodesForTheDeploymentEnvironment() { SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", ""); Container container = softwareSystem.AddContainer("Container", "Description", "Technology"); DeploymentNode deploymentNode = Model.AddDeploymentNode("Deployment Node", "Description", "Technology"); ContainerInstance containerInstance = deploymentNode.Add(container); deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description"); deploymentView.Environment = "Live"; deploymentView.AddAllDeploymentNodes(); Assert.Equal(0, deploymentView.Elements.Count); }
public void Test_AddAllDeploymentNodes_AddsDeploymentNodesAndContainerInstances_WhenThereAreTopLevelDeploymentNodesWithContainerInstances() { SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", ""); Container container = softwareSystem.AddContainer("Container", "Description", "Technology"); DeploymentNode deploymentNode = Model.AddDeploymentNode("Deployment Node", "Description", "Technology"); ContainerInstance containerInstance = deploymentNode.Add(container); deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description"); deploymentView.AddAllDeploymentNodes(); Assert.Equal(2, deploymentView.Elements.Count); Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNode))); Assert.True(deploymentView.Elements.Contains(new ElementView(containerInstance))); }
public void Test_Remove_RemovesTheChildDeploymentNodeAndChildren() { SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", ""); Container container = softwareSystem.AddContainer("Container", "Description", "Technology"); DeploymentNode deploymentNodeParent = Model.AddDeploymentNode("Deployment Node", "Description", "Technology"); DeploymentNode deploymentNodeChild = deploymentNodeParent.AddDeploymentNode("Deployment Node", "Description", "Technology"); InfrastructureNode infrastructureNode = deploymentNodeChild.AddInfrastructureNode("Infrastructure Node"); ContainerInstance containerInstance = deploymentNodeChild.Add(container); deploymentView = Views.CreateDeploymentView(softwareSystem, "deployment", "Description"); deploymentView.AddAllDeploymentNodes(); Assert.Equal(4, deploymentView.Elements.Count); deploymentView.Remove(deploymentNodeParent); Assert.Equal(0, deploymentView.Elements.Count); }
static void Main() { Workspace workspace = new Workspace("HTTP-based health checks example", "An example of how to use the HTTP-based health checks feature"); Model model = workspace.Model; ViewSet views = workspace.Views; 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(DatabaseTag); 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.Environment = "Live"; deploymentView.AddAllDeploymentNodes(); views.Configuration.Styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); views.Configuration.Styles.Add(new ElementStyle(DatabaseTag) { Shape = Shape.Cylinder }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); WorkspaceUtils.PrintWorkspaceAsJson(workspace); Console.ReadKey(); structurizrClient.PutWorkspaceAsync(WorkspaceId, workspace).Wait(); }
public void Test_Remove_RemovesTheSoftwareSystemInstance() { SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Software System", ""); DeploymentNode deploymentNodeParent = Model.AddDeploymentNode("Deployment Node", "Description", "Technology"); DeploymentNode deploymentNodeChild = deploymentNodeParent.AddDeploymentNode("Deployment Node", "Description", "Technology"); InfrastructureNode infrastructureNode = deploymentNodeChild.AddInfrastructureNode("Infrastructure Node"); SoftwareSystemInstance softwareSystemInstance = deploymentNodeChild.Add(softwareSystem); deploymentView = Views.CreateDeploymentView("deployment", "Description"); deploymentView.AddAllDeploymentNodes(); Assert.Equal(4, deploymentView.Elements.Count); deploymentView.Remove(softwareSystemInstance); Assert.Equal(3, deploymentView.Elements.Count); Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeParent))); Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNodeChild))); Assert.True(deploymentView.Elements.Contains(new ElementView(infrastructureNode))); }
public void Test_AddAllDeploymentNodes_AddsDeploymentNodesAndContainerInstancesOnlyForTheSoftwareSystemInScope() { SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("Software System 1", ""); Container container1 = softwareSystem1.AddContainer("Container 1", "Description", "Technology"); DeploymentNode deploymentNode1 = Model.AddDeploymentNode("Deployment Node 1", "Description", "Technology"); ContainerInstance containerInstance1 = deploymentNode1.Add(container1); SoftwareSystem softwareSystem2 = Model.AddSoftwareSystem("Software System 2", ""); Container container2 = softwareSystem2.AddContainer("Container 2", "Description", "Technology"); DeploymentNode deploymentNode2 = Model.AddDeploymentNode("Deployment Node 2", "Description", "Technology"); ContainerInstance containerInstance2 = deploymentNode2.Add(container2); // two containers from different software systems on the same deployment node deploymentNode1.Add(container2); deploymentView = Views.CreateDeploymentView(softwareSystem1, "deployment", "Description"); deploymentView.AddAllDeploymentNodes(); Assert.Equal(2, deploymentView.Elements.Count); Assert.True(deploymentView.Elements.Contains(new ElementView(deploymentNode1))); Assert.True(deploymentView.Elements.Contains(new ElementView(containerInstance1))); }
private void PopulateWorkspace() { Model model = _workspace.Model; ViewSet views = _workspace.Views; model.Enterprise = new Enterprise("Some Enterprise"); Person user = model.AddPerson(Location.Internal, "User", ""); SoftwareSystem softwareSystem = model.AddSoftwareSystem(Location.Internal, "Software System", ""); user.Uses(softwareSystem, "Uses"); SoftwareSystem emailSystem = model.AddSoftwareSystem(Location.External, "E-mail System", ""); softwareSystem.Uses(emailSystem, "Sends e-mail using"); emailSystem.Delivers(user, "Delivers e-mails to"); Container webApplication = softwareSystem.AddContainer("Web Application", "", ""); Container database = softwareSystem.AddContainer("Database", "", ""); user.Uses(webApplication, "Uses", "HTTP"); webApplication.Uses(database, "Reads from and writes to", "JDBC"); webApplication.Uses(emailSystem, "Sends e-mail using"); Component controller = webApplication.AddComponent("SomeController", "", "Spring MVC Controller"); Component emailComponent = webApplication.AddComponent("EmailComponent", ""); Component repository = webApplication.AddComponent("SomeRepository", "", "Spring Data"); user.Uses(controller, "Uses", "HTTP"); controller.Uses(repository, "Uses"); controller.Uses(emailComponent, "Sends e-mail using"); repository.Uses(database, "Reads from and writes to", "JDBC"); emailComponent.Uses(emailSystem, "Sends e-mails using", "SMTP"); DeploymentNode webServer = model.AddDeploymentNode("Web Server", "A server hosted at AWS EC2.", "Ubuntu 12.04 LTS"); webServer.AddDeploymentNode("Apache Tomcat", "The live web server", "Apache Tomcat 8.x") .Add(webApplication); DeploymentNode databaseServer = model.AddDeploymentNode("Database Server", "A server hosted at AWS EC2.", "Ubuntu 12.04 LTS"); databaseServer.AddDeploymentNode("MySQL", "The live database server", "MySQL 5.5.x") .Add(database); EnterpriseContextView enterpriseContextView = views.CreateEnterpriseContextView("enterpriseContext", ""); enterpriseContextView.AddAllElements(); SystemContextView systemContextView = views.CreateSystemContextView(softwareSystem, "systemContext", ""); systemContextView.AddAllElements(); ContainerView containerView = views.CreateContainerView(softwareSystem, "containers", ""); containerView.AddAllElements(); ComponentView componentView = views.CreateComponentView(webApplication, "components", ""); componentView.AddAllElements(); DynamicView dynamicView = views.CreateDynamicView(webApplication, "dynamic", ""); dynamicView.Add(user, "Requests /something", controller); dynamicView.Add(controller, repository); dynamicView.Add(repository, "select * from something", database); DeploymentView deploymentView = views.CreateDeploymentView(softwareSystem, "deployment", ""); deploymentView.AddAllDeploymentNodes(); }
static void Main() { Workspace workspace = new Workspace("Amazon Web Services Example", "An example AWS deployment architecture."); Model model = workspace.Model; SoftwareSystem softwareSystem = model.AddSoftwareSystem("Spring PetClinic", "Allows employees to view and manage information regarding the veterinarians, the clients, and their pets."); Container webApplication = softwareSystem.AddContainer("Web Application", "Allows employees to view and manage information regarding the veterinarians, the clients, and their pets.", "Java and Spring Boot"); webApplication.AddTags(SpringBootTag); Container database = softwareSystem.AddContainer("Database", "Stores information regarding the veterinarians, the clients, and their pets.", "Relational database schema"); database.AddTags(DatabaseTag); webApplication.Uses(database, "Reads from and writes to", "JDBC/SSL"); DeploymentNode amazonWebServices = model.AddDeploymentNode("Amazon Web Services"); amazonWebServices.AddTags("Amazon Web Services - Cloud"); DeploymentNode amazonRegion = amazonWebServices.AddDeploymentNode("US-East-1"); amazonRegion.AddTags("Amazon Web Services - Region"); DeploymentNode autoscalingGroup = amazonRegion.AddDeploymentNode("Autoscaling group"); autoscalingGroup.AddTags("Amazon Web Services - Auto Scaling"); DeploymentNode ec2 = autoscalingGroup.AddDeploymentNode("Amazon EC2"); ec2.AddTags("Amazon Web Services - EC2"); ContainerInstance webApplicationInstance = ec2.Add(webApplication); InfrastructureNode route53 = amazonRegion.AddInfrastructureNode("Route 53"); route53.AddTags("Amazon Web Services - Route 53"); InfrastructureNode elb = amazonRegion.AddInfrastructureNode("Elastic Load Balancer"); elb.AddTags("Amazon Web Services - Elastic Load Balancing"); route53.Uses(elb, "Forwards requests to", "HTTPS"); elb.Uses(webApplicationInstance, "Forwards requests to", "HTTPS"); DeploymentNode rds = amazonRegion.AddDeploymentNode("Amazon RDS"); rds.AddTags("Amazon Web Services - RDS"); DeploymentNode mySql = rds.AddDeploymentNode("MySQL"); mySql.AddTags("Amazon Web Services - RDS_MySQL_instance"); ContainerInstance databaseInstance = mySql.Add(database); ViewSet views = workspace.Views; DeploymentView deploymentView = views.CreateDeploymentView(softwareSystem, "AmazonWebServicesDeployment", "An example deployment diagram."); deploymentView.AddAllDeploymentNodes(); deploymentView.AddAnimation(route53); deploymentView.AddAnimation(elb); deploymentView.AddAnimation(webApplicationInstance); deploymentView.AddAnimation(databaseInstance); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(SpringBootTag) { Shape = Shape.RoundedBox, Background = "#ffffff" }); styles.Add(new ElementStyle(DatabaseTag) { Shape = Shape.Cylinder, Background = "#ffffff" }); styles.Add(new ElementStyle(Tags.InfrastructureNode) { Shape = Shape.RoundedBox, Background = "#ffffff" }); views.Configuration.Theme = "https://raw.githubusercontent.com/structurizr/themes/master/amazon-web-services/theme.json"; StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }