Java Code Examples for com.structurizr.Workspace#getModel()

The following examples show how to use com.structurizr.Workspace#getModel() . 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: StructurizrSimple.java    From tutorials with MIT License 6 votes vote down vote up
private static Workspace getSoftwareSystem() {
    Workspace workspace = new Workspace("Payment Gateway", "Payment Gateway");
    Model model = workspace.getModel();

    Person user = model.addPerson("Merchant", "Merchant");
    SoftwareSystem paymentTerminal = model.addSoftwareSystem(PAYMENT_TERMINAL, "Payment Terminal");
    user.uses(paymentTerminal, "Makes payment");
    SoftwareSystem fraudDetector = model.addSoftwareSystem(FRAUD_DETECTOR, "Fraud Detector");
    paymentTerminal.uses(fraudDetector, "Obtains fraud score");

    ViewSet viewSet = workspace.getViews();

    SystemContextView contextView = viewSet.createSystemContextView(workspace.getModel().getSoftwareSystemWithName(PAYMENT_TERMINAL), SOFTWARE_SYSTEM_VIEW, "Payment Gateway Diagram");
    contextView.addAllElements();

    return workspace;
}
 
Example 2
Source File: ClientSideEncryption.java    From java with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 3
Source File: AutomaticDocumentationTemplateExample.java    From java with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: DynamicViewTests.java    From java with Apache License 2.0 6 votes vote down vote up
@Test
public void test_normalSequence() {
    workspace = new Workspace("Name", "Description");
    model = workspace.getModel();

    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    Container container1 = softwareSystem.addContainer("Container 1", "Description", "Technology");
    Container container2 = softwareSystem.addContainer("Container 2", "Description", "Technology");
    Container container3 = softwareSystem.addContainer("Container 3", "Description", "Technology");

    container1.uses(container2, "Uses");
    container1.uses(container3, "Uses");

    DynamicView view = workspace.getViews().createDynamicView(softwareSystem, "key", "Description");

    view.add(container1, container2);
    view.add(container1, container3);

    assertSame(container2, view.getRelationships().stream().filter(r -> r.getOrder().equals("1")).findFirst().get().getRelationship().getDestination());
    assertSame(container3, view.getRelationships().stream().filter(r -> r.getOrder().equals("2")).findFirst().get().getRelationship().getDestination());
}
 
Example 5
Source File: StructurizrSimple.java    From tutorials with MIT License 6 votes vote down vote up
private static void addComponents(Workspace workspace) {
    Model model = workspace.getModel();

    SoftwareSystem paymentTerminal = model.getSoftwareSystemWithName(PAYMENT_TERMINAL);
    Container jvm1 = paymentTerminal.getContainerWithName("JVM-1");

    Component jaxrs = jvm1.addComponent("jaxrs-jersey", "restful webservice implementation", "rest");
    Component gemfire = jvm1.addComponent("gemfire", "Clustered Cache Gemfire", "cache");
    Component hibernate = jvm1.addComponent("hibernate", "Data Access Layer", "jpa");

    jaxrs.uses(gemfire, "");
    gemfire.uses(hibernate, "");

    ComponentView componentView = workspace.getViews().createComponentView(jvm1, COMPONENT_VIEW, "JVM Components");
    componentView.addAllComponents();
}
 
Example 6
Source File: Theme.java    From java with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Theme", "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();

    // add a theme
    views.getConfiguration().setTheme("https://raw.githubusercontent.com/structurizr/java/master/structurizr-examples/src/com/structurizr/example/theme/theme.json");

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example 7
Source File: DynamicViewTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_parallelSequence() {
    workspace = new Workspace("Name", "Description");
    model = workspace.getModel();
    SoftwareSystem softwareSystemA = model.addSoftwareSystem("A", "");
    SoftwareSystem softwareSystemB = model.addSoftwareSystem("B", "");
    SoftwareSystem softwareSystemC1 = model.addSoftwareSystem("C1", "");
    SoftwareSystem softwareSystemC2 = model.addSoftwareSystem("C2", "");
    SoftwareSystem softwareSystemD = model.addSoftwareSystem("D", "");
    SoftwareSystem softwareSystemE = model.addSoftwareSystem("E", "");

    // A -> B -> C1 -> D -> E
    // A -> B -> C2 -> D -> E
    softwareSystemA.uses(softwareSystemB, "uses");
    softwareSystemB.uses(softwareSystemC1, "uses");
    softwareSystemC1.uses(softwareSystemD, "uses");
    softwareSystemB.uses(softwareSystemC2, "uses");
    softwareSystemC2.uses(softwareSystemD, "uses");
    softwareSystemD.uses(softwareSystemE, "uses");

    DynamicView view = workspace.getViews().createDynamicView("key", "Description");

    view.add(softwareSystemA, softwareSystemB);
    view.startParallelSequence();
    view.add(softwareSystemB, softwareSystemC1);
    view.add(softwareSystemC1, softwareSystemD);
    view.endParallelSequence();
    view.startParallelSequence();
    view.add(softwareSystemB, softwareSystemC2);
    view.add(softwareSystemC2, softwareSystemD);
    view.endParallelSequence(true);
    view.add(softwareSystemD, softwareSystemE);

    assertEquals(1, view.getRelationships().stream().filter(r -> r.getOrder().equals("1")).count());
    assertEquals(2, view.getRelationships().stream().filter(r -> r.getOrder().equals("2")).count());
    assertEquals(2, view.getRelationships().stream().filter(r -> r.getOrder().equals("3")).count());
    assertEquals(1, view.getRelationships().stream().filter(r -> r.getOrder().equals("4")).count());
}
 
Example 8
Source File: StylingRelationships.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("Styling Relationships", "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.");
        Container webApplication = softwareSystem.addContainer("Web Application", "My web application.", "Java and Spring MVC");
        Container database = softwareSystem.addContainer("Database", "My database.", "Relational database schema");
        user.uses(webApplication, "Uses", "HTTPS");
        webApplication.uses(database, "Reads from and writes to", "JDBC");

        ViewSet views = workspace.getViews();
        ContainerView containerView = views.createContainerView(softwareSystem, "containers", "An example of a container diagram.");
        containerView.addAllElements();

        Styles styles = workspace.getViews().getConfiguration().getStyles();

        // example 1
//        styles.addRelationshipStyle(Tags.RELATIONSHIP).color("#ff0000");

        // example 2
//        model.getRelationships().stream().filter(r -> "HTTPS".equals(r.getTechnology())).forEach(r -> r.addTags("HTTPS"));
//        model.getRelationships().stream().filter(r -> "JDBC".equals(r.getTechnology())).forEach(r -> r.addTags("JDBC"));
//        styles.addRelationshipStyle("HTTPS").color("#ff0000");
//        styles.addRelationshipStyle("JDBC").color("#0000ff");

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example 9
Source File: ViewTests.java    From java with Apache License 2.0 4 votes vote down vote up
@Test
public void test_copyLayoutInformationFrom() {
    Workspace workspace1 = new Workspace("", "");
    Model model1 = workspace1.getModel();
    SoftwareSystem softwareSystem1A = model1.addSoftwareSystem("System A", "Description");
    SoftwareSystem softwareSystem1B = model1.addSoftwareSystem("System B", "Description");
    Person person1 = model1.addPerson("Person", "Description");
    Relationship personUsesSoftwareSystem1 = person1.uses(softwareSystem1A, "Uses");

    // create a view with SystemA and Person (locations are set for both, relationship has vertices)
    StaticView staticView1 = new SystemContextView(softwareSystem1A, "context", "Description");
    staticView1.add(softwareSystem1B);
    staticView1.getElementView(softwareSystem1B).setX(123);
    staticView1.getElementView(softwareSystem1B).setY(321);
    staticView1.add(person1);
    staticView1.getElementView(person1).setX(456);
    staticView1.getElementView(person1).setY(654);
    staticView1.getRelationshipView(personUsesSoftwareSystem1).setVertices(Arrays.asList(new Vertex(123, 456)));
    staticView1.getRelationshipView(personUsesSoftwareSystem1).setPosition(70);
    staticView1.getRelationshipView(personUsesSoftwareSystem1).setRouting(Routing.Orthogonal);

    // and create a dynamic view, as they are treated slightly differently
    DynamicView dynamicView1 = new DynamicView(model1, "dynamic", "Description");
    dynamicView1.add(person1, "Overridden description", softwareSystem1A);
    dynamicView1.getElementView(person1).setX(111);
    dynamicView1.getElementView(person1).setY(222);
    dynamicView1.getElementView(softwareSystem1A).setX(333);
    dynamicView1.getElementView(softwareSystem1A).setY(444);
    dynamicView1.getRelationshipView(personUsesSoftwareSystem1).setVertices(Arrays.asList(new Vertex(555, 666)));
    dynamicView1.getRelationshipView(personUsesSoftwareSystem1).setPosition(30);
    dynamicView1.getRelationshipView(personUsesSoftwareSystem1).setRouting(Routing.Direct);

    Workspace workspace2 = new Workspace("", "");
    Model model2 = workspace2.getModel();
    // creating these in the opposite order will cause them to get different internal IDs
    SoftwareSystem softwareSystem2B = model2.addSoftwareSystem("System B", "Description");
    SoftwareSystem softwareSystem2A = model2.addSoftwareSystem("System A", "Description");
    Person person2 = model2.addPerson("Person", "Description");
    Relationship personUsesSoftwareSystem2 = person2.uses(softwareSystem2A, "Uses");

    // create a view with SystemB and Person (locations are 0,0 for both)
    StaticView staticView2 = new SystemContextView(softwareSystem2A, "context", "Description");
    staticView2.add(softwareSystem2B);
    staticView2.add(person2);
    assertEquals(0, staticView2.getElementView(softwareSystem2B).getX());
    assertEquals(0, staticView2.getElementView(softwareSystem2B).getY());
    assertEquals(0, staticView2.getElementView(softwareSystem2B).getX());
    assertEquals(0, staticView2.getElementView(softwareSystem2B).getY());
    assertEquals(0, staticView2.getElementView(person2).getX());
    assertEquals(0, staticView2.getElementView(person2).getY());
    assertTrue(staticView2.getRelationshipView(personUsesSoftwareSystem2).getVertices().isEmpty());

    // and create a dynamic view (locations are 0,0)
    DynamicView dynamicView2 = new DynamicView(model2, "dynamic", "Description");
    dynamicView2.add(person2, "Overridden description", softwareSystem2A);

    staticView2.copyLayoutInformationFrom(staticView1);
    assertEquals(0, staticView2.getElementView(softwareSystem2A).getX());
    assertEquals(0, staticView2.getElementView(softwareSystem2A).getY());
    assertEquals(123, staticView2.getElementView(softwareSystem2B).getX());
    assertEquals(321, staticView2.getElementView(softwareSystem2B).getY());
    assertEquals(456, staticView2.getElementView(person2).getX());
    assertEquals(654, staticView2.getElementView(person2).getY());
    Vertex vertex1 = staticView2.getRelationshipView(personUsesSoftwareSystem2).getVertices().iterator().next();
    assertEquals(123, vertex1.getX());
    assertEquals(456, vertex1.getY());
    assertEquals(70, staticView2.getRelationshipView(personUsesSoftwareSystem2).getPosition().intValue());
    assertEquals(Routing.Orthogonal, staticView2.getRelationshipView(personUsesSoftwareSystem2).getRouting());

    dynamicView2.copyLayoutInformationFrom(dynamicView1);
    assertEquals(111, dynamicView2.getElementView(person2).getX());
    assertEquals(222, dynamicView2.getElementView(person2).getY());
    assertEquals(333, dynamicView2.getElementView(softwareSystem2A).getX());
    assertEquals(444, dynamicView2.getElementView(softwareSystem2A).getY());
    Vertex vertex2 = dynamicView2.getRelationshipView(personUsesSoftwareSystem2).getVertices().iterator().next();
    assertEquals(555, vertex2.getX());
    assertEquals(666, vertex2.getY());
    assertEquals(30, dynamicView2.getRelationshipView(personUsesSoftwareSystem2).getPosition().intValue());
    assertEquals(Routing.Direct, dynamicView2.getRelationshipView(personUsesSoftwareSystem2).getRouting());
}
 
Example 10
Source File: MicroservicesExample.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Microservices example", "An example of a microservices architecture, which includes asynchronous and parallel behaviour.");
    Model model = workspace.getModel();

    SoftwareSystem mySoftwareSystem = model.addSoftwareSystem("Customer Information System", "Stores information ");
    Person customer = model.addPerson("Customer", "A customer");
    Container customerApplication = mySoftwareSystem.addContainer("Customer Application", "Allows customers to manage their profile.", "Angular");

    Container customerService = mySoftwareSystem.addContainer("Customer Service", "The point of access for customer information.", "Java and Spring Boot");
    customerService.addTags(MICROSERVICE_TAG);
    Container customerDatabase = mySoftwareSystem.addContainer("Customer Database", "Stores customer information.", "Oracle 12c");
    customerDatabase.addTags(DATASTORE_TAG);

    Container reportingService = mySoftwareSystem.addContainer("Reporting Service", "Creates normalised data for reporting purposes.", "Ruby");
    reportingService.addTags(MICROSERVICE_TAG);
    Container reportingDatabase = mySoftwareSystem.addContainer("Reporting Database", "Stores a normalised version of all business data for ad hoc reporting purposes.", "MySQL");
    reportingDatabase.addTags(DATASTORE_TAG);

    Container auditService = mySoftwareSystem.addContainer("Audit Service", "Provides organisation-wide auditing facilities.", "C# .NET");
    auditService.addTags(MICROSERVICE_TAG);
    Container auditStore = mySoftwareSystem.addContainer("Audit Store", "Stores information about events that have happened.", "Event Store");
    auditStore.addTags(DATASTORE_TAG);

    Container messageBus = mySoftwareSystem.addContainer("Message Bus", "Transport for business events.", "RabbitMQ");
    messageBus.addTags(MESSAGE_BUS_TAG);

    customer.uses(customerApplication, "Uses");
    customerApplication.uses(customerService, "Updates customer information using", "JSON/HTTPS", InteractionStyle.Synchronous);
    customerService.uses(messageBus, "Sends customer update events to", "", InteractionStyle.Asynchronous);
    customerService.uses(customerDatabase, "Stores data in", "JDBC", InteractionStyle.Synchronous);
    customerService.uses(customerApplication, "Sends events to", "WebSocket", InteractionStyle.Asynchronous);
    messageBus.uses(reportingService, "Sends customer update events to", "", InteractionStyle.Asynchronous);
    messageBus.uses(auditService, "Sends customer update events to", "", InteractionStyle.Asynchronous);
    reportingService.uses(reportingDatabase, "Stores data in", "", InteractionStyle.Synchronous);
    auditService.uses(auditStore, "Stores events in", "", InteractionStyle.Synchronous);

    ViewSet views = workspace.getViews();

    ContainerView containerView = views.createContainerView(mySoftwareSystem, "Containers", null);
    containerView.addAllElements();

    DynamicView dynamicView = views.createDynamicView(mySoftwareSystem, "CustomerUpdateEvent", "This diagram shows what happens when a customer updates their details.");
    dynamicView.add(customer, customerApplication);
    dynamicView.add(customerApplication, customerService);

    dynamicView.add(customerService, customerDatabase);
    dynamicView.add(customerService, messageBus);

    dynamicView.startParallelSequence();
    dynamicView.add(messageBus, reportingService);
    dynamicView.add(reportingService, reportingDatabase);
    dynamicView.endParallelSequence();

    dynamicView.startParallelSequence();
    dynamicView.add(messageBus, auditService);
    dynamicView.add(auditService, auditStore);
    dynamicView.endParallelSequence();

    dynamicView.startParallelSequence();
    dynamicView.add(customerService, "Confirms update to", customerApplication);
    dynamicView.endParallelSequence();

    Styles styles = views.getConfiguration().getStyles();
    styles.addElementStyle(Tags.ELEMENT).color("#000000");
    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);

    styles.addRelationshipStyle(Tags.ASYNCHRONOUS).dashed(true);
    styles.addRelationshipStyle(Tags.SYNCHRONOUS).dashed(false);

    StructurizrClient client = new StructurizrClient("key", "secret");
    client.putWorkspace(4241, workspace);
}
 
Example 11
Source File: ViewSetTests.java    From java with Apache License 2.0 4 votes vote down vote up
@Test
public void test_hydrate() {
    Workspace workspace = new Workspace("Name", "Description");
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();
    Person person = model.addPerson("Person", "Description");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    Container container = softwareSystem.addContainer("Container", "Description", "Technology");
    Component component = container.addComponent("Component", "Description", "Technology");
    Relationship personUsesSoftwareSystemRelationship = person.uses(softwareSystem, "uses");
    DeploymentNode deploymentNode = model.addDeploymentNode("Deployment Node", "Description", "Technology");
    ContainerInstance containerInstance = deploymentNode.add(container);

    SystemLandscapeView systemLandscapeView = new SystemLandscapeView();
    systemLandscapeView.setKey("systemLandscape"); // this is used for the filtered view below
    systemLandscapeView.setElements(elementViewsFor(person, softwareSystem));
    systemLandscapeView.setRelationships(relationshipViewsFor(personUsesSoftwareSystemRelationship));
    views.setSystemLandscapeViews(Collections.singleton(systemLandscapeView));

    SystemContextView systemContextView = new SystemContextView();
    systemContextView.setKey("systemContext");
    systemContextView.setSoftwareSystemId(softwareSystem.getId());
    systemContextView.setElements(elementViewsFor(softwareSystem));
    views.setSystemContextViews(Collections.singleton(systemContextView));

    ContainerView containerView = new ContainerView();
    containerView.setKey("containers");
    containerView.setSoftwareSystemId(softwareSystem.getId());
    containerView.setElements(elementViewsFor(container));
    views.setContainerViews(Collections.singleton(containerView));

    ComponentView componentView = new ComponentView();
    componentView.setKey("components");
    componentView.setSoftwareSystemId(softwareSystem.getId());
    componentView.setContainerId(container.getId());
    componentView.setElements(elementViewsFor(component));
    views.setComponentViews(Collections.singleton(componentView));

    DynamicView dynamicView = new DynamicView();
    dynamicView.setKey("dynamic");
    dynamicView.setElementId(softwareSystem.getId());
    dynamicView.setElements(elementViewsFor(component));
    views.setDynamicViews(Collections.singleton(dynamicView));

    DeploymentView deploymentView = new DeploymentView();
    deploymentView.setKey("deployment");
    deploymentView.setSoftwareSystemId(softwareSystem.getId());
    deploymentView.setElements(elementViewsFor(deploymentNode, containerInstance));
    views.setDeploymentViews(Collections.singleton(deploymentView));

    FilteredView filteredView = new FilteredView();
    filteredView.setKey("filtered");
    filteredView.setBaseViewKey(systemLandscapeView.getKey());
    views.setFilteredViews(Collections.singleton(filteredView));

    workspace.getViews().hydrate(model);

    assertSame(model, systemLandscapeView.getModel());
    assertSame(views, systemLandscapeView.getViewSet());
    assertSame(person, systemLandscapeView.getElementView(person).getElement());
    assertSame(softwareSystem, systemLandscapeView.getElementView(softwareSystem).getElement());
    assertSame(personUsesSoftwareSystemRelationship, systemLandscapeView.getRelationshipView(personUsesSoftwareSystemRelationship).getRelationship());

    assertSame(model, systemContextView.getModel());
    assertSame(views, systemContextView.getViewSet());
    assertSame(softwareSystem, systemContextView.getSoftwareSystem());
    assertSame(softwareSystem, systemContextView.getElementView(softwareSystem).getElement());

    assertSame(model, containerView.getModel());
    assertSame(views, containerView.getViewSet());
    assertSame(softwareSystem, containerView.getSoftwareSystem());
    assertSame(container, containerView.getElementView(container).getElement());

    assertSame(model, componentView.getModel());
    assertSame(views, componentView.getViewSet());
    assertSame(softwareSystem, componentView.getSoftwareSystem());
    assertSame(container, componentView.getContainer());
    assertSame(component, componentView.getElementView(component).getElement());

    assertSame(model, dynamicView.getModel());
    assertSame(views, dynamicView.getViewSet());
    assertSame(softwareSystem, dynamicView.getSoftwareSystem());
    assertSame(softwareSystem, dynamicView.getElement());
    assertSame(component, dynamicView.getElementView(component).getElement());

    assertSame(model, deploymentView.getModel());
    assertSame(views, deploymentView.getViewSet());
    assertSame(softwareSystem, deploymentView.getSoftwareSystem());
    assertSame(deploymentNode, deploymentView.getElementView(deploymentNode).getElement());
    assertSame(containerInstance, deploymentView.getElementView(containerInstance).getElement());

    assertSame(systemLandscapeView, filteredView.getView());
}
 
Example 12
Source File: Arc42DocumentationExample.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
        Workspace workspace = new Workspace("Documentation - arc42", "An empty software architecture document using the arc42 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);

        Arc42DocumentationTemplate template = new Arc42DocumentationTemplate(workspace);

        // this is the Markdown version
        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/arc42/markdown");
        template.addIntroductionAndGoalsSection(softwareSystem, new File(documentationRoot, "01-introduction-and-goals.md"));
        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "02-architecture-constraints.md"));
        template.addContextAndScopeSection(softwareSystem, new File(documentationRoot, "03-system-scope-and-context.md"));
        template.addSolutionStrategySection(softwareSystem, new File(documentationRoot, "04-solution-strategy.md"));
        template.addBuildingBlockViewSection(softwareSystem, new File(documentationRoot, "05-building-block-view.md"));
        template.addRuntimeViewSection(softwareSystem, new File(documentationRoot, "06-runtime-view.md"));
        template.addDeploymentViewSection(softwareSystem, new File(documentationRoot, "07-deployment-view.md"));
        template.addCrosscuttingConceptsSection(softwareSystem, new File(documentationRoot, "08-crosscutting-concepts.md"));
        template.addArchitecturalDecisionsSection(softwareSystem, new File(documentationRoot, "09-architecture-decisions.md"));
        template.addRisksAndTechnicalDebtSection(softwareSystem, new File(documentationRoot, "10-quality-requirements.md"));
        template.addQualityRequirementsSection(softwareSystem, new File(documentationRoot, "11-risks-and-technical-debt.md"));
        template.addGlossarySection(softwareSystem, new File(documentationRoot, "12-glossary.md"));

        // this is the AsciiDoc version
//        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/arc42/asciidoc");
//        template.addIntroductionAndGoalsSection(softwareSystem, new File(documentationRoot, "01-introduction-and-goals.adoc"));
//        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "02-architecture-constraints.adoc"));
//        template.addContextAndScopeSection(softwareSystem, new File(documentationRoot, "03-system-scope-and-context.adoc"));
//        template.addSolutionStrategySection(softwareSystem, new File(documentationRoot, "04-solution-strategy.adoc"));
//        template.addBuildingBlockViewSection(softwareSystem, new File(documentationRoot, "05-building-block-view.adoc"));
//        template.addRuntimeViewSection(softwareSystem, new File(documentationRoot, "06-runtime-view.adoc"));
//        template.addDeploymentViewSection(softwareSystem, new File(documentationRoot, "07-deployment-view.adoc"));
//        template.addCrosscuttingConceptsSection(softwareSystem, new File(documentationRoot, "08-crosscutting-concepts.adoc"));
//        template.addArchitecturalDecisionsSection(softwareSystem, new File(documentationRoot, "09-architecture-decisions.adoc"));
//        template.addRisksAndTechnicalDebtSection(softwareSystem, new File(documentationRoot, "10-quality-requirements.adoc"));
//        template.addQualityRequirementsSection(softwareSystem, new File(documentationRoot, "11-risks-and-technical-debt.adoc"));
//        template.addGlossarySection(softwareSystem, new File(documentationRoot, "12-glossary.adoc"));

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example 13
Source File: ViewSetTests.java    From java with Apache License 2.0 4 votes vote down vote up
@Test
public void test_createDefaultViews() {
    Workspace workspace = new Workspace("Name", "Description");
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();

    SoftwareSystem ss1 = model.addSoftwareSystem("Software System 1");
    Container c1 = ss1.addContainer("Container 1", "", "");
    Component cc1 = c1.addComponent("Component 1", "", "");

    SoftwareSystem ss2 = model.addSoftwareSystem("Software System 2");
    Container c2 = ss2.addContainer("Container 2", "", "");
    Component cc2 = c2.addComponent("Component 2", "", "");

    DeploymentNode dev = model.addDeploymentNode("Development", "Developer Laptop", "", "");
    DeploymentNode live = model.addDeploymentNode("Live", "Amazon Web Services", "", "");
    DeploymentNode liveEc2 = live.addDeploymentNode("EC2");

    views.createDefaultViews();

    assertEquals(1, views.getSystemLandscapeViews().size());
    assertEquals("SystemLandscape", views.getSystemLandscapeViews().iterator().next().getKey());

    assertEquals(2, views.getSystemContextViews().size());
    assertSame(ss1, views.getSystemContextViews().stream().filter(v -> v.getKey().equals("SoftwareSystem1-SystemContext")).findFirst().get().getSoftwareSystem());
    assertSame(ss2, views.getSystemContextViews().stream().filter(v -> v.getKey().equals("SoftwareSystem2-SystemContext")).findFirst().get().getSoftwareSystem());

    assertEquals(2, views.getContainerViews().size());
    assertSame(ss1, views.getContainerViews().stream().filter(v -> v.getKey().equals("SoftwareSystem1-Container")).findFirst().get().getSoftwareSystem());
    assertSame(ss2, views.getContainerViews().stream().filter(v -> v.getKey().equals("SoftwareSystem2-Container")).findFirst().get().getSoftwareSystem());

    assertEquals(2, views.getComponentViews().size());
    assertSame(c1, views.getComponentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem1-Container1-Component")).findFirst().get().getContainer());
    assertSame(c2, views.getComponentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem2-Container2-Component")).findFirst().get().getContainer());

    assertEquals(0, views.getDynamicViews().size());
    assertEquals(0, views.getDeploymentViews().size());

    live.addInfrastructureNode("Route 53");

    views.clear();
    views.createDefaultViews();

    assertEquals(1, views.getDeploymentViews().size());
    assertSame("Live", views.getDeploymentViews().stream().filter(v -> v.getKey().equals("Live-Deployment")).findFirst().get().getEnvironment());

    dev.add(c1);
    liveEc2.add(c1);
    liveEc2.add(c2);

    views.clear();
    views.createDefaultViews();

    assertEquals(3, views.getDeploymentViews().size());
    assertSame(ss1, views.getDeploymentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem1-Development-Deployment")).findFirst().get().getSoftwareSystem());
    assertSame("Development", views.getDeploymentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem1-Development-Deployment")).findFirst().get().getEnvironment());
    assertSame(ss1, views.getDeploymentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem1-Live-Deployment")).findFirst().get().getSoftwareSystem());
    assertSame("Live", views.getDeploymentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem1-Live-Deployment")).findFirst().get().getEnvironment());
    assertSame(ss2, views.getDeploymentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem2-Live-Deployment")).findFirst().get().getSoftwareSystem());
    assertSame("Live", views.getDeploymentViews().stream().filter(v -> v.getKey().equals("SoftwareSystem2-Live-Deployment")).findFirst().get().getEnvironment());
}
 
Example 14
Source File: FinancialRiskSystem.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Financial Risk System", "This is a simple (incomplete) example C4 model based upon the financial risk system architecture kata, which can be found at http://bit.ly/sa4d-risksystem");
    Model model = workspace.getModel();

    SoftwareSystem financialRiskSystem = model.addSoftwareSystem("Financial Risk System", "Calculates the bank's exposure to risk for product X.");

    Person businessUser = model.addPerson("Business User", "A regular business user.");
    businessUser.uses(financialRiskSystem, "Views reports using");

    Person configurationUser = model.addPerson("Configuration User", "A regular business user who can also configure the parameters used in the risk calculations.");
    configurationUser.uses(financialRiskSystem, "Configures parameters using");

    SoftwareSystem tradeDataSystem = model.addSoftwareSystem("Trade Data System", "The system of record for trades of type X.");
    financialRiskSystem.uses(tradeDataSystem, "Gets trade data from");

    SoftwareSystem referenceDataSystem = model.addSoftwareSystem("Reference Data System", "Manages reference data for all counterparties the bank interacts with.");
    financialRiskSystem.uses(referenceDataSystem, "Gets counterparty data from");

    SoftwareSystem referenceDataSystemV2 = model.addSoftwareSystem("Reference Data System v2.0", "Manages reference data for all counterparties the bank interacts with.");
    referenceDataSystemV2.addTags("Future State");
    financialRiskSystem.uses(referenceDataSystemV2, "Gets counterparty data from").addTags("Future State");

    SoftwareSystem emailSystem = model.addSoftwareSystem("E-mail system", "The bank's Microsoft Exchange system.");
    financialRiskSystem.uses(emailSystem, "Sends a notification that a report is ready to");
    emailSystem.delivers(businessUser, "Sends a notification that a report is ready to", "E-mail message", InteractionStyle.Asynchronous);

    SoftwareSystem centralMonitoringService = model.addSoftwareSystem("Central Monitoring Service", "The bank's central monitoring and alerting dashboard.");
    financialRiskSystem.uses(centralMonitoringService, "Sends critical failure alerts to", "SNMP", InteractionStyle.Asynchronous).addTags(TAG_ALERT);

    SoftwareSystem activeDirectory = model.addSoftwareSystem("Active Directory", "The bank's authentication and authorisation system.");
    financialRiskSystem.uses(activeDirectory, "Uses for user authentication and authorisation");

    ViewSet views = workspace.getViews();
    SystemContextView contextView = views.createSystemContextView(financialRiskSystem, "Context", "An example System Context diagram for the Financial Risk System architecture kata.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    Styles styles = views.getConfiguration().getStyles();
    financialRiskSystem.addTags("Risk System");

    styles.addElementStyle(Tags.ELEMENT).color("#ffffff").fontSize(34);
    styles.addElementStyle("Risk System").background("#550000").color("#ffffff");
    styles.addElementStyle(Tags.SOFTWARE_SYSTEM).width(650).height(400).background("#801515").shape(Shape.RoundedBox);
    styles.addElementStyle(Tags.PERSON).width(550).background("#d46a6a").shape(Shape.Person);

    styles.addRelationshipStyle(Tags.RELATIONSHIP).thickness(4).dashed(false).fontSize(32).width(400);
    styles.addRelationshipStyle(Tags.SYNCHRONOUS).dashed(false);
    styles.addRelationshipStyle(Tags.ASYNCHRONOUS).dashed(true);
    styles.addRelationshipStyle(TAG_ALERT).color("#ff0000");

    styles.addElementStyle("Future State").opacity(30).border(Border.Dashed);
    styles.addRelationshipStyle("Future State").opacity(30).dashed(true);

    StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);
    File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/financialrisksystem");
    template.addContextSection(financialRiskSystem, new File(documentationRoot, "context.adoc"));
    template.addFunctionalOverviewSection(financialRiskSystem, new File(documentationRoot, "functional-overview.md"));
    template.addQualityAttributesSection(financialRiskSystem, new File(documentationRoot, "quality-attributes.md"));
    template.addImages(documentationRoot);

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example 15
Source File: AmazonWebServicesExample.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Amazon Web Services Example", "An example AWS deployment architecture.");
    Model model = workspace.getModel();

    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(SPRING_BOOT_TAG);
    Container database = softwareSystem.addContainer("Database", "Stores information regarding the veterinarians, the clients, and their pets.", "Relational database schema");
    database.addTags(DATABASE_TAG);

    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.getViews();
    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.getConfiguration().getStyles();
    styles.addElementStyle(SPRING_BOOT_TAG).shape(Shape.RoundedBox).background("#ffffff");
    styles.addElementStyle(DATABASE_TAG).shape(Shape.Cylinder).background("#ffffff");
    styles.addElementStyle(Tags.INFRASTRUCTURE_NODE).shape(Shape.RoundedBox).background("#ffffff");

    views.getConfiguration().setThemes("https://raw.githubusercontent.com/structurizr/themes/master/amazon-web-services/theme.json");

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example 16
Source File: ViewpointsAndPerspectivesDocumentationExample.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
        Workspace workspace = new Workspace("Documentation - Viewpoints and Perspectives", "An empty software architecture document using the Viewpoints and Perspectives 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);

        ViewpointsAndPerspectivesDocumentationTemplate template = new ViewpointsAndPerspectivesDocumentationTemplate(workspace);

        // this is the Markdown version
        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/viewpointsandperspectives/markdown");
        template.addIntroductionSection(softwareSystem, new File(documentationRoot, "01-introduction.md"));
        template.addGlossarySection(softwareSystem, new File(documentationRoot, "02-glossary.md"));
        template.addSystemStakeholdersAndRequirementsSection(softwareSystem, new File(documentationRoot, "03-system-stakeholders-and-requirements.md"));
        template.addArchitecturalForcesSection(softwareSystem, new File(documentationRoot, "04-architectural-forces.md"));
        template.addArchitecturalViewsSection(softwareSystem, new File(documentationRoot, "05-architectural-views"));
        template.addSystemQualitiesSection(softwareSystem, new File(documentationRoot, "06-system-qualities.md"));
        template.addAppendicesSection(softwareSystem, new File(documentationRoot, "07-appendices.md"));

        // this is the AsciiDoc version
//        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/viewpointsandperspectives/asciidoc");
//        template.addIntroductionSection(softwareSystem, new File(documentationRoot, "01-introduction.adoc"));
//        template.addGlossarySection(softwareSystem, new File(documentationRoot, "02-glossary.adoc"));
//        template.addSystemStakeholdersAndRequirementsSection(softwareSystem, new File(documentationRoot, "03-system-stakeholders-and-requirements.adoc"));
//        template.addArchitecturalForcesSection(softwareSystem, new File(documentationRoot, "04-architectural-forces.adoc"));
//        template.addArchitecturalViewsSection(softwareSystem, new File(documentationRoot, "05-architectural-views"));
//        template.addSystemQualitiesSection(softwareSystem, new File(documentationRoot, "06-system-qualities.adoc"));
//        template.addAppendicesSection(softwareSystem, new File(documentationRoot, "07-appendices.adoc"));

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example 17
Source File: Shapes.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Shapes", "An example of all shapes available in Structurizr.");
    Model model = workspace.getModel();

    model.addSoftwareSystem("Box", "Description").addTags("Box");
    model.addSoftwareSystem("RoundedBox", "Description").addTags("RoundedBox");
    model.addSoftwareSystem("Ellipse", "Description").addTags("Ellipse");
    model.addSoftwareSystem("Circle", "Description").addTags("Circle");
    model.addSoftwareSystem("Hexagon", "Description").addTags("Hexagon");
    model.addSoftwareSystem("Cylinder", "Description").addTags("Cylinder");
    model.addSoftwareSystem("WebBrowser", "Description").addTags("Web Browser");
    model.addSoftwareSystem("Mobile Device Portrait", "Description").addTags("Mobile Device Portrait");
    model.addSoftwareSystem("Mobile Device Landscape", "Description").addTags("Mobile Device Landscape");
    model.addSoftwareSystem("Pipe", "Description").addTags("Pipe");
    model.addSoftwareSystem("Folder", "Description").addTags("Folder");
    model.addSoftwareSystem("Robot", "Description").addTags("Robot");
    model.addPerson("Person", "Description").addTags("Person");
    model.addSoftwareSystem("Component", "Description").addTags("Component");

    ViewSet views = workspace.getViews();
    SystemLandscapeView view = views.createSystemLandscapeView("shapes", "An example of all shapes available in Structurizr.");
    view.addAllElements();
    view.setPaperSize(PaperSize.A5_Landscape);

    Styles styles = views.getConfiguration().getStyles();

    styles.addElementStyle(Tags.ELEMENT).color("#ffffff").background("#438dd5").fontSize(34).width(650).height(400).description(false).metadata(false);
    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("Component").shape(Shape.Component);

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example 18
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 });
}
 
Example 19
Source File: MessageDigestIdGeneratorTests.java    From java with Apache License 2.0 4 votes vote down vote up
private Workspace createWorkspace(IdGenerator ids) {
    Workspace workspace = new Workspace("My workspace", "Description");
    Model model = workspace.getModel();
    model.setIdGenerator(ids);

    SoftwareSystem mySoftwareSystem = model.addSoftwareSystem(Location.Internal, "My Software System", "Description");
    mySoftwareSystem.addTags("Internal");

    Person person = model.addPerson(Location.External, "A User", "Description");
    person.addTags("External");
    person.uses(mySoftwareSystem, "Uses");

    Container webApplication = mySoftwareSystem.addContainer("Web Application", "Description", "Apache Tomcat");
    Container database = mySoftwareSystem.addContainer("Database", "Description", "MySQL");
    person.uses(webApplication, "Uses");
    Relationship webApplicationToDatabase = webApplication.uses(database, "Reads from and writes to");
    webApplicationToDatabase.addTags("JDBC");

    Component componentA = webApplication.addComponent("ComponentA", "Description", "Technology A");
    Component componentB = webApplication.addComponent("com.somecompany.system.ComponentB", "com.somecompany.system.ComponentBImpl", "Description", "Technology B");
    person.uses(componentA, "Uses");
    componentA.uses(componentB, "Uses");
    componentB.uses(database, "Reads from and writes to");

    ViewSet views = workspace.getViews();
    SystemContextView systemContextView = views.createSystemContextView(mySoftwareSystem, "context", "Description");
    systemContextView.addAllSoftwareSystems();
    systemContextView.addAllPeople();

    ContainerView containerView = views.createContainerView(mySoftwareSystem, "containers", "Description");
    containerView.addAllSoftwareSystems();
    containerView.addAllPeople();
    containerView.addAllContainers();

    ComponentView componentView = views.createComponentView(webApplication, "components", "Description");
    componentView.addAllSoftwareSystems();
    componentView.addAllPeople();
    componentView.addAllContainers();
    componentView.addAllComponents();

    views.getConfiguration().getStyles().add(new ElementStyle(Tags.ELEMENT, 600, 450, "#dddddd", "#000000", 30));
    views.getConfiguration().getStyles().add(new ElementStyle("Internal", null, null, "#041F37", "#ffffff", null));
    views.getConfiguration().getStyles().add(new RelationshipStyle(Tags.RELATIONSHIP, 4, "#dddddd", true, Routing.Direct, 25, 300, null));
    views.getConfiguration().getStyles().add(new RelationshipStyle("JDBC", 4, "#ff0000", true, Routing.Direct, 25, 300, null));

    return workspace;
}
 
Example 20
Source File: StructurizrAutoConfiguration.java    From structurizr-extensions with Apache License 2.0 4 votes vote down vote up
@Bean
public Model model(Workspace workspace) {
    return workspace.getModel();
}