Skip to the content.

Core package guide

Install C4.Net.Core when you want to create or modify workspaces in .NET code.

dotnet add package C4.Net.Core

Namespace

using C4.Net;

Create a workspace

A workspace contains the model, views, and related configuration.

Workspace workspace = new Workspace("Getting Started", "A simple architecture workspace.");
Model model = workspace.Model;

Add model elements

Add people, software systems, containers, and components through the model graph.

Person user = model.AddPerson("User", "Uses the system.");
SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "Provides the core capability.");
user.Uses(softwareSystem, "Uses");

Create views

Create a view from the workspace view set, then add the elements you want to render.

SystemContextView view = workspace.Views.CreateSystemContextView(
    softwareSystem,
    "system-context",
    "A simple system context view.");
view.AddAllPeople();
view.AddAllSoftwareSystems();

Apply styles

Styles live under workspace.Views.Configuration.Styles.

Styles styles = workspace.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 });

Next steps

For C4 notation guidance, use the official C4 Model website.