Alpha / Early Preview • v0.1.0 for VS Code

Dhi — Language of Diagrams.

Model complex software and systems in a strongly-typed, modular diagram language—deterministically compiled into crisp, interactive technical diagrams.

First-Class UML Dialect (14 Diagrams) + Generic Graphs · Built-In Offline Compiler · VS Code Dark & Light Native · Strict Static Diagnostics

Pan, zoom, or click any diagram element on the right to highlight its source line on the left.

Sandbox ↗
1dialect uml;
2​
3uml::sequence_diagram "OAuth 2.0 PKCE Authorization Code Flow" {
4​
5 schema {
6 lifeline actor @User [label: "User"];
7 lifeline client @SPA [label: "Single Page App"];
8 lifeline service @AuthSvc [label: "OAuth Server"];
9 lifeline boundary @Resource [label: "Resource API"];
10 }
11​
12 flow {
13 phase "Step 1: User Login & Authorization Request";
14​
15 User -> SPA.login: "clickLogin()";
16​
17 SPA.login {
18 note @pkceNote [on: SPA, pos: right] "Generates code_verifier and code_challenge (S256)";
19 -> self.generatePKCE: "createChallenge()" => challenge;
20 -> AuthSvc.authorize: "GET /authorize?challenge=challenge" => "code=AUTH_CODE_8831";
21 }
22​
23 phase "Step 2: Token Exchange";
24​
25 User -> SPA.tokenExchange: "submitAuthCode(code)";
26​
27 SPA.tokenExchange {
28 -> AuthSvc.token: "POST /token (code + verifier)" => "access_token=JWT";
29 -> self.storeToken: "saveSession(JWT)";
30 }
31​
32 phase "Step 3: Access Protected Resource API";
33​
34 User -> SPA.fetchData: "clickProfile()";
35​
36 SPA.fetchData {
37 -> Resource.getProfile: "GET /user/profile (Bearer JWT)" => "200 OK(profile_data)";
38 -> self.renderDashboard: "displayUser(profile_data)";
39 }
40 }
41​
42 layout {
43 lifeline @User { offset_x: 0 }
44 lifeline @SPA { offset_x: 200 }
45 lifeline @AuthSvc { offset_x: 420 }
46 lifeline @Resource { offset_x: 640 }
47 }
48}
49​
50​
Errors: 0 | sequence_diagram
Read-Only Preview

Diagrams deserve a real compiler.

Visual whiteboards feel effortless until a system grows and every rename breaks connections across a dozen views. Dhi treats architecture diagrams as typed source code.

01

Single Source of Truth (@Identifier)

Declare participants, classes, states, and ports once inside schema { }. Reference an undeclared node or invalid connection, and the compiler catches it (E143, E160) before documentation goes stale.

02

Kinematic Layout Triad (reference / branch / joint)

Never hand-position X/Y coordinates or untangle crossing wires. Compose rigid or telescopic assemblies pinned by shared-node joints, autonomous collector rails, and zero-tangle planar port sorting.

03

Composable Modules & Cross-Diagram link

Split systems across .dhi modules with mod, pub, and use—or connect classes, state machines, and sequence flows via link with cross-file diagnostics, go-to-definition, and symbol rename.

04

Built-In Contracts & Resilience (#[...])

Attach governance (#[owner], #[security]), operational resilience (#[retry], #[circuit_breaker], #[timeout]), and statically checked design contracts (#[pre], #[post], #[invariant]).

05

Typed Design Tokens (let, ..., ${TOKEN})

Define compile-time scalars, numeric expressions, and reusable attribute bags with let, unpack presets with ..., and interpolate tokens directly into labels via ${TOKEN}.

06

Clean Git Reviews & Markdown Support

Semicolon-delimited statements, explicit four-pillar blocks, and architectural comments (///, //?, //!) make diffs straightforward to review and embed cleanly in Markdown.

One consistent grammar across every diagram.

Every Dhi diagram shares the same Universal Entity Formula and Four-Pillar block structure (schema, behavioral/flow links, layout, and theme), avoiding 15 incompatible syntaxes.

1. schema — Declare control nodes, object buffers, swimlane partitions, actions, and #[owner(...)] metadata once.
Sandbox ↗
1dialect uml;
2​
3uml::activity_diagram "Document Review & Editorial Approval Workflow" {
4 schema {
5 control initial @StartReview;
6 control decision @CheckQuality [label: "Meets Standards?"];
7 control merge @MergeSubmissions [label: "Intake"];
8 control final @ReviewFinished;
9​
10 // Standalone object buffer passed across swimlane boundaries
11 object @DocumentDraft : content::Article [state: PendingReview];
12​
13 // Partition 1: Content Author
14 #[owner(team: "technical-writing")]
15 frame partition @author [label: "Content Author"] {
16 action @DraftArticle [label: "Compose Initial Draft"];
17 action @ReviseArticle [label: "Address Editorial Feedback"];
18 }
19​
20 // Partition 2: Editorial Board
21 #[owner(team: "editorial-staff")]
22 frame partition @editor [label: "Editorial Board"] {
23 action @ReviewArticle [label: "Peer Review & Fact Check"];
24 action @PublishArticle [label: "Publish to Digital Channels"];
25 }
26 }
27​
28 flow {
29 // Pipeline flows
30 StartReview -> DraftArticle;
31 DraftArticle -> MergeSubmissions;
32​
33 MergeSubmissions -> DocumentDraft;
34 DocumentDraft -> ReviewArticle;
35 ReviewArticle -> CheckQuality;
36​
37 CheckQuality {
38 if score >= 80 -> PublishArticle;
39 else -> ReviseArticle;
40 }
41​
42 ReviseArticle -> MergeSubmissions;
43 PublishArticle -> ReviewFinished;
44 }
45​
46 layout {
47 reference AuthorSpine: column [gap: 40, align: center] {
48 control @StartReview
49 action @DraftArticle
50 control @MergeSubmissions
51 action @ReviseArticle
52 }
53​
54 branch EditorSpine: column [gap: 40, align: center] {
55 object @DocumentDraft
56 action @ReviewArticle
57 control @CheckQuality
58 action @PublishArticle
59 control @ReviewFinished
60 }
61​
62 joint DraftExchange: row [align: middle, row_gap: 80] {
63 control @MergeSubmissions
64 object @DocumentDraft
65 }
66 }
67​
68 theme {
69 frame partition: [header: [fill: "#1e1e2e", color: "#cdd6f4"], border: [color: "#313244"]];
70 action: [fill: "#181825", border: [color: "#89b4fa", radius: 8]];
71 control decision: [fill: "#f9e2af", border: [color: "#fab387"]];
72 object: [fill: "#11111b", border: [color: "#a6e3a1", dash: dashed]];
73 }
74}
75​
Errors: 0 | activity_diagram
Read-Only Preview

Kinematic Layout. Zero Manual Coordinates.

Instead of brittle X/Y pixel placements, Dhi arranges diagrams as physical assemblies: a ground reference anchor, independent branch clusters, and shared-node joint bridges—paired with autonomous collector rails, flank sinks, and zero-tangle planar port sorting.

Read Kinematic Layout Guide →
reference (Anchor) — Pins the primary SpineAssembly datum at origin (0, 0) using column strategy with centered alignment.
Sandbox ↗
1dialect uml;
2​
3uml::state_machine "Kinematic Layout Mechanism Showcase" {
4 schema {
5 pub event accept DispatchWork;
6 pub event accept AuditTelemetry;
7 pub event accept RotateLog;
8​
9 state initial @Ingress [label: "Ingress Stream"];
10 state @Dispatcher [label: "Event Dispatcher"];
11 state @Processor [label: "High-Speed Core"];
12 state @Logger [label: "Telemetry Logger"];
13 state final @Archive [label: "Cold Archive"];
14 }
15​
16 flow {
17 Ingress -> Dispatcher;
18 Dispatcher on DispatchWork -> Processor;
19 Dispatcher on AuditTelemetry -> Logger;
20 Processor -> Archive;
21 Logger on RotateLog -> Archive;
22​
23 note @loggerNote [on: Logger, pos: right] "Zero-loss ring buffer";
24 }
25​
26 layout {
27 let BASE_GAP = 50;
28 let LOCAL_GAP = 40;
29​
30 // Kinematic Reference Assembly (Spine / Anchor)
31 reference SpineAssembly: column [gap: BASE_GAP, align: center] {
32 state @Ingress
33 state @Dispatcher
34 state @Processor
35 }
36​
37 // Kinematic Branch Assembly (Dynamic Side Chain)
38 branch TelemetryBranch: column [gap: LOCAL_GAP, align: center] {
39 state @Logger
40 state @Archive
41 }
42​
43 // Kinematic Joint (Constrains relative placement between assemblies)
44 joint DispatcherToLogger: row [gap: 90, align: middle] {
45 state @Dispatcher
46 state @Logger
47 }
48​
49 note @loggerNote { offset_x: 20, offset_y: -10 }
50 }
51​
52 theme {
53 edge: [stroke: [color: "#64748b", width: 1.5]];
54 }
55}
56​
Errors: 0 | state_machine
Read-Only Preview

One Language. Fifteen Diagram Types.

Switch tabs to inspect real .dhi source on the left alongside its rendered diagram on the right.

uml::sequence_diagram · actor/client/service/database lifelines, phases, alt/else, par, async, notes Full reference →
Sandbox ↗
1dialect uml;
2​
3uml::sequence_diagram "E-Commerce Checkout Workflow" {
4​
5 schema {
6 lifeline actor @Customer [label: "Customer"];
7 lifeline client @Storefront [label: "Web Storefront"];
8 lifeline service @OrderAPI [label: "Order API Gateway"];
9 lifeline database @InventoryDB [label: "Inventory DB"];
10 lifeline service @PaymentSvc [label: "Payment Gateway"];
11 lifeline service @AuditLogger [label: "Audit Logger"];
12 lifeline service @EmailGateway [label: "Email Gateway"];
13 lifeline service @WarehouseSvc [label: "Warehouse Service"];
14 }
15​
16 flow {
17 phase "Phase 1: Order Placement & Verification";
18​
19 Customer -> Storefront.checkout: "submitCart(cart_id)";
20​
21 Storefront.checkout {
22 note @sessionValNote [on: Storefront, pos: left] "Validates session token before calling API";
23 -> OrderAPI.createOrder: "POST /api/v1/orders" => "201 Created(order_id)";
24 }
25​
26 OrderAPI.createOrder {
27 -> self.validatePayload: "orderData" => isValid;
28​
29 -> InventoryDB.reserveItems: "reserve(cart_id)" => reservationToken;
30​
31 alt "Stock Available" {
32 -> PaymentSvc.charge: "processPayment(amount)" => txn_id;
33​
34 note @mtlsNote [on: PaymentSvc, pos: right] "Secured via mTLS & Idempotency Key";
35​
36 create service WorkerTask [label: "Order Worker"];
37 -> WorkerTask.execute: "runPostOrderTasks(order_id)";
38 } else "Out of Stock" {
39 -> async AuditLogger.logFailure: "Inventory Conflict for cart_id";
40 }
41 }
42​
43 phase "Phase 2: Asynchronous Fulfillment & Cleanup";
44​
45 WorkerTask.execute {
46 par "Customer Receipt" {
47 -> async EmailGateway.sendReceipt: "sendConfirmationEmail(order_id)";
48 } also "Warehouse Dispatch" {
49 -> async WarehouseSvc.printPackingSlip: "enqueueShippingLabel(order_id)";
50 }
51​
52 loop "Retry status sync (3x)" {
53 -> InventoryDB.confirmSync: "confirm(order_id)" => synced;
54 }
55​
56 destroy WorkerTask;
57 }
58​
59 Storefront -> Customer: "renderOrderConfirmationPage()";
60 }
61​
62 layout {
63 lifeline @Customer { offset_x: 0 }
64 lifeline @Storefront { offset_x: 160 }
65 lifeline @OrderAPI { offset_x: 320 }
66 lifeline @InventoryDB { offset_x: 480 }
67 lifeline @PaymentSvc { offset_x: 640 }
68 lifeline @AuditLogger { offset_x: 800 }
69 lifeline @EmailGateway { offset_x: 960 }
70 lifeline @WarehouseSvc { offset_x: 1120 }
71 }
72}
73​
74​
Errors: 0 | sequence-diagram
Read-Only Preview

Scale beyond monolith diagrams.

Organize large architectures across separate .dhi files. Declare submodules with mod, export public boundaries with pub, and compose them via whole-module use imports inside subsystem frames.

Sandbox ↗
1dialect uml;
2​
3mod specs;
4​
5uml::sequence_diagram "E-Commerce Checkout Flow" {
6 schema {
7 lifeline actor @User [label: "Customer"];
8 lifeline client @WebApp [label: "Storefront WebApp"];
9​
10 // Nested frame composition wrapping auth module
11 frame subsystem @security [label: "Security Perimeter"] {
12 use specs::auth as auth;
13 }
14​
15 // Subsystem frame enclosing order module
16 frame subsystem @orderSubsystem [label: "Order Processing"] {
17 use specs::order as order;
18 }
19​
20 // Standalone whole-module import (atomic frame slot)
21 use specs::payment as pay;
22 }
23​
24 flow {
25 phase "Phase 1: Authentication & Cart Checkout";
26​
27 User -> WebApp.submitOrder: "POST /api/checkout" => "checkoutResult";
28​
29 WebApp.submitOrder {
30 -> auth::AuthSvc.verifyToken: "verify(token)" => "userSession";
31 -> order::OrderSvc.checkout: "processOrder(cart)" => "orderStatus";
32 }
33​
34 phase "Phase 2: Payment Authorization & Fulfillment";
35​
36 WebApp -> pay::PaymentGateway.charge: "authorizePayment(cardToken)" => txnReceipt [min: 10ms, max: 50ms];
37​
38 loop "Retry on Network Failure (Max 3)" {
39 WebApp -> async order::OrderSvc.notifyFulfilled: "emitOrderPaid(orderId)";
40 }
41 }
42​
43 layout {
44 frame @security {
45 offset_x: 20
46 display_state: "expanded"
47 }
48 frame @orderSubsystem {
49 offset_x: 40
50 width: 500
51 display_state: "expanded"
52 }
53 frame @pay {
54 offset_x: 60
55 display_state: "collapsed"
56 }
57 }
58}
59​
Errors: 0 | modular_ecommerce
Read-Only Preview

VS Code extension releasing soon.

DHI Language Support (v0.1.0 Early Preview) is releasing soon for VS Code and compatible editors—bringing the built-in offline compiler directly into your workspace with no CLI binaries or external servers required.

  • Built-In Offline Compiler Compile and lay out .dhi diagrams offline directly inside VS Code.
  • Cross-Diagram Language Intelligence Cross-file diagnostics (E001–E306), qualified alias:: autocomplete, hover docs, find-all-references, cross-file rename, and go-to-definition across use and link boundaries.
  • Side-by-Side Read-Only Preview Open any .dhi file (Ctrl+Shift+V / Cmd+Shift+V) for pan, zoom, minimap, fit-to-view, and click-to-reveal source lines.
  • Automatic Theme Adaptation Diagrams follow your active VS Code Light, Dark, or High-Contrast theme seamlessly.
  • Markdown Code Blocks Syntax highlighting for ```dhi blocks inside Markdown files.