Skip to content

Instantly share code, notes, and snippets.

@simonbrowndotje
Last active August 29, 2015 14:03
Show Gist options
  • Save simonbrowndotje/df6c7fc40346153bf591 to your computer and use it in GitHub Desktop.
Save simonbrowndotje/df6c7fc40346153bf591 to your computer and use it in GitHub Desktop.
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
package com.structurizr.example;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.structurizr.model.Location;
import com.structurizr.model.Model;
import com.structurizr.model.Person;
import com.structurizr.model.SoftwareSystem;
import com.structurizr.view.ContextView;
/**
* 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
*/
public class FinancialRiskSystem {
public static void main(String[] args) throws Exception {
Model model = new Model();
// create the basic model
SoftwareSystem financialRiskSystem = model.addSoftwareSystem(Location.Internal, "Financial Risk System", "Calculates the bank's exposure to risk for product X");
Person businessUser = model.addPerson(Location.Internal, "Business User", "A regular business user");
businessUser.uses(financialRiskSystem, "Views reports");
Person configurationUser = model.addPerson(Location.Internal, "Configuration User", "A regular business user who can also configure the parameters used in the risk calculations");
configurationUser.uses(financialRiskSystem, "Configures parameters");
SoftwareSystem tradeDataSystem = model.addSoftwareSystem(Location.External, "Trade Data System", "The system of record for trades of type X");
financialRiskSystem.uses(tradeDataSystem, "Gets trade data from");
SoftwareSystem referenceDataSystem = model.addSoftwareSystem(Location.External, "Reference Data System", "Manages reference data for all counterparties the bank interacts with");
financialRiskSystem.uses(referenceDataSystem, "Gets counterparty data from");
SoftwareSystem emailSystem = model.addSoftwareSystem(Location.Internal, "E-mail system", "Microsoft Exchange");
financialRiskSystem.uses(emailSystem, "Sends a notification that a report is ready via e-mail to");
emailSystem.sendsSomethingTo(businessUser, "Sends a notification that a report is ready via e-mail to");
SoftwareSystem centralMonitoringService = model.addSoftwareSystem(Location.Internal, "Central Monitoring Service", "The bank-wide monitoring and alerting dashboard");
financialRiskSystem.uses(centralMonitoringService, "Sends critical failure alerts to");
SoftwareSystem activeDirectory = model.addSoftwareSystem(Location.Internal, "Active Directory", "Manages users and security roles across the bank");
financialRiskSystem.uses(activeDirectory, "Uses for authentication and authorisation");
// and create some views
ContextView contextView = model.createContextView(financialRiskSystem);
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
String modelAsJson = objectMapper.writeValueAsString(model);
System.out.println(modelAsJson);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment