Java Code Examples for com.structurizr.view.ViewSet#createDeploymentView()

The following examples show how to use com.structurizr.view.ViewSet#createDeploymentView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpHealthChecks.java    From java with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: AwsPublicSystemDocumentation.java    From cia with Apache License 2.0 4 votes vote down vote up
/**
 * The main method.
 *
 * @param args
 *            the arguments
 * @throws Exception
 *             the exception
 */
public static void main(final String[] args) throws Exception {
	final Workspace workspace = new Workspace("Citizen Intelligence Agency", "Public Aws System Documentation");
	final Model model = workspace.getModel();
	final ViewSet viewSet = workspace.getViews();

	final SoftwareSystem ciaSystem = model.addSoftwareSystem("Citizen Intelligence Agency",
			"Tracking politicians like bugs!");

	final DeploymentNode masterAccountNode = model.addDeploymentNode("Master Account", "AWS", "Aws Account");
	final Container awsAccountContainer = ciaSystem.addContainer("Master Account", "AWS", "Aws Account");

	final DeploymentNode iamAccountNode = model.addDeploymentNode("IAM Account", "AWS", "Aws Account");
	final Container iamAccountContainer = ciaSystem.addContainer("IAM Account", "AWS", "Aws Account");
	
	final DeploymentNode devAccountNode = model.addDeploymentNode("Development Account", "AWS", "Aws Account");
	final Container devAccountContainer = ciaSystem.addContainer("Development Account", "AWS", "Aws Account");

	final DeploymentNode opCenterAccountNode = model.addDeploymentNode("Operation Center Account", "AWS", "Aws Account");
	final Container opCenterAccountContainer = ciaSystem.addContainer("Operation Center Account", "AWS", "Aws Account");

	final DeploymentNode auditAccountNode = model.addDeploymentNode("Audit Account", "AWS", "Aws Account");
	final Container auditAccountContainer = ciaSystem.addContainer("Audit Account", "AWS", "Aws Account");
	
	final DeploymentNode appAccountNode = model.addDeploymentNode("Application Account", "AWS", "Aws Account");
	final Container appAccountContainer = ciaSystem.addContainer("Application Account", "AWS", "Aws Account");
	
	awsAccountContainer.uses(iamAccountContainer, "create/restrict");
	awsAccountContainer.uses(devAccountContainer, "create/restrict");
	awsAccountContainer.uses(opCenterAccountContainer, "create/restrict");
	awsAccountContainer.uses(auditAccountContainer, "create/restrict");
	awsAccountContainer.uses(appAccountContainer, "create/restrict");
	
	awsAccountContainer.uses(auditAccountContainer, "publish event/audit");
	iamAccountContainer.uses(auditAccountContainer, "publish event/audit");
	devAccountContainer.uses(auditAccountContainer, "publish event/audit");
	opCenterAccountContainer.uses(auditAccountContainer, "publish event/audit");
	appAccountContainer.uses(auditAccountContainer, "publish event/audit");
	
	opCenterAccountContainer.uses(auditAccountContainer, "Monitor event/audit");
	
	iamAccountContainer.uses(devAccountContainer, "manage access");
	iamAccountContainer.uses(appAccountContainer, "manage access");
	iamAccountContainer.uses(opCenterAccountContainer, "manage access");

	opCenterAccountNode.add(opCenterAccountContainer);
	devAccountNode.add(devAccountContainer);
	auditAccountNode.add(auditAccountContainer);
	appAccountNode.add(appAccountContainer);
	iamAccountNode.add(iamAccountContainer);
	masterAccountNode.add(awsAccountContainer);
	
	final DeploymentView developmentDeploymentView = viewSet.createDeploymentView(ciaSystem, "\"Production Aws Account structure\"",
			"\"Production Aws Account structure\"");

	developmentDeploymentView.add(masterAccountNode);
	developmentDeploymentView.add(iamAccountNode);
	developmentDeploymentView.add(devAccountNode);
	developmentDeploymentView.add(opCenterAccountNode);
	developmentDeploymentView.add(auditAccountNode);
	developmentDeploymentView.add(appAccountNode);		
	

	final Styles styles = viewSet.getConfiguration().getStyles();
	styles.addElementStyle(Tags.COMPONENT).background("#1168bd").color("#ffffff");
	styles.addElementStyle(Tags.CONTAINER).background("#1168bd").color("#ffffff");
	styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff");
	styles.addElementStyle(Tags.PERSON).background("#519823").color("#ffffff").shape(Shape.Person);
	styles.addElementStyle("Database").shape(Shape.Cylinder);

	printPlantUml(workspace);
	System.setProperty("PLANTUML_LIMIT_SIZE", "8192");
	Run.main(new String[] { Paths.get(".").toAbsolutePath().normalize().toString() + File.separator + "target"
			+ File.separator + "site" + File.separator + "architecture" + File.separator });
}