All Projects → 8T4 → c4sharp

8T4 / c4sharp

Licence: MIT license
C4Sharp (C4S) is a .net library for building C4 Model diagrams.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to c4sharp

plantuml-libs
A set of PlantUML libraries and a NPM cli tool to design diagrams which focus on several technologies/approaches: Amazon Web Services (AWS), Azure, Google Cloud Platform (GCP), C4 Model or even EventStorming and more.
Stars: ✭ 75 (-52.83%)
Mutual labels:  plantuml, c4model
C4 Plantuml
C4-PlantUML combines the benefits of PlantUML and the C4 model for providing a simple way of describing and communicate software architectures
Stars: ✭ 3,522 (+2115.09%)
Mutual labels:  plantuml, c4model
C4-PlantumlSkin
This library provides skinning to create C4 diagrams using PlantUml
Stars: ✭ 74 (-53.46%)
Mutual labels:  plantuml, c4model
Json
A really simple C# JSON Parser in 350 lines
Stars: ✭ 202 (+27.04%)
Mutual labels:  nuget
Linqpad.queryplanvisualizer
SQL Server and PostgreSQL query execution plan visualizer for LINQPad
Stars: ✭ 209 (+31.45%)
Mutual labels:  nuget
yavdb
Yet Another Vulnerability Database
Stars: ✭ 14 (-91.19%)
Mutual labels:  nuget
Krypton-Toolkit-Suite-Extended-NET-5.470
An extension to the Krypton Toolkit suite of controls for .NET framework 4.7
Stars: ✭ 51 (-67.92%)
Mutual labels:  nuget
Sleet
A static nuget feed generator for Azure Storage, AWS S3, and more.
Stars: ✭ 201 (+26.42%)
Mutual labels:  nuget
bUnit
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
Stars: ✭ 857 (+438.99%)
Mutual labels:  nuget
Blazortable
Blazor Table Component with Sorting, Paging and Filtering
Stars: ✭ 249 (+56.6%)
Mutual labels:  nuget
Sharpcaster
Chromecast C# SDK for Windows, Windows Phone, .NET 4.5.1, Xamarin.iOS and Xamarin.Android platforms.
Stars: ✭ 245 (+54.09%)
Mutual labels:  nuget
Typeahead
Typeahead control for Blazor applications
Stars: ✭ 226 (+42.14%)
Mutual labels:  nuget
vscode-npm-gui
vscode nuget package manager gui https://marketplace.visualstudio.com/items?itemName=aliasadidev.nugetpackagemanagergui
Stars: ✭ 36 (-77.36%)
Mutual labels:  nuget
Watsontcp
WatsonTcp is the easiest way to build TCP-based clients and servers in C#.
Stars: ✭ 209 (+31.45%)
Mutual labels:  nuget
junit.testlogger
JUnit test logger for vstest platform
Stars: ✭ 61 (-61.64%)
Mutual labels:  nuget
Log4net.elasticsearch
log4net appender to ElasticSearch
Stars: ✭ 202 (+27.04%)
Mutual labels:  nuget
GenuineChannels
Collection of custom .NET Remoting channels
Stars: ✭ 29 (-81.76%)
Mutual labels:  nuget
Templates
.NET project templates with batteries included, providing the minimum amount of code required to get you going faster.
Stars: ✭ 2,864 (+1701.26%)
Mutual labels:  nuget
ecto erd
A mix task for generating Entity Relationship Diagram from Ecto schemas available in your project.
Stars: ✭ 173 (+8.81%)
Mutual labels:  plantuml
makeitpdf
A close-to-code documentation helper
Stars: ✭ 15 (-90.57%)
Mutual labels:  plantuml

logo

C4Sharp (C4S) is a .net library for building diagram as code, based on C4 Model. It's works like a superset of C4-PlantUML through which developers can create, share, and consume C4 Model diagrams as code (C#) such as Context, Container, Component and Deployment diagrams.

GETTING STARTED

The C4 model is an easy to learn, developer friendly approach to software architecture diagramming. Good software architecture diagrams assist with communication inside/outside of software development/product teams, efficient onboarding of new staff, architecture reviews/evaluations, risk identification (e.g. risk-storming), threat modelling (e.g. STRIDE/LINDDUN), etc.
SIMON BROWN

Installing

Fist, you will need the .NET 5.0+ and Java to run C4Sharp. Also, you should install C4Sharp package in your project. This package is available through Nuget Packages.

Package Description Version Downloads Maintainability Status
C4SHARP dotnet library for building diagrams NuGet Nuget Codacy Badge .NET
C4SCLI cli for compiling C4S projects NuGet Nuget Codacy Badge .NET

DIAGRAM AS CODE

There are benefits to using these tools over the heavier alternatives, including easy version control and the ability to generate the DSLs from many sources. ools in this space that we like include Diagrams, Structurizr DSL, AsciiDoctor Diagram and stables such as WebSequenceDiagrams, PlantUML and the venerable Graphviz. It's also fairly simple to generate your own SVG these days, so don't rule out quickly writing your own tool either. One of our authors wrote a small Ruby script to quickly create SVGs, for example.
Thoughtworks Technology Radar

Coding

To build a diagram using the C4S library we need to identify the structures and their relationships through a class that inherits properties directly from DiagramBuildRunner. See the following example of building a container diagram:

namespace C4Bank.Deposit.Architecure;

public class ContainerDiagram : DiagramBuildRunner
{
    protected override string Title => "C4Bank Context of Deposit Area";
    protected override DiagramType DiagramType => DiagramType.Container;
    
    protected override IEnumerable<Structure> Structures => new Structure[]
    {
        new Person("Customer", "Customer", "Bank Customer"),
        new SoftwareSystem("OTBank.Finance", "Finance", "OTBank Finance System", Boundary.External),
        new SoftwareSystem("C4Bank.Account", "Account", "C4Bank Account System"),
        new Api<DepositReceived>("Aspnet/C#", "ACL"),
        new EventStreaming<RegisteredAccount>("kafka", "Partition 01"),
        
        SoftwareSystemBoundary.New("Deposit",
            new Api<DepositoProcessingWorker>("C#"),
            new Database<IDepositRepository>("SQL Server", "Deposit Data Base"),
            new ServerConsole<SynchronizeNewAccountConsumer>("C#", "Kafka Consumer"),
            new Database<IAccountRepository>("SQL Server", "Account Data Base")
        ),
    };

    protected override IEnumerable<Relationship> Relationships => new[]
    {
        It("Customer") > It("OTBank.Finance") | "send deposit",
        It("OTBank.Finance") > It<DepositReceived>() | ("POST", "HTTP"),
        It<DepositoProcessingWorker>() < It<DepositReceived>() | ("POST", "HTTP"),
        It<DepositoProcessingWorker>() > It<IDepositRepository>(),
        
        It("Customer") > It("C4Bank.Account") | "register",
        It("C4Bank.Account") > It<RegisteredAccount>() | "produces",
        It<SynchronizeNewAccountConsumer>() > It<RegisteredAccount>() | "consumes",
        It<SynchronizeNewAccountConsumer>() > It<IAccountRepository>(),
        It<DepositoProcessingWorker>() > It<IAccountRepository>(),
    };   
}

Code 1 - container diagram as code

Compiling

There are two strategies for compiling diagrams in your project: self-compiling and using the C4SCLI tool.

a) self-compiling approach:

Code the following structure into program.cs. In this approach, it is preferable that you use a separate project.

internal static class Program
{
    private static void Main()
    {
        var diagrams = new[]
        {
            new ContainerDiagram().Build(),
        };
        
        new PlantumlSession()
            .UseDiagramImageBuilder()
            .UseDiagramSvgImageBuilder()
            .Export(diagrams);
    }
}

Code 2 - self-compiling approach
see the complete code here

b) Using the C4SCLI tool:

The C4SCLI can be used in DevOps pipelines, removing the need to manually compile diagrams. For this, install C4SCLI tool and execute de the following command:

$ c4scli build <solution path> [-o <output path>]

⚠️ only compatible with projects using c4sharp version 5.0+

The Result

The previous steps will result in the following image:

img

You can customize the diagram by implementing the SetStyle() method, as in the following example:

protected override IElementStyle? SetStyle()
{
    return new ElementStyle()
        .UpdateElementStyle(ElementName.Person, "#000000", "#000000")
        .UpdateElementStyle(ElementName.Container, "#ffffff", "#000000", "#000000", false, Shape.RoundedBoxShape)
        .UpdateElementStyle(ElementName.System, "#f4f4f4", "#000000", "#000000", false, Shape.RoundedBoxShape)
        .UpdateElementStyle(ElementName.ExternalSystem, "#f4f4f4", "#000000", "#000000", false, Shape.RoundedBoxShape);
}    

img

LEARN

THANKS

C4 community

Contributors

Colleagues

Guide to contributing to a GitHub project

This is a guide to contributing to this open source project that uses GitHub. It’s mostly based on how many open sorce projects operate. That’s all there is to it. The fundamentals are:

  • Fork the project & clone locally.
  • Create an upstream remote and sync your local copy before you branch.
  • Branch for each separate piece of work.
  • Do the work, write good commit messages, and read the CONTRIBUTING file if there is one.
  • Push to your origin repository.
  • Create a new PR in GitHub.
  • Respond to any code review feedback.

If you want to contribute to an open source project, the best one to pick is one that you are using yourself. The maintainers will appreciate it!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].