likec4
CLI Toollikec4/likec4
Code-driven tool to create live C4-style architecture diagrams.
Overview
LikeC4 is a modeling language and toolset inspired by the C4 model. It generates always up-to-date diagrams directly from your code, enabling collaboration and evolution of software architecture. Includes a CLI, VS Code extension, and a live preview server.
README Preview
# Architecture as a code\n\nVisualize, collaborate on, and evolve your software architecture with always up-to-date, live diagrams generated from your code.\n\n[docs](https://likec4.dev/) - [playground](https://playground.likec4.dev/) - [demo](https://template.likec4.dev/view/index)\n\n \n\n\n\n\n\n\n## What is LikeC4? Why "like"?\n\nLikeC4 is a modeling language for describing software architecture and tools to generate diagrams from the model.\n\nLikeC4 is inspired by [C4 Model](https://c4model.com/) and [Structurizr DSL](https://github.com/structurizr/dsl), but provides some flexibility.\nYou customize or define your own notation, element types, and any number of nested levels in architecture model.\\nPerfectly tailored to your needs.\n\n## What does LikeC4 look like?\n\nLikeC4 source:\n\n\n \n\n\nRun [CLI](./packages/likec4/README.md) to preview:\n\n```sh\nnpx likec4 start\n```\n\nAnd result:\n\n\n \n\n\nTemplate repository - [likec4/template](https://github.com/likec4/template)\\nDeployed - [https://template.likec4.dev](https://template.likec4.dev/view/index)\n\n[](https://stackblitz.com/~/github.com/likec4/template)\n\nCheck [Tutorial](https://likec4.dev/tutorial/) - for a quick overview of LikeC4.\n\n## Getting help\n\nWe are always happy to help you get started:\n\n- [Join Discord community](https://discord.gg/86ZSpjKAdA) – it is the easiest way to get help\n- [GitHub Discussions](https://github.com/likec4/likec4/discussions) – ask anything about the project or give feedback\n\n## Contributors\n\n\n \n\n\n[Become a contributor](./CONTRIBUTING.md)\n\n## Support development\n\nLikeC4 is a MIT-licensed open source project with its ongoing development made possible entirely by your support.\\nIf you like the project, please consider contributing financially to help grow and improve it.\\nYou can support us via [OpenCollective](https://opencollective.com/likec4) or [GitHub Sponsors](https://github.com/sponsors/likec4).\n\n## License\n\nThis project is release
FAQ (5)
TroubleshootingHow do I fix LikeC4 error "Layout validation failed: Element @owner not found" for a relationship between two imported sibling elements?
This affects LikeC4 CLI 1.59.3 and 1.59.4. When imported elements such as @owner.a and @owner.b are connected, commonAncestor() incorrectly treats the project namespace @owner as a model element.
Immediate workaround: place both elements under a real parent element and import that parent.
In owner/model.c4:
model {
system platform {
system a
system b
}
}
In consumer/model.c4:
import { platform } from 'owner'
model {
platform.a -> platform.b "Example relationship"
}
views {
view example {
include platform.a, platform.b
}
}
Permanent fix: in packages/core/src/utils/fqn.ts, update commonAncestor() so a single @namespace segment is not returned as an ancestor:
if (
ancestor.length === 0 ||
(ancestor.length === 1 && ancestor[0]!.startsWith('@'))
) {
return null
}Use a patched build or upgrade to a release containing the PR "fix(core): ignore project namespace in commonAncestor of imported elements". Verify with:
npx likec4 validate --project consumer . --jsonTroubleshootingHow do I fix the LikeC4 visual editor inserting duplicate style rules outside a dynamic view?
Upgrade to LikeC4 v1.59.4 or newer; the bug was fixed in the language-server by inserting style changes before the view's closing brace. After upgrading, delete the duplicate style blocks from the surrounding views block and keep only the rule inside the edited dynamic view, for example:
dynamic view example {
user -> app
style app {
shape mobile
}
}
As a temporary workaround on v1.59.3, add any local style rule inside the dynamic view before using the visual editor, such as style user {}, so subsequent style insertions remain inside the view.
TroubleshootingWhy are long metadata values not truncated and the full-value tooltip missing in the LikeC4 element details dialog?
The value grid column uses 1fr, which resolves to minmax(auto, 1fr). With white-space: nowrap, its minimum width becomes the full text width, so the column expands instead of truncating the value. Fix the grid in packages/diagram/src/overlays/element-details/ElementDetailsCard.tsx by changing the value column to minmax(0, 1fr):
gridTemplateColumns: 'min-content minmax(0, 1fr)'
Also add minWidth: 0 to the metadata value wrapper in packages/diagram/src/overlays/element-details/MetadataValue.tsx, while keeping the truncation styles:
{
minWidth: 0,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
}
This allows the column to shrink below its content width, makes scrollWidth > clientWidth true for long values, and enables the hover tooltip. Short values remain unchanged. If the tooltip appears behind the dialog backdrop after this fix, also raise the portal tooltip’s z-index above the <dialog> and backdrop (related to #3256).
TroubleshootingWhy is the relationship kind default title missing in LikeC4 dynamic view steps?
This is a bug in LikeC4 1.59.3: a relationship kind's default technology is applied to dynamic view steps, but its default title is not. Upgrade to a release containing the fix fix(core): apply relationship kind default title to dynamic view steps. As a workaround, repeat the title explicitly on the step:
gatewayService2 -[discover]-> discoveryServer ':8761'
Without the explicit ':8761', the title will not render until the fixed version is used.
TroubleshootingHow to fix LikeC4 HTML export ignoring a dynamic view's "variant: sequence" attribute and showing the diagram view?
This happens because the exported SPA defaults the URL dynamic parameter to diagram on initial render, overriding the view's configured variant: sequence.
Temporary workaround: open the exported HTML with the explicit query parameter:
index.html?dynamic=sequence
If the URL already has a query string, use:
index.html?...&dynamic=sequence
For a local single-file export, open it as, for example:
file:///absolute/path/to/index.html?dynamic=sequence
Permanent fix: upgrade to a LikeC4 release containing the fix "respect dynamic view variant on initial render," then rebuild:
npx -y likec4@latest build -o "./html" --output-single-file