com.structurizr.api.StructurizrClient Java Examples

The following examples show how to use com.structurizr.api.StructurizrClient. 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: GettingStarted.java    From java with Apache License 2.0 6 votes vote down vote up
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);
}
 
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: CorporateBranding.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("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);
}
 
Example #4
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 #5
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 #6
Source File: FilteredViews.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("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);
}
 
Example #7
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 #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: Structurizr.java    From architecture-guild with Apache License 2.0 5 votes vote down vote up
private static void uploadWorkspaceToStructurizr(Workspace workspace) throws Exception {
    try(InputStream inputStream = Structurizr.class.getClassLoader()
            .getResourceAsStream("secret.properties")) {
        Properties prop = new Properties();
        prop.load(inputStream);
        long workspaceId = parseLong(prop.getProperty("workspace.id"));
        String apiKey = prop.getProperty("api.key");
        String apiSecret = prop.getProperty("api.secret");
        StructurizrClient structurizrClient = new StructurizrClient(apiKey, apiSecret);
        structurizrClient.putWorkspace(workspaceId, workspace);
    }
}
 
Example #10
Source File: StylingElements.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 Elements", "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.addElementStyle(Tags.ELEMENT).background("#438dd5").color("#ffffff");

        // example 2
//        styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
//        styles.addElementStyle(Tags.PERSON).background("#08427b");
//        styles.addElementStyle(Tags.CONTAINER).background("#438dd5");

        // example 3
//        styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
//        styles.addElementStyle(Tags.PERSON).background("#08427b").shape(Shape.Person);
//        styles.addElementStyle(Tags.CONTAINER).background("#438dd5");
//        database.addTags("Database");
//        styles.addElementStyle("Database").shape(Shape.Cylinder);

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example #11
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 #12
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 #13
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 #14
Source File: EmptyWorkspace.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("Name", "Description");
    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #15
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 #16
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 #17
Source File: StructurizrDocumentationExample.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 - Structurizr", "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);

        StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);

        // this is the Markdown version
        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/structurizr/markdown");
        template.addContextSection(softwareSystem, new File(documentationRoot, "01-context.md"));
        template.addFunctionalOverviewSection(softwareSystem, new File(documentationRoot, "02-functional-overview.md"));
        template.addQualityAttributesSection(softwareSystem, new File(documentationRoot, "03-quality-attributes.md"));
        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "04-constraints.md"));
        template.addPrinciplesSection(softwareSystem, new File(documentationRoot, "05-principles.md"));
        template.addSoftwareArchitectureSection(softwareSystem, new File(documentationRoot, "06-software-architecture.md"));
        template.addDataSection(softwareSystem, new File(documentationRoot, "07-data.md"));
        template.addInfrastructureArchitectureSection(softwareSystem, new File(documentationRoot, "08-infrastructure-architecture.md"));
        template.addDeploymentSection(softwareSystem, new File(documentationRoot, "09-deployment.md"));
        template.addDevelopmentEnvironmentSection(softwareSystem, new File(documentationRoot, "10-development-environment.md"));
        template.addOperationAndSupportSection(softwareSystem, new File(documentationRoot, "11-operation-and-support.md"));
        template.addDecisionLogSection(softwareSystem, new File(documentationRoot, "12-decision-log.md"));

        // this is the AsciiDoc version
//        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/structurizr/asciidoc");
//        template.addContextSection(softwareSystem, new File(documentationRoot, "01-context.adoc"));
//        template.addFunctionalOverviewSection(softwareSystem, new File(documentationRoot, "02-functional-overview.adoc"));
//        template.addQualityAttributesSection(softwareSystem, new File(documentationRoot, "03-quality-attributes.adoc"));
//        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "04-constraints.adoc"));
//        template.addPrinciplesSection(softwareSystem, new File(documentationRoot, "05-principles.adoc"));
//        template.addSoftwareArchitectureSection(softwareSystem, new File(documentationRoot, "06-software-architecture.adoc"));
//        template.addDataSection(softwareSystem, new File(documentationRoot, "07-data.adoc"));
//        template.addInfrastructureArchitectureSection(softwareSystem, new File(documentationRoot, "08-infrastructure-architecture.adoc"));
//        template.addDeploymentSection(softwareSystem, new File(documentationRoot, "09-deployment.adoc"));
//        template.addDevelopmentEnvironmentSection(softwareSystem, new File(documentationRoot, "10-development-environment.adoc"));
//        template.addOperationAndSupportSection(softwareSystem, new File(documentationRoot, "11-operation-and-support.adoc"));
//        template.addDecisionLogSection(softwareSystem, new File(documentationRoot, "12-decision-log.adoc"));

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example #18
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 #19
Source File: Structurizr.java    From java-quickstart with Apache License 2.0 4 votes vote down vote up
private static void uploadWorkspaceToStructurizr(Workspace workspace) throws Exception {
    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #20
Source File: StructurizrAutoConfiguration.java    From structurizr-extensions with Apache License 2.0 4 votes vote down vote up
@Bean
public StructurizrService structurizrService(StructurizrClient structurizrClient, Workspace workspace,
                                             StructurizrProperties properties) {
     return new StructurizrService(structurizrClient, workspace, properties);
}
 
Example #21
Source File: WidgetsLimited.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("Widgets Limited", "Sells widgets to customers online.");
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();
    Styles styles = views.getConfiguration().getStyles();

    model.setEnterprise(new Enterprise("Widgets Limited"));

    Person customer = model.addPerson(Location.External, "Customer", "A customer of Widgets Limited.");
    Person customerServiceUser = model.addPerson(Location.Internal, "Customer Service Agent", "Deals with customer enquiries.");
    SoftwareSystem ecommerceSystem = model.addSoftwareSystem(Location.Internal, "E-commerce System", "Allows customers to buy widgets online via the widgets.com website.");
    SoftwareSystem fulfilmentSystem = model.addSoftwareSystem(Location.Internal, "Fulfilment System", "Responsible for processing and shipping of customer orders.");
    SoftwareSystem taxamo = model.addSoftwareSystem(Location.External, "Taxamo", "Calculates local tax (for EU B2B customers) and acts as a front-end for Braintree Payments.");
    taxamo.setUrl("https://www.taxamo.com");
    SoftwareSystem braintreePayments = model.addSoftwareSystem(Location.External, "Braintree Payments", "Processes credit card payments on behalf of Widgets Limited.");
    braintreePayments.setUrl("https://www.braintreepayments.com");
    SoftwareSystem jerseyPost = model.addSoftwareSystem(Location.External, "Jersey Post", "Calculates worldwide shipping costs for packages.");

    model.getPeople().stream().filter(p -> p.getLocation() == Location.External).forEach(p -> p.addTags(EXTERNAL_TAG));
    model.getPeople().stream().filter(p -> p.getLocation() == Location.Internal).forEach(p -> p.addTags(INTERNAL_TAG));

    model.getSoftwareSystems().stream().filter(ss -> ss.getLocation() == Location.External).forEach(ss -> ss.addTags(EXTERNAL_TAG));
    model.getSoftwareSystems().stream().filter(ss -> ss.getLocation() == Location.Internal).forEach(ss -> ss.addTags(INTERNAL_TAG));

    customer.interactsWith(customerServiceUser, "Asks questions to", "Telephone");
    customerServiceUser.uses(ecommerceSystem, "Looks up order information using");
    customer.uses(ecommerceSystem, "Places orders for widgets using");
    ecommerceSystem.uses(fulfilmentSystem, "Sends order information to");
    fulfilmentSystem.uses(jerseyPost, "Gets shipping charges from");
    ecommerceSystem.uses(taxamo, "Delegates credit card processing to");
    taxamo.uses(braintreePayments, "Uses for credit card processing");

    SystemLandscapeView systemLandscapeView = views.createSystemLandscapeView("SystemLandscape", "The system landscape for Widgets Limited.");
    systemLandscapeView.addAllElements();

    SystemContextView ecommerceSystemContext = views.createSystemContextView(ecommerceSystem, "EcommerceSystemContext", "The system context diagram for the Widgets Limited e-commerce system.");
    ecommerceSystemContext.addNearestNeighbours(ecommerceSystem);
    ecommerceSystemContext.remove(customer.getEfferentRelationshipWith(customerServiceUser));

    SystemContextView fulfilmentSystemContext = views.createSystemContextView(fulfilmentSystem, "FulfilmentSystemContext", "The system context diagram for the Widgets Limited fulfilment system.");
    fulfilmentSystemContext.addNearestNeighbours(fulfilmentSystem);

    DynamicView dynamicView = views.createDynamicView("CustomerSupportCall", "A high-level overview of the customer support call process.");
    dynamicView.add(customer, customerServiceUser);
    dynamicView.add(customerServiceUser, ecommerceSystem);

    StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);
    template.addSection("System Landscape", Format.Markdown, "Here is some information about the Widgets Limited system landscape... ![](embed:SystemLandscape)");
    template.addContextSection(ecommerceSystem, Format.Markdown, "This is the context section for the E-commerce System... ![](embed:EcommerceSystemContext)");
    template.addContextSection(fulfilmentSystem, Format.Markdown, "This is the context section for the Fulfilment System... ![](embed:FulfilmentSystemContext)");

    styles.addElementStyle(Tags.SOFTWARE_SYSTEM).shape(Shape.RoundedBox);
    styles.addElementStyle(Tags.PERSON).shape(Shape.Person);

    styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
    styles.addElementStyle(EXTERNAL_TAG).background("#EC5381").border(Border.Dashed);
    styles.addElementStyle(INTERNAL_TAG).background("#B60037");

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #22
Source File: StructurizrService.java    From structurizr-extensions with Apache License 2.0 4 votes vote down vote up
public StructurizrService(StructurizrClient structurizrClient, Workspace workspace, StructurizrProperties properties) {
    this.structurizrClient = structurizrClient;
    this.workspace = workspace;
    this.properties = properties;
}