Skip to content

ayida

GitHub →

ayida compiles a C4 model architecture from HCL. You describe the architecture once, in *.ayida.hcl files. Diagrams, markdown, a browsable site, graph queries, a machine-readable export, a semantic diff between revisions, and an MCP server for AI assistants are all projections of the compiled result.

This documentation describes ayida v2.1.1. ayida was previously named loko. To move a loko 1.6 project, follow Upgrading from loko.
See it rendered. The microservices example is built with ayida build and hosted live at docs.mdstn.dev/ayida/demo. It shows the same diagrams, element pages and navigation that ayida produces from HCL.

What it does

CommandWhat you get
ayida validateEvery problem in the architecture, with file, line and column
ayida fmtCanonical formatting, like terraform fmt
ayida buildD2 and SVG diagrams, markdown and a static site. No d2 binary needed
ayida serveA live preview that rebuilds as you edit
ayida queryDependents, dependencies, paths, orphans, coupling and listings
ayida exportThe compiled architecture as JSON or TOON
ayida diffWhat changed between two revisions, and the elements each change affects
ayida changelogThe same changes as markdown, for release notes
ayida mcpAn MCP server: assistants describe, query, validate and edit the HCL

Why a compiler

When an architecture lives in several places, such as diagram files, wiki pages and frontmatter, the copies drift apart and nothing says which one is right. ayida has one authored artefact, the HCL, and it checks every reference in it at compile time. A broken relationship is an error with a position:

Error: Unresolvable reference
  on arch.ayida.hcl:28:19:
  28 |     target      = container.ordrs_db
                         ^^^^^^^^^^^^^^^^^^
  No element "container.ordrs_db" is declared. Did you mean
  container.orders_db?

Because the source is plain text with stable addresses, you can review an architecture in a pull request and diff it between revisions. An assistant can edit it, and no hand-drawn diagram goes stale.

Core concepts

Two planes. The logical plane is environment-agnostic C4: person, system, container, component, external. The deployment plane instantiates it per environment: deployment, an optional nested node tree, and instance blocks carrying attributes and bindings to real infrastructure such as Terraform addresses.

Relationships nest inside their source. A uses "orders" block inside container "api" has the stable address container.api.uses.orders. kind = "async" or "trigger" changes how it is drawn, never what depends on what.

References are typed and resolved at compile time. container.db is a reference, not a string. A typo is an error with a source range and usually a suggestion.

Prose lives beside the model. docs = "./docs/api.md" attaches markdown to an element; it appears on the element’s site page. Paths resolve from the file that declares them, with the project root as a fallback, so prose survives a file being moved.

Views are generated, declared and dynamic. Every system and container with children gets a diagram automatically. A view block selects elements by reference or tag for a focused picture, and can carry a title, description, direction and layout. A view with step blocks is a dynamic view: an ordered flow through the model, drawn as numbered edges or a sequence diagram.

Diagrams are readable by default. elk lays out every view unless you choose dagre, so edges route at right angles and labels stay legible. Every element is a rounded card with an icon, a bold title, a kind line and a wrapped description. The generated site has a navigation tree, breadcrumbs, light and dark themes, and bundled fonts. It loads nothing from the network, and a theme in templates/ can rebrand it.

Changes are semantic. ayida diff compares two revisions by address. Each change is classed as added, removed, renamed, rewired, attribute changed or rebound, and lists the elements that depend on it. Formatting, comments and declaration order are never changes.

Output is byte-stable. The same source always produces identical bytes, on any machine, in any file-system order, so a committed export is reviewable in a diff.

Three severities, three exit codes. Errors exit 1, warnings exit 2 under --strict, and information lines are advice that never changes an exit code. You can silence warning and information codes per project (ignore_warnings) or per run (--ignore).

The compiler is stateless. No lock file, no state file, no database. Git is the history.

Why “ayida”?

Ayida Wedo is the lwa of the rainbow in Haitian Vodou. With Damballa she joins the earth and the sky, and holds together what would otherwise stay apart. Like Ayida, this tool joins the parts of an architecture into one model that people and assistants can read.

License

ayida is licensed under the Business Source License 1.1.