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.PutWorkspaceAsync(WorkspaceId, workspace).Wait(); }
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); }
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); }
protected override void Write(SystemContextView view, TextWriter writer) { var showBoundary = view.EnterpriseBoundaryVisible ?? true; WriteProlog(view, writer); if (showBoundary) { var enterpriseName = view.Model.Enterprise.Name; writer.WriteLine($"Enterprise_Boundary({TokenizeName(enterpriseName)}, \"{enterpriseName}\") {{"); } view.Elements .Select(ev => ev.Element) .OrderBy(e => e.Name).ToList() .ForEach(e => Write(e, writer, showBoundary ? 1 : 0)); Write(view.Relationships, writer); if (showBoundary) { writer.WriteLine("}"); } WriteEpilog(view, writer); }
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.PutWorkspaceAsync(WorkspaceId, workspace).Wait(); }
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("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.PutWorkspaceAsync(WorkspaceId, workspace).Wait(); }
public void Write(SystemContextView view, TextWriter writer) { if (view == null) { throw new ArgumentException("A system context view must be specified."); } try { WriteHeader(view, writer); view.Elements .Select(ev => ev.Element) .OrderBy(e => e.Name).ToList() .ForEach(e => Write(e, writer, false)); Write(view.Relationships, writer); writer.WriteLine("@enduml"); writer.WriteLine(""); } catch (IOException e) { Console.WriteLine(e.StackTrace); } }
static void Main(string[] args) { Workspace workspace = new Workspace("Music Sample Manager architecture", "This is a model of the architecture of the Music Sample Manager project."); Model model = workspace.Model; Person musician = model.AddPerson("Musician", "A person who wants to write/record some music."); Person libraryAuthor = model.AddPerson("Author", "A person who authors samples to be used by musicians."); SoftwareSystem consoleApp = model.AddSoftwareSystem("msm.exe", "A console application that lets users perform MSM operations."); musician.Uses(consoleApp, "Uses"); SoftwareSystem desktopGUIApp = model.AddSoftwareSystem("Desktop GUI App", "A desktop application that lets uers perform MSM operations."); musician.Uses(desktopGUIApp, "Uses"); SoftwareSystem dawClient = model.AddSoftwareSystem("DAW Client", "Functionality built into DAWs that allows users to perform MSM operations."); musician.Uses(dawClient, "Uses"); SoftwareSystem website = model.AddSoftwareSystem("Website", "Website that allows musicians to browse packages, and authors to publish/manage packages."); musician.Uses(website, "Uses packages from"); libraryAuthor.Uses(website, "Publishes to"); SoftwareSystem serverSoftware = model.AddSoftwareSystem("Server software", "Handles submissions to the database, authentication, serving requests for packages, etc."); consoleApp.Uses(serverSoftware, "Communicates with"); dawClient.Uses(serverSoftware, "Interfaces with"); SoftwareSystem localPackageCache = model.AddSoftwareSystem("Local package cache", "Cache of downloaded packages, to be used by DAW projects."); consoleApp.Uses(localPackageCache, "Interfaces with"); dawClient.Uses(localPackageCache, "Works with"); ViewSet viewSet = workspace.Views; SystemContextView contextView = viewSet.CreateSystemContextView(consoleApp, "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 }); PublishWorkspace(workspace); }
private void PopulateWorkspace() { Model model = _workspace.Model; model.Enterprise = new Enterprise("Some Enterprise"); Person user = model.AddPerson(Location.Internal, "User", ""); SoftwareSystem softwareSystem = model.AddSoftwareSystem(Location.Internal, "Software System", ""); user.Uses(softwareSystem, "Uses"); SoftwareSystem emailSystem = model.AddSoftwareSystem(Location.External, "E-mail System", ""); softwareSystem.Uses(emailSystem, "Sends e-mail using"); emailSystem.Delivers(user, "Delivers e-mails to"); Container webApplication = softwareSystem.AddContainer("Web Application", "", ""); Container database = softwareSystem.AddContainer("Database", "", ""); user.Uses(webApplication, "Uses", "HTTP"); webApplication.Uses(database, "Reads from and writes to", "JDBC"); webApplication.Uses(emailSystem, "Sends e-mail using"); Component controller = webApplication.AddComponent("SomeController", "", "Spring MVC Controller"); Component emailComponent = webApplication.AddComponent("EmailComponent", ""); Component repository = webApplication.AddComponent("SomeRepository", "", "Spring Data"); user.Uses(controller, "Uses", "HTTP"); controller.Uses(repository, "Uses"); controller.Uses(emailComponent, "Sends e-mail using"); repository.Uses(database, "Reads from and writes to", "JDBC"); emailComponent.Uses(emailSystem, "Sends e-mails using", "SMTP"); EnterpriseContextView enterpriseContextView = _workspace.Views.CreateEnterpriseContextView("enterpriseContext", ""); enterpriseContextView.AddAllElements(); SystemContextView systemContextView = _workspace.Views.CreateSystemContextView(softwareSystem, "systemContext", ""); systemContextView.AddAllElements(); ContainerView containerView = _workspace.Views.CreateContainerView(softwareSystem, "containers", ""); containerView.AddAllElements(); ComponentView componentView = _workspace.Views.CreateComponentView(webApplication, "components", ""); componentView.AddAllElements(); DynamicView dynamicView = _workspace.Views.CreateDynamicView(webApplication, "dynamic", ""); dynamicView.Add(user, "Requests /something", controller); dynamicView.Add(controller, repository); dynamicView.Add(repository, "select * from something", database); }
static void Main() { Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); Model model = workspace.Model; model.Enterprise = new Enterprise("Some Enterprise"); Person user = model.AddPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system."); var userUsesSystemRelation = user.Uses(softwareSystem, "Uses"); // a direction could be added to relation (active in all views) // userUsesSystemRelation.SetDirection(DirectionValues.Right); ViewSet views = workspace.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); // C4PlantUMLWriter support view specific directions too, e.g. "User" should be left of "Software System" only in this view contextView.Relationships .First(rv => rv.Relationship.SourceId == user.Id && rv.Relationship.DestinationId == softwareSystem.Id) .SetDirection(DirectionValues.Right); using (var stringWriter = new StringWriter()) { var plantUmlWriter = new C4PlantUmlWriter(); plantUmlWriter.Write(workspace, stringWriter); Console.WriteLine(stringWriter.ToString()); } Container webApplication = softwareSystem.AddContainer("Web Application", "Delivers content", "Java and spring MVC"); Container database = softwareSystem.AddContainer("Database", "Stores information", "Relational Database Schema"); // Additional mark it as database database.SetIsDatabase(true); user.Uses(webApplication, "uses", "HTTP"); webApplication.Uses(database, "Reads from and writes to", "JDBC").SetDirection(DirectionValues.Right); var containerView = views.CreateContainerView(softwareSystem, "containers", ""); containerView.AddAllElements(); using (var stringWriter = new StringWriter()) { var plantUmlWriter = new C4PlantUmlWriter(); plantUmlWriter.Write(containerView, stringWriter); Console.WriteLine(stringWriter.ToString()); } }
public void Test_AddNearestNeighbours_AddsNearestNeighbours_WhenThereAreSomeNearestNeighbours() { SoftwareSystem softwareSystemA = model.AddSoftwareSystem("System A", "Description"); SoftwareSystem softwareSystemB = model.AddSoftwareSystem("System B", "Description"); Person userA = model.AddPerson("User A", "Description"); Person userB = model.AddPerson("User B", "Description"); // userA -> systemA -> system -> systemB -> userB userA.Uses(softwareSystemA, ""); softwareSystemA.Uses(softwareSystem, ""); softwareSystem.Uses(softwareSystemB, ""); softwareSystemB.Delivers(userB, ""); // userA -> systemA -> web application -> systemB -> userB // web application -> database Container webApplication = softwareSystem.AddContainer("Web Application", "", ""); Container database = softwareSystem.AddContainer("Database", "", ""); softwareSystemA.Uses(webApplication, ""); webApplication.Uses(softwareSystemB, ""); webApplication.Uses(database, ""); // userA -> systemA -> controller -> service -> repository -> database Component controller = webApplication.AddComponent("Controller", ""); Component service = webApplication.AddComponent("Service", ""); Component repository = webApplication.AddComponent("Repository", ""); softwareSystemA.Uses(controller, ""); controller.Uses(service, ""); service.Uses(repository, ""); repository.Uses(database, ""); // userA -> systemA -> controller -> service -> systemB -> userB service.Uses(softwareSystemB, ""); view.AddNearestNeighbours(softwareSystem); Assert.AreEqual(3, view.Elements.Count); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystemA))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystem))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystemB))); view = new SystemContextView(softwareSystem, "context", "Description"); view.AddNearestNeighbours(softwareSystemA); Assert.AreEqual(3, view.Elements.Count); Assert.IsTrue(view.Elements.Contains(new ElementView(userA))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystemA))); Assert.IsTrue(view.Elements.Contains(new ElementView(softwareSystem))); }
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("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); }
public void test_writeSystemContextView() { PopulateWorkspace(); SystemContextView systemContextView = _workspace.Views.SystemContextViews.First(); _plantUMLWriter.Write(systemContextView, _stringWriter); Assert.Equal("@startuml" + Environment.NewLine + "title Software System - System Context" + Environment.NewLine + "component \"E-mail System\" <<Software System>> as 4" + Environment.NewLine + "component \"Software System\" <<Software System>> as 2" + Environment.NewLine + "actor \"User\" <<Person>> as 1" + Environment.NewLine + "4 ..> 1 : Delivers e-mails to" + Environment.NewLine + "2 ..> 4 : Sends e-mail using" + Environment.NewLine + "1 ..> 2 : Uses" + Environment.NewLine + "@enduml" + Environment.NewLine + Environment.NewLine, _stringWriter.ToString()); }
public void Test_WriteSystemContextView() { PopulateWorkspace(); SystemContextView systemContextView = _workspace.Views.SystemContextViews.First(); _plantUMLWriter.Write(systemContextView, _stringWriter); Assert.AreEqual("@startuml" + Environment.NewLine + "title Software System - System Context" + Environment.NewLine + "[E-mail System] <<Software System>> as EmailSystem" + Environment.NewLine + "[Software System] <<Software System>> as SoftwareSystem" + Environment.NewLine + "actor User" + Environment.NewLine + "EmailSystem ..> User : Delivers e-mails to" + Environment.NewLine + "SoftwareSystem ..> EmailSystem : Sends e-mail using" + Environment.NewLine + "User ..> SoftwareSystem : Uses" + Environment.NewLine + "@enduml" + Environment.NewLine + "" + Environment.NewLine, _stringWriter.ToString()); }
static void Main(string[] args) { // a Structurizr workspace is the wrapper for a software architecture model, views and documentation Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); Model model = workspace.Model; // add some elements to your software architecture 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"); // define some views (the diagrams you would like to see) ViewSet views = workspace.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.PaperSize = PaperSize.A5_Landscape; contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); // add some documentation StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); template.AddContextSection(softwareSystem, Format.Markdown, "Here is some context about the software system...\n" + "\n" + "![](embed:SystemContext)"); // add some styling Styles styles = views.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 }); UploadWorkspaceToStructurizr(workspace); }
public void Test_AddDefaultElements() { Person user1 = Model.AddPerson("User 1"); Person user2 = Model.AddPerson("User 2"); SoftwareSystem softwareSystem1 = Model.AddSoftwareSystem("Software System 1"); SoftwareSystem softwareSystem2 = Model.AddSoftwareSystem("Software System 2"); user1.Uses(softwareSystem1, ""); softwareSystem1.Uses(softwareSystem2, ""); user2.Uses(softwareSystem2, ""); view = Views.CreateSystemContextView(softwareSystem1, "key", "description"); view.AddDefaultElements(); Assert.Equal(3, view.Elements.Count); Assert.True(view.Elements.Contains(new ElementView(user1))); Assert.False(view.Elements.Contains(new ElementView(user2))); Assert.True(view.Elements.Contains(new ElementView(softwareSystem1))); Assert.True(view.Elements.Contains(new ElementView(softwareSystem2))); }
public void Test_Construction() { SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Name", "Description"); SystemContextView systemContextView = Views.CreateSystemContextView(softwareSystem, "SystemContext", "Description"); FilteredView filteredView = Views.CreateFilteredView( systemContextView, "CurrentStateSystemContext", "The system context as-is.", FilterMode.Exclude, "v2", "v3" ); Assert.Equal("CurrentStateSystemContext", filteredView.Key); Assert.Equal("SystemContext", filteredView.BaseViewKey); Assert.Same(systemContextView, filteredView.View); Assert.Equal("The system context as-is.", filteredView.Description); Assert.Equal(FilterMode.Exclude, filteredView.Mode); Assert.Equal(2, filteredView.Tags.Count); Assert.True(filteredView.Tags.Contains("v2")); Assert.True(filteredView.Tags.Contains("v3")); }
public void test_writeSystemContextView() { PopulateWorkspace(); SystemContextView systemContextView = _workspace.Views.SystemContextViews.First(); _plantUMLWriter.Write(systemContextView, _stringWriter); Assert.Equal( @"@startuml title Software System - System Context component ""E-mail System"" <<Software System>> as 4 component ""Software System"" <<Software System>> as 2 actor ""User"" <<Person>> as 1 4 ..> 1 : Delivers e-mails to 2 ..> 4 : Sends e-mail using 1 ..> 2 : Uses @enduml ".UnifyNewLine(), _stringWriter.ToString()); }
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 views = workspace.Views; SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); StringWriter stringWriter = new StringWriter(); PlantUMLWriter plantUMLWriter = new PlantUMLWriter(); plantUMLWriter.Write(workspace, stringWriter); Console.WriteLine(stringWriter.ToString()); }
private void Write(SystemContextView view, TextWriter writer) { try { writer.WriteLine("@startuml"); writer.WriteLine("title " + view.Name); view.Elements .Select(ev => ev.Element) .OrderBy(e => e.Name).ToList() .ForEach(e => Write(e, writer, false)); Write(view.Relationships, writer); writer.WriteLine("@enduml"); writer.WriteLine(""); } catch (IOException e) { Console.WriteLine(e.StackTrace); } }
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.PutWorkspaceAsync(WorkspaceId, workspace).Wait(); }
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); }
public void Test_CopyLayoutInformationFrom() { Workspace workspace1 = new Workspace("", ""); Model model1 = workspace1.Model; SoftwareSystem softwareSystem1A = model1.AddSoftwareSystem("System A", "Description"); SoftwareSystem softwareSystem1B = model1.AddSoftwareSystem("System B", "Description"); Person person1 = model1.AddPerson("Person", "Description"); Relationship personUsesSoftwareSystem1 = person1.Uses(softwareSystem1A, "Uses"); // create a view with SystemA and Person (locations are set for both, relationship has vertices) StaticView staticView1 = new SystemContextView(softwareSystem1A, "context", "Description"); staticView1.Add(softwareSystem1B); staticView1.GetElementView(softwareSystem1B).X = 123; staticView1.GetElementView(softwareSystem1B).Y = 321; staticView1.Add(person1); staticView1.GetElementView(person1).X = 456; staticView1.GetElementView(person1).Y = 654; staticView1.GetRelationshipView(personUsesSoftwareSystem1).Vertices = new List <Vertex>() { new Vertex(123, 456) }; staticView1.GetRelationshipView(personUsesSoftwareSystem1).Position = 70; staticView1.GetRelationshipView(personUsesSoftwareSystem1).Routing = Routing.Orthogonal; // and create a dynamic view, as they are treated slightly differently DynamicView dynamicView1 = new DynamicView(model1, "dynamic", "Description"); dynamicView1.Add(person1, "Overridden description", softwareSystem1A); dynamicView1.GetElementView(person1).X = 111; dynamicView1.GetElementView(person1).Y = 222; dynamicView1.GetElementView(softwareSystem1A).X = 333; dynamicView1.GetElementView(softwareSystem1A).Y = 444; dynamicView1.GetRelationshipView(personUsesSoftwareSystem1).Vertices = new List <Vertex>() { new Vertex(555, 666) }; dynamicView1.GetRelationshipView(personUsesSoftwareSystem1).Position = 30; dynamicView1.GetRelationshipView(personUsesSoftwareSystem1).Routing = Routing.Direct; Workspace workspace2 = new Workspace("", ""); Model model2 = workspace2.Model; // creating these in the opposite order will cause them to get different internal IDs SoftwareSystem softwareSystem2B = model2.AddSoftwareSystem("System B", "Description"); SoftwareSystem softwareSystem2A = model2.AddSoftwareSystem("System A", "Description"); Person person2 = model2.AddPerson("Person", "Description"); Relationship personUsesSoftwareSystem2 = person2.Uses(softwareSystem2A, "Uses"); // create a view with SystemB and Person (locations are 0,0 for both) StaticView staticView2 = new SystemContextView(softwareSystem2A, "context", "Description"); staticView2.Add(softwareSystem2B); staticView2.Add(person2); Assert.Equal(0, staticView2.GetElementView(softwareSystem2B).X); Assert.Equal(0, staticView2.GetElementView(softwareSystem2B).Y); Assert.Equal(0, staticView2.GetElementView(softwareSystem2B).X); Assert.Equal(0, staticView2.GetElementView(softwareSystem2B).Y); Assert.Equal(0, staticView2.GetElementView(person2).X); Assert.Equal(0, staticView2.GetElementView(person2).Y); Assert.True(staticView2.GetRelationshipView(personUsesSoftwareSystem2).Vertices.Count == 0); // and create a dynamic view (locations are 0,0) DynamicView dynamicView2 = new DynamicView(model2, "dynamic", "Description"); dynamicView2.Add(person2, "Overridden description", softwareSystem2A); staticView2.CopyLayoutInformationFrom(staticView1); Assert.Equal(0, staticView2.GetElementView(softwareSystem2A).X); Assert.Equal(0, staticView2.GetElementView(softwareSystem2A).Y); Assert.Equal(123, staticView2.GetElementView(softwareSystem2B).X); Assert.Equal(321, staticView2.GetElementView(softwareSystem2B).Y); Assert.Equal(456, staticView2.GetElementView(person2).X); Assert.Equal(654, staticView2.GetElementView(person2).Y); Vertex vertex1 = staticView2.GetRelationshipView(personUsesSoftwareSystem2).Vertices[0]; Assert.Equal(123, vertex1.X); Assert.Equal(456, vertex1.Y); Assert.Equal(70, staticView2.GetRelationshipView(personUsesSoftwareSystem2).Position); Assert.Equal(Routing.Orthogonal, staticView2.GetRelationshipView(personUsesSoftwareSystem2).Routing); dynamicView2.CopyLayoutInformationFrom(dynamicView1); Assert.Equal(111, dynamicView2.GetElementView(person2).X); Assert.Equal(222, dynamicView2.GetElementView(person2).Y); Assert.Equal(333, dynamicView2.GetElementView(softwareSystem2A).X); Assert.Equal(444, dynamicView2.GetElementView(softwareSystem2A).Y); Vertex vertex2 = dynamicView2.GetRelationshipView(personUsesSoftwareSystem2).Vertices[0]; Assert.Equal(555, vertex2.X); Assert.Equal(666, vertex2.Y); Assert.Equal(30, dynamicView2.GetRelationshipView(personUsesSoftwareSystem2).Position); Assert.Equal(Routing.Direct, dynamicView2.GetRelationshipView(personUsesSoftwareSystem2).Routing); }
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("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); }
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); }
public SystemContextViewTests() { softwareSystem = model.AddSoftwareSystem("The System", "Description"); view = workspace.Views.CreateSystemContextView(softwareSystem, "context", "Description"); }
public static Workspace Create() { Workspace workspace = new Workspace("Big Bank plc", "This is an example workspace to illustrate the key features of Structurizr, based around a fictional online banking system."); Model model = workspace.Model; ViewSet views = workspace.Views; model.Enterprise = new Enterprise("Big Bank plc"); // people and software systems Person customer = model.AddPerson(Location.External, "Personal Banking Customer", "A customer of the bank, with personal bank accounts."); SoftwareSystem internetBankingSystem = model.AddSoftwareSystem(Location.Internal, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments."); customer.Uses(internetBankingSystem, "Uses"); SoftwareSystem mainframeBankingSystem = model.AddSoftwareSystem(Location.Internal, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc."); mainframeBankingSystem.AddTags(ExistingSystemTag); internetBankingSystem.Uses(mainframeBankingSystem, "Uses"); SoftwareSystem emailSystem = model.AddSoftwareSystem(Location.Internal, "E-mail System", "The internal Microsoft Exchange e-mail system."); internetBankingSystem.Uses(emailSystem, "Sends e-mail using"); emailSystem.AddTags(ExistingSystemTag); emailSystem.Delivers(customer, "Sends e-mails to"); SoftwareSystem atm = model.AddSoftwareSystem(Location.Internal, "ATM", "Allows customers to withdraw cash."); atm.AddTags(ExistingSystemTag); atm.Uses(mainframeBankingSystem, "Uses"); customer.Uses(atm, "Withdraws cash using"); Person customerServiceStaff = model.AddPerson(Location.Internal, "Customer Service Staff", "Customer service staff within the bank."); customerServiceStaff.AddTags(BankStaffTag); customerServiceStaff.Uses(mainframeBankingSystem, "Uses"); customer.InteractsWith(customerServiceStaff, "Asks questions to", "Telephone"); Person backOfficeStaff = model.AddPerson(Location.Internal, "Back Office Staff", "Administration and support staff within the bank."); backOfficeStaff.AddTags(BankStaffTag); backOfficeStaff.Uses(mainframeBankingSystem, "Uses"); // containers Container singlePageApplication = internetBankingSystem.AddContainer("Single-Page Application", "Provides all of the Internet banking functionality to customers via their web browser.", "JavaScript and Angular"); singlePageApplication.AddTags(WebBrowserTag); Container mobileApp = internetBankingSystem.AddContainer("Mobile App", "Provides a limited subset of the Internet banking functionality to customers via their mobile device.", "Xamarin"); mobileApp.AddTags(MobileAppTag); Container webApplication = internetBankingSystem.AddContainer("Web Application", "Delivers the static content and the Internet banking single page application.", "Java and Spring MVC"); Container apiApplication = internetBankingSystem.AddContainer("API Application", "Provides Internet banking functionality via a JSON/HTTPS API.", "Java and Spring MVC"); Container database = internetBankingSystem.AddContainer("Database", "Stores user registration information, hashed authentication credentials, access logs, etc.", "Relational Database Schema"); database.AddTags(DatabaseTag); customer.Uses(webApplication, "Uses", "HTTPS"); customer.Uses(singlePageApplication, "Uses", ""); customer.Uses(mobileApp, "Uses", ""); webApplication.Uses(singlePageApplication, "Delivers to the customer's web browser", ""); apiApplication.Uses(database, "Reads from and writes to", "JDBC"); apiApplication.Uses(mainframeBankingSystem, "Uses", "XML/HTTPS"); apiApplication.Uses(emailSystem, "Sends e-mail using", "SMTP"); // components // - for a real-world software system, you would probably want to extract the components using // - static analysis/reflection rather than manually specifying them all Component signinController = apiApplication.AddComponent("Sign In Controller", "Allows users to sign in to the Internet Banking System.", "Spring MVC Rest Controller"); Component accountsSummaryController = apiApplication.AddComponent("Accounts Summary Controller", "Provides customers with a summary of their bank accounts.", "Spring MVC Rest Controller"); Component resetPasswordController = apiApplication.AddComponent("Reset Password Controller", "Allows users to reset their passwords with a single use URL.", "Spring MVC Rest Controller"); Component securityComponent = apiApplication.AddComponent("Security Component", "Provides functionality related to signing in, changing passwords, etc.", "Spring Bean"); Component mainframeBankingSystemFacade = apiApplication.AddComponent("Mainframe Banking System Facade", "A facade onto the mainframe banking system.", "Spring Bean"); Component emailComponent = apiApplication.AddComponent("E-mail Component", "Sends e-mails to users.", "Spring Bean"); apiApplication.Components.Where(c => "Spring MVC Rest Controller".Equals(c.Technology)).ToList().ForEach(c => singlePageApplication.Uses(c, "Makes API calls to", "JSON/HTTPS")); apiApplication.Components.Where(c => "Spring MVC Rest Controller".Equals(c.Technology)).ToList().ForEach(c => mobileApp.Uses(c, "Makes API calls to", "JSON/HTTPS")); signinController.Uses(securityComponent, "Uses"); accountsSummaryController.Uses(mainframeBankingSystemFacade, "Uses"); resetPasswordController.Uses(securityComponent, "Uses"); resetPasswordController.Uses(emailComponent, "Uses"); securityComponent.Uses(database, "Reads from and writes to", "JDBC"); mainframeBankingSystemFacade.Uses(mainframeBankingSystem, "Uses", "XML/HTTPS"); emailComponent.Uses(emailSystem, "Sends e-mail using"); model.AddImplicitRelationships(); // deployment nodes and container instances DeploymentNode developerLaptop = model.AddDeploymentNode("Development", "Developer Laptop", "A developer laptop.", "Microsoft Windows 10 or Apple macOS"); DeploymentNode apacheTomcat = developerLaptop.AddDeploymentNode("Docker Container - Web Server", "A Docker container.", "Docker") .AddDeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", 1, DictionaryUtils.Create("Xmx=512M", "Xms=1024M", "Java Version=8")); apacheTomcat.Add(webApplication); apacheTomcat.Add(apiApplication); developerLaptop.AddDeploymentNode("Docker Container - Database Server", "A Docker container.", "Docker") .AddDeploymentNode("Database Server", "A development database.", "Oracle 12c") .Add(database); developerLaptop.AddDeploymentNode("Web Browser", "", "Chrome, Firefox, Safari, or Edge").Add(singlePageApplication); DeploymentNode customerMobileDevice = model.AddDeploymentNode("Live", "Customer's mobile device", "", "Apple iOS or Android"); customerMobileDevice.Add(mobileApp); DeploymentNode customerComputer = model.AddDeploymentNode("Live", "Customer's computer", "", "Microsoft Windows or Apple macOS"); customerComputer.AddDeploymentNode("Web Browser", "", "Chrome, Firefox, Safari, or Edge").Add(singlePageApplication); DeploymentNode bigBankDataCenter = model.AddDeploymentNode("Live", "Big Bank plc", "", "Big Bank plc data center"); DeploymentNode liveWebServer = bigBankDataCenter.AddDeploymentNode("bigbank-web***", "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "Ubuntu 16.04 LTS", 4, DictionaryUtils.Create("Location=London and Reading")); liveWebServer.AddDeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", 1, DictionaryUtils.Create("Xmx=512M", "Xms=1024M", "Java Version=8")) .Add(webApplication); DeploymentNode liveApiServer = bigBankDataCenter.AddDeploymentNode("bigbank-api***", "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "Ubuntu 16.04 LTS", 8, DictionaryUtils.Create("Location=London and Reading")); liveApiServer.AddDeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", 1, DictionaryUtils.Create("Xmx=512M", "Xms=1024M", "Java Version=8")) .Add(apiApplication); DeploymentNode primaryDatabaseServer = bigBankDataCenter.AddDeploymentNode("bigbank-db01", "The primary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=London")) .AddDeploymentNode("Oracle - Primary", "The primary, live database server.", "Oracle 12c"); primaryDatabaseServer.Add(database); DeploymentNode bigBankdb02 = bigBankDataCenter.AddDeploymentNode("bigbank-db02", "The secondary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=Reading")); bigBankdb02.AddTags(FailoverTag); DeploymentNode secondaryDatabaseServer = bigBankdb02.AddDeploymentNode("Oracle - Secondary", "A secondary, standby database server, used for failover purposes only.", "Oracle 12c"); secondaryDatabaseServer.AddTags(FailoverTag); ContainerInstance secondaryDatabase = secondaryDatabaseServer.Add(database); model.Relationships.Where(r => r.Destination.Equals(secondaryDatabase)).ToList().ForEach(r => r.AddTags(FailoverTag)); Relationship dataReplicationRelationship = primaryDatabaseServer.Uses(secondaryDatabaseServer, "Replicates data to", ""); secondaryDatabase.AddTags(FailoverTag); // views/diagrams SystemLandscapeView systemLandscapeView = views.CreateSystemLandscapeView("SystemLandscape", "The system landscape diagram for Big Bank plc."); systemLandscapeView.AddAllElements(); systemLandscapeView.PaperSize = PaperSize.A5_Landscape; SystemContextView systemContextView = views.CreateSystemContextView(internetBankingSystem, "SystemContext", "The system context diagram for the Internet Banking System."); systemContextView.EnterpriseBoundaryVisible = false; systemContextView.AddNearestNeighbours(internetBankingSystem); systemContextView.PaperSize = PaperSize.A5_Landscape; ContainerView containerView = views.CreateContainerView(internetBankingSystem, "Containers", "The container diagram for the Internet Banking System."); containerView.Add(customer); containerView.AddAllContainers(); containerView.Add(mainframeBankingSystem); containerView.Add(emailSystem); containerView.PaperSize = PaperSize.A5_Landscape; ComponentView componentView = views.CreateComponentView(apiApplication, "Components", "The component diagram for the API Application."); componentView.Add(mobileApp); componentView.Add(singlePageApplication); componentView.Add(database); componentView.AddAllComponents(); componentView.Add(mainframeBankingSystem); componentView.Add(emailSystem); componentView.PaperSize = PaperSize.A5_Landscape; systemLandscapeView.AddAnimation(internetBankingSystem, customer, mainframeBankingSystem, emailSystem); systemLandscapeView.AddAnimation(atm); systemLandscapeView.AddAnimation(customerServiceStaff, backOfficeStaff); systemContextView.AddAnimation(internetBankingSystem); systemContextView.AddAnimation(customer); systemContextView.AddAnimation(mainframeBankingSystem); systemContextView.AddAnimation(emailSystem); containerView.AddAnimation(customer, mainframeBankingSystem, emailSystem); containerView.AddAnimation(webApplication); containerView.AddAnimation(singlePageApplication); containerView.AddAnimation(mobileApp); containerView.AddAnimation(apiApplication); containerView.AddAnimation(database); componentView.AddAnimation(singlePageApplication, mobileApp); componentView.AddAnimation(signinController, securityComponent, database); componentView.AddAnimation(accountsSummaryController, mainframeBankingSystemFacade, mainframeBankingSystem); componentView.AddAnimation(resetPasswordController, emailComponent, database); // dynamic diagrams and deployment diagrams are not available with the Free Plan DynamicView dynamicView = views.CreateDynamicView(apiApplication, "SignIn", "Summarises how the sign in feature works in the single-page application."); dynamicView.Add(singlePageApplication, "Submits credentials to", signinController); dynamicView.Add(signinController, "Calls isAuthenticated() on", securityComponent); dynamicView.Add(securityComponent, "select * from users where username = ?", database); dynamicView.PaperSize = PaperSize.A5_Landscape; DeploymentView developmentDeploymentView = views.CreateDeploymentView(internetBankingSystem, "DevelopmentDeployment", "An example development deployment scenario for the Internet Banking System."); developmentDeploymentView.Environment = "Development"; developmentDeploymentView.Add(developerLaptop); developmentDeploymentView.PaperSize = PaperSize.A5_Landscape; DeploymentView liveDeploymentView = views.CreateDeploymentView(internetBankingSystem, "LiveDeployment", "An example live deployment scenario for the Internet Banking System."); liveDeploymentView.Environment = "Live"; liveDeploymentView.Add(bigBankDataCenter); liveDeploymentView.Add(customerMobileDevice); liveDeploymentView.Add(customerComputer); liveDeploymentView.Add(dataReplicationRelationship); liveDeploymentView.PaperSize = PaperSize.A5_Landscape; // colours, shapes and other diagram styling Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#1168bd", Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.Container) { Background = "#438dd5", Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.Component) { Background = "#85bbf0", Color = "#000000" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b", Color = "#ffffff", Shape = Shape.Person, FontSize = 22 }); styles.Add(new ElementStyle(ExistingSystemTag) { Background = "#999999", Color = "#ffffff" }); styles.Add(new ElementStyle(BankStaffTag) { Background = "#999999", Color = "#ffffff" }); styles.Add(new ElementStyle(WebBrowserTag) { Shape = Shape.WebBrowser }); styles.Add(new ElementStyle(MobileAppTag) { Shape = Shape.MobileDeviceLandscape }); styles.Add(new ElementStyle(DatabaseTag) { Shape = Shape.Cylinder }); styles.Add(new ElementStyle(FailoverTag) { Opacity = 25 }); styles.Add(new RelationshipStyle(FailoverTag) { Opacity = 25, Position = 70 }); // documentation // - usually the documentation would be included from separate Markdown/AsciiDoc files, but this is just an example StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); template.AddContextSection(internetBankingSystem, Format.Markdown, "Here is some context about the Internet Banking System...\n" + "![](embed:SystemLandscape)\n" + "![](embed:SystemContext)\n" + "### Internet Banking System\n...\n" + "### Mainframe Banking System\n...\n"); template.AddContainersSection(internetBankingSystem, Format.Markdown, "Here is some information about the containers within the Internet Banking System...\n" + "![](embed:Containers)\n" + "### Web Application\n...\n" + "### Database\n...\n"); template.AddComponentsSection(webApplication, Format.Markdown, "Here is some information about the API Application...\n" + "![](embed:Components)\n" + "### Sign in process\n" + "Here is some information about the Sign In Controller, including how the sign in process works...\n" + "![](embed:SignIn)"); template.AddDevelopmentEnvironmentSection(internetBankingSystem, Format.AsciiDoc, "Here is some information about how to set up a development environment for the Internet Banking System...\n" + "image::embed:DevelopmentDeployment[]"); template.AddDeploymentSection(internetBankingSystem, Format.AsciiDoc, "Here is some information about the live deployment environment for the Internet Banking System...\n" + "image::embed:LiveDeployment[]"); return(workspace); }