Skip to content

Instantly share code, notes, and snippets.

@simonbrowndotje
Created March 17, 2015 19:13
Show Gist options
  • Save simonbrowndotje/d549fd2b5305f77efe8e to your computer and use it in GitHub Desktop.
Save simonbrowndotje/d549fd2b5305f77efe8e to your computer and use it in GitHub Desktop.
package com.structurizr.example.core;
import com.structurizr.Workspace;
import com.structurizr.api.StructurizrClient;
import com.structurizr.model.*;
import com.structurizr.view.*;
public class SelfDrivingCarSystem {
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Self-Driving Car System", "Case study for Nate Schutta's modeling workshop at the O'Reilly Software Architecture Conference 2015");
Model model = workspace.getModel();
// create the basic model
SoftwareSystem selfDrivingCarSystem = model.addSoftwareSystem(Location.Internal, "Self-Driving Car System", "Central system for storing information about self-driving cars.");
SoftwareSystem selfDrivingCar = model.addSoftwareSystem("Self-Driving Car", "Our own self-driving cars");
selfDrivingCar.uses(selfDrivingCarSystem, "Sends VIN and status information (battery level, health of engine, location, etc) to");
Person carOwner = model.addPerson("Car Owner", "The owner of a self-driving car");
carOwner.uses(selfDrivingCarSystem, "Gets information from and makes requests (e.g. summon car) to");
carOwner.uses(selfDrivingCar, "Owns and drives");
Person auditor = model.addPerson("Auditor", "Audits access to customer data");
auditor.uses(selfDrivingCarSystem, "Views audit information about customer data access from");
Person dataScientist = model.addPerson("Data Scientist", "Mines self-driving car data");
dataScientist.uses(selfDrivingCarSystem, "Mines and produces reports about self-driving cars and their usage with");
Person softwareUpdater = model.addPerson("Developer", "Builds and maintains the software used in the self-driving cars");
softwareUpdater.uses(selfDrivingCarSystem, "Send software updates for cars to");
selfDrivingCarSystem.uses(selfDrivingCar, "Sends software updates to");
// create some views
ViewSet viewSet = workspace.getViews();
SystemContextView contextView = viewSet.createContextView(selfDrivingCarSystem);
contextView.setPaperSize(PaperSize.Slide_4_3);
contextView.addAllElements();
// tag and style some elements
selfDrivingCarSystem.addTags("System Under Construction");
viewSet.getStyles().add(new ElementStyle(Tags.ELEMENT, 600, 450, null, null, 40));
viewSet.getStyles().add(new ElementStyle("System Under Construction", null, null, "#041F37", "#ffffff", null));
viewSet.getStyles().add(new ElementStyle(Tags.SOFTWARE_SYSTEM, null, null, "#2A4E6E", "#ffffff", null));
viewSet.getStyles().add(new ElementStyle(Tags.PERSON, null, null, "#728da5", "white", 40));
viewSet.getStyles().add(new RelationshipStyle(Tags.RELATIONSHIP, 5, null, 40, 500));
contextView.setPaperSize(PaperSize.Slide_4_3);
// upload it to structurizr.com
StructurizrClient structurizrClient = new StructurizrClient("https://api.structurizr.com", "key", "secret");
structurizrClient.mergeWorkspace(271 , workspace);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment