static void Main() { Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); Model model = workspace.Model; 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 viewSet = workspace.Views; SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); Styles styles = viewSet.Configuration.Styles; styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#1168bd", Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b", Color = "#ffffff", Shape = Shape.Person }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Corporate Branding", "This is a model of my software system."); Model model = workspace.Model; 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.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(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.Configuration.Branding; branding.Logo = ImageUtils.GetImageAsDataUri(new FileInfo("structurizr-logo.png")); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Documentation - Structurizr", "An empty software architecture document using the Structurizr template."); Model model = workspace.Model; ViewSet views = workspace.Views; 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.Configuration.Styles; styles.Add(new ElementStyle(Tags.Person) { Shape = Shape.Person }); StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); // this is the Markdown version DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "structurizr" + Path.DirectorySeparatorChar + "markdown"); template.AddContextSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-context.md"))); template.AddFunctionalOverviewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-functional-overview.md"))); template.AddQualityAttributesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-quality-attributes.md"))); template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-constraints.md"))); template.AddPrinciplesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-principles.md"))); template.AddSoftwareArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-software-architecture.md"))); template.AddDataSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-data.md"))); template.AddInfrastructureArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-infrastructure-architecture.md"))); template.AddDeploymentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-deployment.md"))); template.AddDevelopmentEnvironmentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-development-environment.md"))); template.AddOperationAndSupportSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-operation-and-support.md"))); template.AddDecisionLogSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-decision-log.md"))); // this is the AsciiDoc version // DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "structurizr" + Path.DirectorySeparatorChar + "asciidoc"); // template.AddContextSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-context.adoc"))); // template.AddFunctionalOverviewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-functional-overview.adoc"))); // template.AddQualityAttributesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-quality-attributes.adoc"))); // template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-constraints.adoc"))); // template.AddPrinciplesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-principles.adoc"))); // template.AddSoftwareArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-software-architecture.adoc"))); // template.AddDataSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-data.adoc"))); // template.AddInfrastructureArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-infrastructure-architecture.adoc"))); // template.AddDeploymentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-deployment.adoc"))); // template.AddDevelopmentEnvironmentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-development-environment.adoc"))); // template.AddOperationAndSupportSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-operation-and-support.adoc"))); // template.AddDecisionLogSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-decision-log.adoc"))); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Client-side encrypted workspace", "This is a client-side encrypted workspace. The passphrase is 'password'."); Model model = workspace.Model; 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 viewSet = workspace.Views; SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); Styles styles = viewSet.Configuration.Styles; styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#d34407", Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#f86628", Color = "#ffffff", Shape = Shape.Person }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.EncryptionStrategy = new AesEncryptionStrategy("password"); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main(string[] args) { Workspace workspace = new Workspace("RegAndElig", "Registration and Eligibility Model."); var model = workspace.Model; Person user = model.AddPerson("Service Provider", "A user of my software system."); SoftwareSystem softwareSystem = model.AddSoftwareSystem("Ess Web", "Web Front end."); user.Uses(softwareSystem, "Uses"); ViewSet viewSet = workspace.Views; SystemContextView contextView = viewSet.CreateSystemContextView( softwareSystem, "context", "A simple example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); Styles styles = viewSet.Configuration.Styles; styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#1168bd", Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b", Color = "#ffffff" }); StructurizrClient structurizrClient = new StructurizrClient("key", "secret"); structurizrClient.PutWorkspace(1234, workspace); }
static void Main() { Workspace workspace = new Workspace("Styling Relationships", "This is a model of my software system."); Model model = workspace.Model; 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.Views; ContainerView containerView = views.CreateContainerView(softwareSystem, "containers", "An example of a container diagram."); containerView.AddAllElements(); Styles styles = workspace.Views.Configuration.Styles; // example 1 // styles.Add(new RelationshipStyle(Tags.Relationship) { Color = "#ff0000" }); // example 2 // model.Relationships.Where(r => "HTTPS".Equals(r.Technology)).ToList().ForEach(r => r.AddTags("HTTPS")); // model.Relationships.Where(r => "JDBC".Equals(r.Technology)).ToList().ForEach(r => r.AddTags("JDBC")); // styles.Add(new RelationshipStyle("HTTPS") { Color = "#ff0000" }); // styles.Add(new RelationshipStyle("JDBC") { Color = "#0000ff" }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Documentation - arc42", "An empty software architecture document using the arc42 template."); Model model = workspace.Model; ViewSet views = workspace.Views; 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.Configuration.Styles; styles.Add(new ElementStyle(Tags.Person) { Shape = Shape.Person }); Arc42DocumentationTemplate template = new Arc42DocumentationTemplate(workspace); // this is the Markdown version DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "arc42" + Path.DirectorySeparatorChar + "markdown"); template.AddIntroductionAndGoalsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-introduction-and-goals.md"))); template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-architecture-constraints.md"))); template.AddContextAndScopeSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-system-scope-and-context.md"))); template.AddSolutionStrategySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-solution-strategy.md"))); template.AddBuildingBlockViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-building-block-view.md"))); template.AddRuntimeViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-runtime-view.md"))); template.AddDeploymentViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-deployment-view.md"))); template.AddCrosscuttingConceptsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-crosscutting-concepts.md"))); template.AddArchitecturalDecisionsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-architecture-decisions.md"))); template.AddRisksAndTechnicalDebtSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-quality-requirements.md"))); template.AddQualityRequirementsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-risks-and-technical-debt.md"))); template.AddGlossarySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-glossary.md"))); // this is the AsciiDoc version // DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "arc42" + Path.DirectorySeparatorChar + "asciidoc"); // template.AddIntroductionAndGoalsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-introduction-and-goals.adoc"))); // template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-architecture-constraints.adoc"))); // template.AddContextAndScopeSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-system-scope-and-context.adoc"))); // template.AddSolutionStrategySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-solution-strategy.adoc"))); // template.AddBuildingBlockViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-building-block-view.adoc"))); // template.AddRuntimeViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-runtime-view.adoc"))); // template.AddDeploymentViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-deployment-view.adoc"))); // template.AddCrosscuttingConceptsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-crosscutting-concepts.adoc"))); // template.AddArchitecturalDecisionsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-architecture-decisions.adoc"))); // template.AddRisksAndTechnicalDebtSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-quality-requirements.adoc"))); // template.AddQualityRequirementsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-risks-and-technical-debt.adoc"))); // template.AddGlossarySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-glossary.adoc"))); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
public void UploadWorkspaceToStructurizr(Workspace workspace, StructurizerOptions structurizerOptions) { var structurizrClient = new StructurizrClient( structurizerOptions.ApiKey, structurizerOptions.ApiSecret); structurizrClient.PutWorkspace(structurizerOptions.WorkspaceId, workspace); }
static void Main(string[] args) { Console.WriteLine("Creating diagrams"); var workspace = CreateWorkspace(); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
private static void UploadWorkspaceToStructurizr(Workspace workspace) { var structurizrClient = new StructurizrClient(_apiKey, _apiSecret) { MergeFromRemote = false }; structurizrClient.PutWorkspace(_workspaceId, workspace); Console.WriteLine($"Workspace can be viewed at {string.Format(WorkspaceUrlFormat, _workspaceId)}"); }
static void Main(string[] args) { Workspace workspace = new Workspace("Remote workspace", "A test remote workspace"); workspace.Source = "https://gist.githubusercontent.com/simonbrowndotje/3bc87b89b82358c74f96470edc7519ad/raw/642ebcffb84e0c6ae612853919cf78b181bb65fe/structurizr-techtribesje.json"; StructurizrClient structurizrClient = new StructurizrClient("key", "secret"); structurizrClient.PutWorkspace(1234, workspace); }
private static void UploadToStructurizr(string[] args) { var workspace = ArchitectureModel(new InfrastructureEnvironment("prod")); var configuration = Configuration(args); var client = new StructurizrClient(configuration["Structurizr:Key"], configuration["Structurizr:Secret"]) { WorkspaceArchiveLocation = null }; client.PutWorkspace(int.Parse(configuration["Structurizr:WorkspaceId"]), workspace); }
public void Test_PutWorkspace_ThrowsAnException_WhenANullWorkspaceIsSpecified() { try { _structurizrClient = new StructurizrClient("key", "secret"); _structurizrClient.PutWorkspace(1234, null); throw new TestFailedException(); } catch (ArgumentException iae) { Assert.Equal("The workspace must not be null.", iae.Message); } }
public void Test_PutWorkspace_ThrowsAnException_WhenTheWorkspaceIdIsNotValid() { try { _structurizrClient = new StructurizrClient("key", "secret"); _structurizrClient.PutWorkspace(0, new Workspace("Name", "Description")); throw new TestFailedException(); } catch (ArgumentException iae) { Assert.Equal("The workspace ID must be a positive integer.", iae.Message); } }
static void Main() { Workspace workspace = new Workspace("Documentation - Viewpoints and Perspectives", "An empty software architecture document using the Viewpoints and Perspectives template."); Model model = workspace.Model; ViewSet views = workspace.Views; 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.Configuration.Styles; styles.Add(new ElementStyle(Tags.Person) { Shape = Shape.Person }); ViewpointsAndPerspectivesDocumentation template = new ViewpointsAndPerspectivesDocumentation(workspace); // this is the Markdown version DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "viewpointsandperspectives" + Path.DirectorySeparatorChar + "markdown"); template.AddIntroductionSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-introduction.md"))); template.AddGlossarySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-glossary.md"))); template.AddSystemStakeholdersAndRequirementsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-system-stakeholders-and-requirements.md"))); template.AddArchitecturalForcesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-architectural-forces.md"))); template.AddArchitecturalViewsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-architectural-views"))); template.AddSystemQualitiesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-system-qualities.md"))); template.AddAppendicesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-appendices.md"))); // this is the AsciiDoc version // DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "viewpointsandperspectives" + Path.DirectorySeparatorChar + "asciidoc"); // template.AddIntroductionSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-introduction.adoc"))); // template.AddGlossarySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-glossary.adoc"))); // template.AddSystemStakeholdersAndRequirementsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-system-stakeholders-and-requirements.adoc"))); // template.AddArchitecturalForcesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-architectural-forces.adoc"))); // template.AddArchitecturalViewsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-architectural-views"))); // template.AddSystemQualitiesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-system-qualities.adoc"))); // template.AddAppendicesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-appendices.adoc"))); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("HTTP-based health checks example", "An example of how to use the HTTP-based health checks feature"); Model model = workspace.Model; ViewSet views = workspace.Views; 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(DatabaseTag); 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.Environment = "Live"; deploymentView.AddAllDeploymentNodes(); views.Configuration.Styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); views.Configuration.Styles.Add(new ElementStyle(DatabaseTag) { Shape = Shape.Cylinder }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); WorkspaceUtils.PrintWorkspaceAsJson(workspace); Console.ReadKey(); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Corporate Branding", "This is a model of my software system."); Model model = workspace.Model; 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.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(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)"); template.AddQualityAttributesSection(softwareSystem, Format.Markdown, "Here is some information about the quality attributes..."); template.AddSoftwareArchitectureSection(softwareSystem, Format.Markdown, "Here is some information about the software architecture..."); template.AddOperationAndSupportSection(softwareSystem, Format.Markdown, "Here is some information about how to operate and support the software..."); template.AddDecisionLogSection(softwareSystem, Format.Markdown, "Here is some information about the decisions made..."); Branding branding = views.Configuration.Branding; branding.Color1 = new ColorPair("#02172c", "#ffffff"); branding.Color2 = new ColorPair("#08427b", "#ffffff"); branding.Color3 = new ColorPair("#1168bd", "#ffffff"); branding.Color4 = new ColorPair("#438dd5", "#ffffff"); branding.Color5 = new ColorPair("#85bbf0", "#ffffff"); branding.Logo = ImageUtils.GetImageAsDataUri(new FileInfo("structurizr-logo.png")); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Filtered Views", "An example of using filtered views."); Model model = workspace.Model; 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(FutureState); user.Uses(softwareSystemA, "Uses for tasks 1 and 2").AddTags(CurrentState); user.Uses(softwareSystemA, "Uses for task 1").AddTags(FutureState); user.Uses(softwareSystemB, "Uses for task 2").AddTags(FutureState); ViewSet views = workspace.Views; EnterpriseContextView enterpriseContextView = views.CreateEnterpriseContextView("EnterpriseContext", "An example Enterprise Context diagram."); enterpriseContextView.AddAllElements(); views.CreateFilteredView(enterpriseContextView, "CurrentState", "The current context.", FilterMode.Exclude, FutureState); views.CreateFilteredView(enterpriseContextView, "FutureState", "The future state context after Software System B is live.", FilterMode.Exclude, CurrentState); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#91a437", Shape = Shape.RoundedBox }); styles.Add(new ElementStyle(Tags.Person) { Background = "#6a7b15", Shape = Shape.Person }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Styling Elements", "This is a model of my software system."); Model model = workspace.Model; 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.Views; ContainerView containerView = views.CreateContainerView(softwareSystem, "containers", "An example of a container diagram."); containerView.AddAllElements(); Styles styles = workspace.Views.Configuration.Styles; // example 1 // styles.Add(new ElementStyle(Tags.Element) { Background = "#438dd5", Color = "#ffffff" }); // example 2 // styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); // styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b" }); // styles.Add(new ElementStyle(Tags.Container) { Background = "#438dd5" }); // example 3 // styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); // styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b" , Shape = Shape.Person }); // styles.Add(new ElementStyle(Tags.Container) { Background = "#438dd5" }); // database.AddTags("Database"); // styles.Add(new ElementStyle("Database") { Shape = Shape.Cylinder }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Theme", "This is a model of my software system."); Model model = workspace.Model; 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 viewSet = workspace.Views; SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); // add a theme viewSet.Configuration.Theme = "https://raw.githubusercontent.com/structurizr/dotnet/master/Structurizr.Examples/Theme/theme.json"; StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { 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.Model; 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(AlertTag); 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.Views; 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.Configuration.Styles; financialRiskSystem.AddTags("Risk System"); styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff", FontSize = 34 }); styles.Add(new ElementStyle("Risk System") { Background = "#550000", Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.SoftwareSystem) { Width = 650, Height = 400, Background = "#801515", Shape = Shape.RoundedBox }); styles.Add(new ElementStyle(Tags.Person) { Width = 550, Background = "#d46a6a", Shape = Shape.Person }); styles.Add(new RelationshipStyle(Tags.Relationship) { Thickness = 4, Dashed = false, FontSize = 32, Width = 400 }); styles.Add(new RelationshipStyle(Tags.Synchronous) { Dashed = false }); styles.Add(new RelationshipStyle(Tags.Asynchronous) { Dashed = true }); styles.Add(new RelationshipStyle(AlertTag) { Color = "#ff0000" }); styles.Add(new ElementStyle("Future State") { Opacity = 30, Border = Border.Dashed }); styles.Add(new RelationshipStyle("Future State") { Opacity = 30, Dashed = true }); StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); DirectoryInfo documentationRoot = new DirectoryInfo("FinancialRiskSystem"); template.AddContextSection(financialRiskSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "context.adoc"))); template.AddFunctionalOverviewSection(financialRiskSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "functional-overview.md"))); template.AddQualityAttributesSection(financialRiskSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "quality-attributes.md"))); template.AddImages(documentationRoot); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, Create()); }
public void PersistWorkspace(Workspace workspace) { WorkspaceManager.CommitChanges(); _structurizrClient.PutWorkspace(_workSpaceId, workspace); }
static void Banking() { const long workspaceId = 0; const string apiKey = ""; const string apiSecret = ""; StructurizrClient structurizrClient = new StructurizrClient(apiKey, apiSecret); Workspace workspace = new Workspace("C4 Model Microservices - Sistema de Monitoreo", "Sistema de Monitoreo del Traslado Aéreo de Vacunas SARS-CoV-2"); Model model = workspace.Model; ViewSet viewSet = workspace.Views; // 1. Diagrama de Contexto SoftwareSystem monitoringSystem = model.AddSoftwareSystem("Monitoreo del Traslado Aéreo de Vacunas SARS-CoV-2", "Permite el seguimiento y monitoreo del traslado aéreo a nuestro país de las vacunas para la COVID-19."); SoftwareSystem googleMaps = model.AddSoftwareSystem("Google Maps", "Plataforma que ofrece una REST API de información geo referencial."); SoftwareSystem aircraftSystem = model.AddSoftwareSystem("Aircraft System", "Permite transmitir información en tiempo real por el avión del vuelo a nuestro sistema"); Person ciudadano = model.AddPerson("Ciudadano", "Ciudadano peruano."); Person periodista = model.AddPerson("Periodista", "Periodista de los diferentes medios de prensa."); Person developer = model.AddPerson("Developer", "Developer - Open Data."); ciudadano.Uses(monitoringSystem, "Realiza consultas para mantenerse al tanto de la planificación de los vuelos hasta la llegada del lote de vacunas al Perú"); periodista.Uses(monitoringSystem, "Realiza consultas para mantenerse al tanto de la planificación de los vuelos hasta la llegada del lote de vacunas al Perú"); developer.Uses(monitoringSystem, "Realiza consultas a la REST API para mantenerse al tanto de la planificación de los vuelos hasta la llegada del lote de vacunas al Perú"); monitoringSystem.Uses(aircraftSystem, "Consulta información en tiempo real por el avión del vuelo"); monitoringSystem.Uses(googleMaps, "Usa"); SystemContextView contextView = viewSet.CreateSystemContextView(monitoringSystem, "Contexto", "Diagrama de contexto"); contextView.PaperSize = PaperSize.A4_Landscape; contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); // Tags monitoringSystem.AddTags("SistemaMonitoreo"); googleMaps.AddTags("GoogleMaps"); aircraftSystem.AddTags("AircraftSystem"); ciudadano.AddTags("Ciudadano"); periodista.AddTags("Periodista"); developer.AddTags("Developer"); Styles styles = viewSet.Configuration.Styles; styles.Add(new ElementStyle("Ciudadano") { Background = "#0a60ff", Color = "#ffffff", Shape = Shape.Person }); styles.Add(new ElementStyle("Periodista") { Background = "#08427b", Color = "#ffffff", Shape = Shape.Person }); styles.Add(new ElementStyle("Developer") { Background = "#facc2e", Shape = Shape.Robot }); styles.Add(new ElementStyle("SistemaMonitoreo") { Background = "#008f39", Color = "#ffffff", Shape = Shape.RoundedBox }); styles.Add(new ElementStyle("GoogleMaps") { Background = "#90714c", Color = "#ffffff", Shape = Shape.RoundedBox }); styles.Add(new ElementStyle("AircraftSystem") { Background = "#2f95c7", Color = "#ffffff", Shape = Shape.RoundedBox }); // 2. Diagrama de Contenedores Container mobileApplication = monitoringSystem.AddContainer("Mobile App", "Permite a los usuarios visualizar un dashboard con el resumen de toda la información del traslado de los lotes de vacunas.", "Flutter"); Container webApplication = monitoringSystem.AddContainer("Web App", "Permite a los usuarios visualizar un dashboard con el resumen de toda la información del traslado de los lotes de vacunas.", "Flutter Web"); Container landingPage = monitoringSystem.AddContainer("Landing Page", "", "Flutter Web"); Container apiGateway = monitoringSystem.AddContainer("API Gateway", "API Gateway", "Spring Boot port 8080"); Container flightPlanningContext = monitoringSystem.AddContainer("Flight Planning Context", "Bounded Context del Microservicio de Planificación de Vuelos", "Spring Boot port 8081"); Container airportContext = monitoringSystem.AddContainer("Airport Context", "Bounded Context del Microservicio de información de Aeropuertos", "Spring Boot port 8082"); Container aircraftInventoryContext = monitoringSystem.AddContainer("Aircraft Inventory Context", "Bounded Context del Microservicio de Inventario de Aviones", "Spring Boot port 8083"); Container vaccinesInventoryContext = monitoringSystem.AddContainer("Vaccines Inventory Context", "Bounded Context del Microservicio de Inventario de Vacunas", "Spring Boot port 8084"); Container monitoringContext = monitoringSystem.AddContainer("Monitoring Context", "Bounded Context del Microservicio de Monitoreo en tiempo real del status y ubicación del vuelo que transporta las vacunas", "Spring Boot port 8085"); Container messageBus = monitoringSystem.AddContainer("Bus de Mensajes en Cluster de Alta Disponibilidad", "Transporte de eventos del dominio.", "RabbitMQ"); Container flightPlanningContextDatabase = monitoringSystem.AddContainer("Flight Planning Context DB", "", "Oracle"); Container airportContextDatabase = monitoringSystem.AddContainer("Airport Context DB", "", "Oracle"); Container aircraftInventoryContextDatabase = monitoringSystem.AddContainer("Aircraft Inventory Context DB", "", "Oracle"); Container vaccinesInventoryContextDatabase = monitoringSystem.AddContainer("Vaccines Inventory Context DB", "", "Oracle"); Container monitoringContextDatabase = monitoringSystem.AddContainer("Monitoring Context DB", "", "Oracle"); Container monitoringContextReplicaDatabase = monitoringSystem.AddContainer("Monitoring Context DB Replica", "", "Oracle"); Container monitoringContextReactiveDatabase = monitoringSystem.AddContainer("Monitoring Context Reactive DB", "", "Firebase Cloud Firestore"); ciudadano.Uses(mobileApplication, "Consulta"); ciudadano.Uses(webApplication, "Consulta"); ciudadano.Uses(landingPage, "Consulta"); periodista.Uses(mobileApplication, "Consulta"); periodista.Uses(webApplication, "Consulta"); periodista.Uses(landingPage, "Consulta"); mobileApplication.Uses(apiGateway, "API Request", "JSON/HTTPS"); webApplication.Uses(apiGateway, "API Request", "JSON/HTTPS"); developer.Uses(apiGateway, "API Request", "JSON/HTTPS"); apiGateway.Uses(flightPlanningContext, "API Request", "JSON/HTTPS"); apiGateway.Uses(airportContext, "API Request", "JSON/HTTPS"); apiGateway.Uses(aircraftInventoryContext, "API Request", "JSON/HTTPS"); apiGateway.Uses(vaccinesInventoryContext, "API Request", "JSON/HTTPS"); apiGateway.Uses(monitoringContext, "API Request", "JSON/HTTPS"); flightPlanningContext.Uses(messageBus, "Publica y consume eventos del dominio"); flightPlanningContext.Uses(flightPlanningContextDatabase, "", "JDBC"); airportContext.Uses(messageBus, "Publica y consume eventos del dominio"); airportContext.Uses(airportContextDatabase, "", "JDBC"); aircraftInventoryContext.Uses(messageBus, "Publica y consume eventos del dominio"); aircraftInventoryContext.Uses(aircraftInventoryContextDatabase, "", "JDBC"); vaccinesInventoryContext.Uses(messageBus, "Publica y consume eventos del dominio"); vaccinesInventoryContext.Uses(vaccinesInventoryContextDatabase, "", "JDBC"); monitoringContext.Uses(messageBus, "Publica y consume eventos del dominio"); monitoringContext.Uses(monitoringContextDatabase, "", "JDBC"); monitoringContext.Uses(monitoringContextReplicaDatabase, "", "JDBC"); monitoringContext.Uses(monitoringContextReactiveDatabase, "", ""); monitoringContextDatabase.Uses(monitoringContextReplicaDatabase, "Replica"); monitoringContext.Uses(googleMaps, "API Request", "JSON/HTTPS"); monitoringContext.Uses(aircraftSystem, "API Request", "JSON/HTTPS"); // Tags mobileApplication.AddTags("MobileApp"); webApplication.AddTags("WebApp"); landingPage.AddTags("LandingPage"); apiGateway.AddTags("APIGateway"); flightPlanningContext.AddTags("FlightPlanningContext"); flightPlanningContextDatabase.AddTags("FlightPlanningContextDatabase"); airportContext.AddTags("AirportContext"); airportContextDatabase.AddTags("AirportContextDatabase"); aircraftInventoryContext.AddTags("AircraftInventoryContext"); aircraftInventoryContextDatabase.AddTags("AircraftInventoryContextDatabase"); vaccinesInventoryContext.AddTags("VaccinesInventoryContext"); vaccinesInventoryContextDatabase.AddTags("VaccinesInventoryContextDatabase"); monitoringContext.AddTags("MonitoringContext"); monitoringContextDatabase.AddTags("MonitoringContextDatabase"); monitoringContextReplicaDatabase.AddTags("MonitoringContextReplicaDatabase"); monitoringContextReactiveDatabase.AddTags("MonitoringContextReactiveDatabase"); messageBus.AddTags("MessageBus"); styles.Add(new ElementStyle("MobileApp") { Background = "#9d33d6", Color = "#ffffff", Shape = Shape.MobileDevicePortrait, Icon = "" }); styles.Add(new ElementStyle("WebApp") { Background = "#9d33d6", Color = "#ffffff", Shape = Shape.WebBrowser, Icon = "" }); styles.Add(new ElementStyle("LandingPage") { Background = "#929000", Color = "#ffffff", Shape = Shape.WebBrowser, Icon = "" }); styles.Add(new ElementStyle("APIGateway") { Shape = Shape.RoundedBox, Background = "#0000ff", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("FlightPlanningContext") { Shape = Shape.Hexagon, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("FlightPlanningContextDatabase") { Shape = Shape.Cylinder, Background = "#ff0000", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("AirportContext") { Shape = Shape.Hexagon, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("AirportContextDatabase") { Shape = Shape.Cylinder, Background = "#ff0000", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("AircraftInventoryContext") { Shape = Shape.Hexagon, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("AircraftInventoryContextDatabase") { Shape = Shape.Cylinder, Background = "#ff0000", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("VaccinesInventoryContext") { Shape = Shape.Hexagon, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("VaccinesInventoryContextDatabase") { Shape = Shape.Cylinder, Background = "#ff0000", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("MonitoringContext") { Shape = Shape.Hexagon, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("MonitoringContextDatabase") { Shape = Shape.Cylinder, Background = "#ff0000", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("MonitoringContextReplicaDatabase") { Shape = Shape.Cylinder, Background = "#ff0000", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("MonitoringContextReactiveDatabase") { Shape = Shape.Cylinder, Background = "#ff0000", Color = "#ffffff", Icon = "" }); styles.Add(new ElementStyle("MessageBus") { Width = 850, Background = "#fd8208", Color = "#ffffff", Shape = Shape.Pipe, Icon = "" }); ContainerView containerView = viewSet.CreateContainerView(monitoringSystem, "Contenedor", "Diagrama de contenedores"); contextView.PaperSize = PaperSize.A4_Landscape; containerView.AddAllElements(); // 3. Diagrama de Componentes Component domainLayer = monitoringContext.AddComponent("Domain Layer", "", "Spring Boot"); Component monitoringController = monitoringContext.AddComponent("Monitoring Controller", "REST API endpoints de monitoreo.", "Spring Boot REST Controller"); Component monitoringApplicationService = monitoringContext.AddComponent("Monitoring Application Service", "Provee métodos para el monitoreo, pertenece a la capa Application de DDD", "Spring Component"); Component flightRepository = monitoringContext.AddComponent("Flight Repository", "Información del vuelo", "Spring Component"); Component vaccineLoteRepository = monitoringContext.AddComponent("VaccineLote Repository", "Información de lote de vacunas", "Spring Component"); Component locationRepository = monitoringContext.AddComponent("Location Repository", "Ubicación del vuelo", "Spring Component"); Component aircraftSystemFacade = monitoringContext.AddComponent("Aircraft System Facade", "", "Spring Component"); apiGateway.Uses(monitoringController, "", "JSON/HTTPS"); monitoringController.Uses(monitoringApplicationService, "Invoca métodos de monitoreo"); monitoringController.Uses(aircraftSystemFacade, "Usa"); monitoringApplicationService.Uses(domainLayer, "Usa", ""); monitoringApplicationService.Uses(flightRepository, "", "JDBC"); monitoringApplicationService.Uses(vaccineLoteRepository, "", "JDBC"); monitoringApplicationService.Uses(locationRepository, "", "JDBC"); flightRepository.Uses(monitoringContextDatabase, "", "JDBC"); vaccineLoteRepository.Uses(monitoringContextDatabase, "", "JDBC"); locationRepository.Uses(monitoringContextDatabase, "", "JDBC"); locationRepository.Uses(monitoringContextReactiveDatabase, "", ""); locationRepository.Uses(googleMaps, "", "JSON/HTTPS"); aircraftSystemFacade.Uses(aircraftSystem, "JSON/HTTPS"); // Tags domainLayer.AddTags("DomainLayer"); monitoringController.AddTags("MonitoringController"); monitoringApplicationService.AddTags("MonitoringApplicationService"); flightRepository.AddTags("FlightRepository"); vaccineLoteRepository.AddTags("VaccineLoteRepository"); locationRepository.AddTags("LocationRepository"); aircraftSystemFacade.AddTags("AircraftSystemFacade"); styles.Add(new ElementStyle("DomainLayer") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("MonitoringController") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("MonitoringApplicationService") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("MonitoringDomainModel") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("FlightStatus") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("FlightRepository") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("VaccineLoteRepository") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("LocationRepository") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); styles.Add(new ElementStyle("AircraftSystemFacade") { Shape = Shape.Component, Background = "#facc2e", Icon = "" }); ComponentView componentView = viewSet.CreateComponentView(monitoringContext, "Components", "Component Diagram"); componentView.PaperSize = PaperSize.A4_Landscape; componentView.Add(mobileApplication); componentView.Add(webApplication); componentView.Add(apiGateway); componentView.Add(monitoringContextDatabase); componentView.Add(monitoringContextReactiveDatabase); componentView.Add(aircraftSystem); componentView.Add(googleMaps); componentView.AddAllComponents(); structurizrClient.UnlockWorkspace(workspaceId); structurizrClient.PutWorkspace(workspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Structurizr for .NET Annotations", "This is a model of my software system."); Model model = workspace.Model; 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", "Provides users with information.", "C#"); Container database = softwareSystem.AddContainer("Database", "Stores information.", "Relational database schema"); database.AddTags(DatabaseTag); string assemblyPath = typeof(StructurizrAnnotations).Assembly.Location; DefaultAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(Path.GetDirectoryName(assemblyPath)); AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly( assemblyPath, new ReaderParameters { AssemblyResolver = resolver } ); ComponentFinder componentFinder = new ComponentFinder( webApplication, "Structurizr.Examples.Annotations", new StructurizrAnnotationsComponentFinderStrategy(assembly) ); componentFinder.FindComponents(); model.AddImplicitRelationships(); ViewSet views = workspace.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllElements(); ContainerView containerView = views.CreateContainerView(softwareSystem, "Containers", "The container diagram from my software system."); containerView.AddAllElements(); ComponentView componentView = views.CreateComponentView(webApplication, "Components", "The component diagram for the web application."); componentView.AddAllElements(); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#1168bd" }); styles.Add(new ElementStyle(Tags.Container) { Background = "#438dd5" }); styles.Add(new ElementStyle(Tags.Component) { Background = "#85bbf0", Color = "#000000" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b", Shape = Shape.Person }); styles.Add(new ElementStyle(DatabaseTag) { Shape = Shape.Cylinder }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Widgets Limited", "Sells widgets to customers online."); Model model = workspace.Model; ViewSet views = workspace.Views; Styles styles = views.Configuration.Styles; model.Enterprise = 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.Url = "https://www.taxamo.com"; SoftwareSystem braintreePayments = model.AddSoftwareSystem(Location.External, "Braintree Payments", "Processes credit card payments on behalf of Widgets Limited."); braintreePayments.Url = "https://www.braintreepayments.com"; SoftwareSystem jerseyPost = model.AddSoftwareSystem(Location.External, "Jersey Post", "Calculates worldwide shipping costs for packages."); model.People.Where(p => p.Location == Location.External).ToList().ForEach(p => p.AddTags(ExternalTag)); model.People.Where(p => p.Location == Location.Internal).ToList().ForEach(p => p.AddTags(InternalTag)); model.SoftwareSystems.Where(ss => ss.Location == Location.External).ToList().ForEach(ss => ss.AddTags(ExternalTag)); model.SoftwareSystems.Where(ss => ss.Location == Location.Internal).ToList().ForEach(ss => ss.AddTags(InternalTag)); 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"); EnterpriseContextView enterpriseContextView = views.CreateEnterpriseContextView("EnterpriseContext", "The enterprise context for Widgets Limited."); enterpriseContextView.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("Enterprise Context", 1, Format.Markdown, "Here is some information about the Widgets Limited enterprise context... ![](embed:EnterpriseContext)"); 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.Add(new ElementStyle(Tags.SoftwareSystem) { Shape = Shape.RoundedBox }); styles.Add(new ElementStyle(Tags.Person) { Shape = Shape.Person }); styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); styles.Add(new ElementStyle(ExternalTag) { Background = "#EC5381", Border = Border.Dashed }); styles.Add(new ElementStyle(InternalTag) { Background = "#B60037" }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }
private static void updateWorkspaceToStructurizr(Workspace workspace) { StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.PutWorkspace(WORKSPACE_ID, workspace); }
internal void Publish() { var structrizrClient = new StructurizrClient(_config.ApiKey, _config.ApiSecret); structrizrClient.PutWorkspace(_config.WorkspaceId, _workspace); }
private static void CreateContosoExample(int workSpaceId, string apiKey, string apiSecret) { Workspace workspace = new Workspace("Contoso University", "A software architecture model of the Contoso University sample project."); Model model = workspace.Model; ViewSet views = workspace.Views; Styles styles = views.Configuration.Styles; Person universityStaff = model.AddPerson("University Staff", "A staff member of the Contoso University."); SoftwareSystem contosoUniversity = model.AddSoftwareSystem("Contoso University", "Allows staff to view and update student, course, and instructor information."); universityStaff.Uses(contosoUniversity, "uses"); SystemContextView contextView = views.CreateSystemContextView(contosoUniversity, "Context", "The system context view for the Contoso University system."); contextView.AddAllElements(); #region Containers //Container webApplication = contosoUniversity.AddContainer("Web Application", "Allows staff to view and update student, course, and instructor information.", "Microsoft ASP.NET MVC"); //Container database = contosoUniversity.AddContainer("Database", "Stores information about students, courses and instructors", "Microsoft SQL Server Express LocalDB"); //database.AddTags("Database"); //database.Url = "https://github.com/simonbrowndotje/ContosoUniversity/tree/master/ContosoUniversity/Migrations"; //universityStaff.Uses(webApplication, "Uses", "HTTPS"); //webApplication.Uses(database, "Reads from and writes to"); //ContainerView containerView = views.CreateContainerView(contosoUniversity, "Containers", "The containers that make up the Contoso University system."); //containerView.AddAllElements(); #endregion #region Dynamic components //ComponentFinder componentFinder = new ComponentFinder( // webApplication, // typeof(ContosoUniversity.MvcApplication).Namespace, // new TypeBasedComponentFinderStrategy( // new InterfaceImplementationTypeMatcher(typeof(System.Web.Mvc.IController), null, "ASP.NET MVC Controller"), // new ExtendsClassTypeMatcher(typeof(System.Data.Entity.DbContext), null, "Entity Framework DbContext") // ) //); //componentFinder.FindComponents(); //// connect the user to the web MVC controllers //webApplication.Components.ToList().FindAll(c => c.Technology == "ASP.NET MVC Controller").ForEach(c => universityStaff.Uses(c, "uses")); //// connect all DbContext components to the database //webApplication.Components.ToList().FindAll(c => c.Technology == "Entity Framework DbContext").ForEach(c => c.Uses(database, "Reads from and writes to")); //ComponentView componentView = views.CreateComponentView(webApplication, "Components", "The components inside the Contoso University web application."); //componentView.AddAllElements(); #endregion #region Documentation //Documentation documentation = workspace.Documentation; //FileInfo documentationRoot = new FileInfo(@"..\..\ContosoDocs"); //documentation.Add(contosoUniversity, SectionType.Context, DocumentationFormat.Markdown, // new FileInfo(Path.Combine(documentationRoot.FullName, "context.md"))); //documentation.Add(contosoUniversity, SectionType.FunctionalOverview, DocumentationFormat.Markdown, // new FileInfo(Path.Combine(documentationRoot.FullName, "functional-overview.md"))); //documentation.Add(contosoUniversity, SectionType.QualityAttributes, DocumentationFormat.Markdown, // new FileInfo(Path.Combine(documentationRoot.FullName, "quality-attributes.md"))); //documentation.AddImages(documentationRoot); #endregion // add some styling styles.Add(new ElementStyle(Tags.Person) { Background = "#0d4d4d", Color = "#ffffff", Shape = Shape.Person }); styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#003333", Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.Container) { Background = "#226666", Color = "#ffffff" }); styles.Add(new ElementStyle("Database") { Shape = Shape.Cylinder }); styles.Add(new ElementStyle(Tags.Component) { Background = "#407f7f", Color = "#ffffff" }); StructurizrClient structurizrClient = new StructurizrClient(apiKey, apiSecret); structurizrClient.PutWorkspace(workSpaceId, workspace); }
static void Main() { Workspace workspace = new Workspace("Microservices example", "An example of a microservices architecture, which includes asynchronous and parallel behaviour."); Model model = workspace.Model; 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(MicroserviceTag); Container customerDatabase = mySoftwareSystem.AddContainer("Customer Database", "Stores customer information.", "Oracle 12c"); customerDatabase.AddTags(DataStoreTag); Container reportingService = mySoftwareSystem.AddContainer("Reporting Service", "Creates normalised data for reporting purposes.", "Ruby"); reportingService.AddTags(MicroserviceTag); Container reportingDatabase = mySoftwareSystem.AddContainer("Reporting Database", "Stores a normalised version of all business data for ad hoc reporting purposes.", "MySQL"); reportingDatabase.AddTags(DataStoreTag); Container auditService = mySoftwareSystem.AddContainer("Audit Service", "Provides organisation-wide auditing facilities.", "C# .NET"); auditService.AddTags(MicroserviceTag); Container auditStore = mySoftwareSystem.AddContainer("Audit Store", "Stores information about events that have happened.", "Event Store"); auditStore.AddTags(DataStoreTag); Container messageBus = mySoftwareSystem.AddContainer("Message Bus", "Transport for business events.", "RabbitMQ"); messageBus.AddTags(MessageBusTag); 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.Views; 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.Add(customerService, "Confirms update to", customerApplication); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(Tags.Element) { Color = "#000000" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#ffbf00", Shape = Shape.Person }); styles.Add(new ElementStyle(Tags.Container) { Background = "#facc2E" }); styles.Add(new ElementStyle(MessageBusTag) { Width = 1600, Shape = Shape.Pipe }); styles.Add(new ElementStyle(MicroserviceTag) { Shape = Shape.Hexagon }); styles.Add(new ElementStyle(DataStoreTag) { Background = "#f5da81", Shape = Shape.Cylinder }); styles.Add(new RelationshipStyle(Tags.Relationship) { Routing = Routing.Orthogonal }); styles.Add(new RelationshipStyle(Tags.Asynchronous) { Dashed = true }); styles.Add(new RelationshipStyle(Tags.Synchronous) { Dashed = false }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }