Skip to content

LikeC4 Diagrams

Speculator provides first-class support for LikeC4 diagrams. LikeC4 allows you to define your architecture as code and render it as interactive diagrams.

The Speculator parser recognizes the <likec4-view> tag and transforms it into a dedicated BlockLikeC4View AST node with type: 'likeC4View'.

This semantic node allows components in the render pipeline (like Astro components) to easily identify and render the diagram using a client:only directive, ensuring that the heavy React-based diagram component is only loaded and executed in the browser.

To include a LikeC4 view in your specification, use the <likec4-view> tag.

<likec4-view view-id="oidc" />
AttributeDescriptionRequired
view-idThe unique identifier of the LikeC4 view to render.Yes
dynamic-variantSpecify a visualization variant. Supported values: diagram, sequence.No

To enable LikeC4 support, you need to configure the LikeC4VitePlugin in your Astro project.

astro.config.mjs
import { LikeC4VitePlugin } from "likec4/vite-plugin";
export default defineConfig({
// ...
vite: {
plugins: [
LikeC4VitePlugin({
workspace: path.resolve("spec"),
}),
],
},
});
<likec4-view view-id="cloud-architecture" dynamic-variant="diagram" />

The rendered diagram will be interactive and responsive, integrated directly into your specification.