Skip to content

Static structures

Yan Justino edited this page Nov 20, 2021 · 12 revisions

Notations

In C4S the static structures represent the C4 model notation. It uses some attributes to draw the shapes are as follows:

Person

A person represents one of the human users of your software system (e.g. actors, roles, personas, etc)

public static Person Customer => new Person("customer", "Personal Banking Customer")
{
    Description = "A customer of the bank, with personal bank accounts.",
    Boundary = Boundary.External
};

Software System

A software system is the highest level of abstraction and describes something that delivers value to its users, whether they are human or not. This includes the software system you are modeling, and the other software systems upon which your software system depends (or vice versa). In many cases, a software system is "owned by" a single software development team.

public static SoftwareSystem System => new SoftwareSystem("BankingSystem", "Internet Banking System")
{
    Description = "Allows customers to view information about their bank accounts, and make payments."
};

Container

Not Docker! In the C4 model, a container represents an application or a data store. A container is something that needs to be running in order for the overall software system to work. In real terms, a container is something like: Server-side web application, Client-side web application, Client-side desktop application, Mobile app, Server-side console application, Serverless function, Database, Blob or content store, File system, Shell script.

public static Container BackendApi => new Container("BackendApi", "BackendApi")
{
    ContainerType = ContainerType.Api,
    Description = "Provides Internet banking functionality via API.",
    Technology = "Dotnet, Docker Container"
};

Using Instances

If you need to use instances of a container, just put [id of instance] like this:

(Containers.BackendApi > Containers.OracleDatabase[1])["Writes to", "JDBC"],
(Containers.BackendApi < Containers.OracleDatabase[2])["Reads from", "JDBC"],

Containers Type

public enum ContainerType
{
    [Description("Mobile app")]
    Mobile,

    [Description("Server-side web application")]
    WebApplication,

    [Description("Server-side console application")]
    ServerConsole,

    [Description("Client-side desktop application")]
    ClientDesktop,

    [Description("Serverless function")]
    ServerlessFunction,

    [Description("Blob or content store")]
    Blob,

    [Description("File sytem")]
    FileSystem,

    [Description("Shell script")]
    ShellScript,

    [Description("SPA")]
    Spa,

    [Description("API")]
    Api,

    [Description("Queue")]
    Queue,

    [Description("Database")]
    Database,

    [Description("")]
    None
}
  

Component

The word "component" is a hugely overloaded term in the software development industry, but in this context, a component is a grouping of related functionality encapsulated behind a well-defined interface. If you're using a language like Java or C#, the simplest way to think of a component is that it's a collection of implementation classes behind an interface. Aspects such as how those components are packaged (e.g. one component vs many components per JAR file, DLL, shared library, etc) are separate and orthogonal concerns. An important point to note here is that all components inside a container typically execute in the same process space. In the C4 model, components are not separately deployable units.

public static Component Controller => new Component("sign", "Sign In Controller")
{
    Description = "Allows users to sign in to the internet banking system",
    Technology = "MVC Rest Controller",
};

Learn More

See more in our sample code