Skip to content

Instantly share code, notes, and snippets.

@simonbrowndotje
Last active August 29, 2015 14:23
Show Gist options
  • Save simonbrowndotje/e150c52ad78b58a236ee to your computer and use it in GitHub Desktop.
Save simonbrowndotje/e150c52ad78b58a236ee to your computer and use it in GitHub Desktop.
C4 software architecture diagram for a furniture company.
package com.structurizr.example.core;
import com.structurizr.Workspace;
import com.structurizr.api.StructurizrClient;
import com.structurizr.model.Model;
import com.structurizr.model.Person;
import com.structurizr.model.SoftwareSystem;
import com.structurizr.model.Tags;
import com.structurizr.view.ElementStyle;
import com.structurizr.view.Shape;
import com.structurizr.view.SystemContextView;
import com.structurizr.view.ViewSet;
public class FurnitureCompany {
public static void main(String[] args) throws Exception {
Workspace workspace = new Workspace("Furniture Company", "A simple model for a company selling furniture.");
Model model = workspace.getModel();
Person salesStaff = model.addPerson("Sales Staff", "");
Person designer = model.addPerson("Designer", "");
Person warehouseStaff = model.addPerson("Warehouse Staff", "");
SoftwareSystem salesOrderbook = model.addSoftwareSystem("Sales Orderbook", "");
SoftwareSystem productCatalogue = model.addSoftwareSystem("Product Catalogue", "");
SoftwareSystem warehouseManagement = model.addSoftwareSystem("Warehouse Management", "");
SoftwareSystem manufacturer = model.addSoftwareSystem("Manufacturer", "");
salesStaff.uses(salesOrderbook, "Maintains orders for customers");
designer.uses(productCatalogue, "Modifies products and examines corresponding orders");
productCatalogue.uses(salesOrderbook, "Product information");
salesOrderbook.uses(productCatalogue, "Sales information");
salesOrderbook.uses(warehouseManagement, "Orders");
warehouseManagement.uses(productCatalogue, "Request product information");
warehouseManagement.uses(manufacturer, "Product to be manufactured");
warehouseManagement.delivers(warehouseStaff, "Delivery orders");
ViewSet viewSet = workspace.getViews();
SystemContextView systemContextView = viewSet.createContextView(salesOrderbook);
systemContextView.addAllElements();
viewSet.getConfiguration().getStyles().add(new ElementStyle(Tags.PERSON, 400, null, null, null, null, Shape.Person));
viewSet.getConfiguration().getStyles().add(new ElementStyle(Tags.SOFTWARE_SYSTEM, null, null, null, null, null, Shape.Box));
StructurizrClient structurizrClient = new StructurizrClient("https://api.structurizr.com", "key", "secret");
structurizrClient.mergeWorkspace(1234, workspace);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment