Modular Architecture

Module System (mod, use, pub, link)

Submodules, barrel mod.dhi files, whole-module imports, frame slotting, and cross-diagram semantic link contracts.

Dhi scales beyond single-file diagrams through strict encapsulation: only pub symbols cross module boundaries (E108), and a module’s internal flow never merges silently into another file.

Submodules (mod) & Barrel Files

Declare submodules with mod <name>; (resolved from <name>.dhi or <name>/mod.dhi). Directory barrel files (mod.dhi) may contain pub mod and pub use declarations only—never a diagram with a flow block (E001).

src/specs/mod.dhi — directory barrel file
pub mod auth;
pub mod order;
pub mod payment;

pub use self::auth;
pub use self::order;
pub use self::payment;

Whole-Module Imports (use) & Frame Slotting

External modules must be imported inside schema { } (E136) as whole units via use <path> [as <alias>];. Granular symbol imports like use path::Symbol; are forbidden (E137), and external symbols must be addressed with alias::Symbol (E138).

src/main.dhi — composing subsystems inside frames
dialect uml;

mod specs;

uml::sequence_diagram "E-Commerce Checkout" {
  schema {
    lifeline actor @User;
    frame subsystem @security [label: "Security Perimeter"] {
      use specs::auth as auth;
    }
    use specs::payment as pay;
  }

  flow {
    User -> auth::AuthSvc.verifyToken: "verify(jwt)" => "session";
    auth::AuthSvc -> pay::PaymentGateway.charge: "charge()" => "receipt";
  }
}

Cross-Diagram Semantic Linking (link)

While use imports reusable symbols and frames, link connects independent diagrams across the system model (class models, state machine lifecycles, sequence realizations) with zero spatial canvas footprint. Cross-diagram links are strictly private (pub link emits E229).

Linking a sequence diagram to a class model and state machine
schema {
  link class models::order as order_model;
  link state_machine flows::order_fsm as order_fsm [strict: true];

  lifeline @order: order_model::Order;
}

Cross-Diagram Language Intelligence

Because use and link create statically typed edges across your workspace, editor tooling understands your entire architecture as one connected model rather than isolated text files:

CapabilityCross-File Behavior
Live Cross-File DiagnosticsEditing an exported class, blueprint, or state machine re-validates every linked diagram in real time (e.g., E211 kind mismatch, E212 unresolved target, E266 contract type mismatch).
Go-to-Definition (Ctrl+Click)Jump directly from a typed lifeline to its class, from a sequence arrow to its method, or from a lifecycle reference to its state machine across use and link boundaries.
Find All References & RenameLocate every usage of a participant, class, or state across linked workspace files and rename symbols safely in a single workspace edit.
Qualified Autocomplete & HoverType alias:: to complete exported symbols and inspect /// doc comments or #[doc("...")] metadata inline.