AnnotatedDiagrams 0.1.22
dotnet add package AnnotatedDiagrams --version 0.1.22
NuGet\Install-Package AnnotatedDiagrams -Version 0.1.22
<PackageReference Include="AnnotatedDiagrams" Version="0.1.22" />
<PackageVersion Include="AnnotatedDiagrams" Version="0.1.22" />
<PackageReference Include="AnnotatedDiagrams" />
paket add AnnotatedDiagrams --version 0.1.22
#r "nuget: AnnotatedDiagrams, 0.1.22"
#:package AnnotatedDiagrams@0.1.22
#addin nuget:?package=AnnotatedDiagrams&version=0.1.22
#tool nuget:?package=AnnotatedDiagrams&version=0.1.22
AnnotatedDiagrams
Core annotations and model library for AnnotatedDiagrams. Define your software architecture using C# attributes and generate diagrams automatically in SVG, Mermaid, PlantUML, and D2 formats.
Installation
dotnet add package AnnotatedDiagrams
Targets netstandard 2.0 — compatible with .NET Framework 4.6.1+, .NET Core, and .NET 5+.
Quick start
1. Declare external nodes and system boundaries (assembly level)
[assembly: DiagramExternalNode("stripe", "Stripe",
Kind = NodeKind.ExternalSystem, Technology = "REST")]
[assembly: DiagramExternalNode("order-queue", "Order Queue",
Kind = NodeKind.Queue, Technology = "Azure Service Bus")]
[assembly: DiagramSystemNode("ecommerce", "E-Commerce Platform")]
2. Annotate your classes
[DiagramNode("Order Service",
Id = "order-svc",
Kind = NodeKind.Container,
System = "ecommerce",
ParentId = "ecommerce",
Technology = ".NET 9",
Description = "Handles order processing")]
[DiagramRelation(typeof(PaymentService),
Kind = RelationKind.Calls, Label = "Charge card")]
[DiagramRelationToExternal("stripe",
Kind = RelationKind.Calls, Label = "Payment gateway",
Tags = new[] { "route:POST /charge" })]
[DiagramRelationToExternal("order-queue",
Kind = RelationKind.Publishes, Label = "Publishes order placed")]
public sealed class OrderService { }
3. Extract and render
var extractor = new ReflectionDiagramExtractor();
var graph = extractor.Extract(new[] { typeof(OrderService).Assembly });
var renderer = new D2Renderer();
var result = renderer.Render(graph, new RenderRequest("Default"));
Console.WriteLine(result.Source); // D2 source
Annotations reference
Assembly-level attributes
| Attribute | Description |
|---|---|
[DiagramExternalNode("id", "Name", Kind = ..., Technology = ..., Tags = ...)] |
Declares an external node (another service, database, queue, etc.) referenced by this assembly |
[DiagramSystemNode("id", "Name")] |
Declares a named system boundary (C4 System box) |
Type-level attributes
| Attribute | Description |
|---|---|
[DiagramNode("Name", Id = ..., Kind = ..., System = ..., ParentId = ..., Technology = ..., Description = ..., Tags = ...)] |
Declares a node for the annotated type |
[DiagramRelation(typeof(Target), Kind = ..., Label = ..., Direction = ..., Tags = ...)] |
Edge to another annotated type in the same assembly |
[DiagramRelationToExternal("ext-id", Kind = ..., Label = ..., Tags = ...)] |
Edge to a node declared with [DiagramExternalNode] |
Direction
Direction.Outbound (default) — this type calls/uses/publishes to the target.
Direction.Inbound — this type receives calls from the target (edge is reversed on the graph).
Direction.Bidirectional — two-way relationship.
Node kinds
| Kind | D2 shape | Typical use |
|---|---|---|
Person |
person | Human actor / user |
ExternalSystem |
rectangle | External service outside your boundary |
System |
rectangle | Your system (C4 System) |
Container |
rectangle | Deployable unit (service, app, DB) |
Component |
oval | Internal component within a container |
Database |
cylinder | Relational or document database |
Queue |
queue | Message queue |
Topic |
queue | Pub/sub topic |
Cache |
cylinder | In-memory or distributed cache |
FileStore |
bucket | Blob / file storage |
Function |
diamond | Serverless function |
Relation kinds
Uses · Calls · Reads · Writes · DependsOn · Publishes · Subscribes · Emits · Consumes · Hosts · Deploys
Queue visualization
Queue and Topic nodes support two visualization styles, controlled by RenderRequest.QueueVisualization:
| Mode | Behavior |
|---|---|
Annotation (default) |
Queues/topics are collapsed; producer→consumer arrows are annotated with [via QueueName] |
Container |
Queues/topics rendered as explicit cylinder nodes with separate producer and consumer edges |
Renderers
| Class | Output | Notes |
|---|---|---|
D2Renderer |
D2 language source | Primary renderer; used by the dashboard and server |
SvgRenderer |
SVG | Standalone SVG output without D2Sharp |
MermaidRenderer |
Mermaid markdown | Compatible with GitHub / GitLab |
PlantUmlRenderer |
PlantUML source | Compatible with PlantUML server |
RenderRequest options
new RenderRequest(
ViewName: "Default", // Which view to render
DropIsolatedNodes: false, // Remove nodes with no edges
LeftToRight: true, // LR layout (false = top-down)
ShowIcons: true, // Show node kind icons
QueueVisualization: QueueVisualization.Annotation)
Graph merging
DiagramGraphMerger.Merge combines graphs from multiple assemblies or services into one:
- Nodes with equal names where at least one is
ExternalSystemor a shared-infrastructure kind (Queue,Topic,Database,Cache,FileStore) are merged into a single canonical node. - Kind priority (highest wins): System > any concrete kind > ExternalSystem.
- Edges are remapped to canonical node IDs; duplicates (same from/to/kind/label) are deduplicated.
var merged = DiagramGraphMerger.Merge(new[] { graphA, graphB });
Related packages
- AnnotatedDiagrams.Runtime — ASP.NET Core middleware that exposes live diagram and traffic-metrics endpoints from a running service.
- AnnotatedDiagrams.Client — MSBuild integration for Blazor WASM projects; generates
.graph.jsonmanifests at build time.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AnnotatedDiagrams:
| Package | Downloads |
|---|---|
|
AnnotatedDiagrams.Runtime
Runtime self-description for AnnotatedDiagrams. Scans loaded assemblies, builds a DiagramGraph, and exposes ASP.NET Core endpoints for architecture diagrams. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.22 | 135 | 4/27/2026 |
| 0.1.21 | 121 | 4/24/2026 |
| 0.1.20 | 117 | 4/24/2026 |
| 0.1.19 | 114 | 4/24/2026 |
| 0.1.18 | 123 | 4/23/2026 |
| 0.1.17 | 135 | 4/1/2026 |
| 0.1.16 | 125 | 3/31/2026 |
| 0.1.15 | 124 | 3/30/2026 |
| 0.1.14 | 124 | 3/15/2026 |
| 0.1.13 | 124 | 3/13/2026 |
| 0.1.12 | 143 | 3/9/2026 |
| 0.1.11 | 114 | 3/9/2026 |
| 0.1.10 | 103 | 3/9/2026 |
| 0.1.9 | 102 | 3/4/2026 |
| 0.1.7 | 102 | 3/4/2026 |
| 0.1.6 | 178 | 2/17/2026 |