Multi-projects
Sometimes you may want to split your LikeC4 model into multiple ones, based on domains, teams, or any other criteria.
You can do this by creating multiple projects in your workspace and linking them together.
You can also use this feature to share your model with other teams or projects.
Create likec4.config.json files in the folders you want to be projects:
Directorycloud
- likec4.config.json
- service1.c4
- service2.c4
- …
Directoryexternals
- likec4.config.json
- amazon.c4
- …
Projects can be nested.
In this case, files from the nested project are not part of the parent project.
Directorycloud
- likec4.config.json
- service1.c4
- service2.c4
Directorynested
- likec4.config.json
- service3.c4 // this will be part of the ‘nested’ project, not the ‘cloud’ project
Import elements
Section titled “Import elements”You can import elements from other projects by using the import keyword.
import { serviceA } from 'projectA'
model { serviceB = service { -> serviceA.api 'calls serviceA' }}Share specification
Section titled “Share specification”You can share specification files (or any other LikeC4 sources) across multiple projects using the include configuration option.
Using include paths
Section titled “Using include paths”Add an include configuration to your project to include files from directories outside the project folder:
{ "$schema": "https://likec4.dev/schemas/config.json", "name": "cloud", "include": { "paths": ["../shared"] }}Directoryshared
- specs.c4
- common-styles.c4
Directorycloud
- likec4.config.json
- services.c4
- …
Directoryexternals
- likec4.config.json
- amazon.c4
- …
Both cloud and externals projects can include the shared specification:
{ "$schema": "https://likec4.dev/schemas/config.json", "name": "cloud", "include": { "paths": ["../shared"] }}{ "$schema": "https://likec4.dev/schemas/config.json", "name": "externals", "include": { "paths": ["../shared"] }}Include configuration
Section titled “Include configuration”The include configuration accepts an object with the following properties:
{ "$schema": "https://likec4.dev/schemas/config.json", "name": "my-project", "include": { "paths": ["../shared", "../common/specs"], "maxDepth": 5, "fileThreshold": 50 }}paths- Array of relative directory paths (required)maxDepth- Maximum directory depth to scan (default: 3, range: 1-20)fileThreshold- Warn if more than this many files are loaded (default: 30)
Using symlinks (alternative)
Section titled “Using symlinks (alternative)”Alternatively, you can use symlinks to share files:
Directoryshared
- specs.c4
Directorycloud
- specs.c4 // -> ../shared/specs.c4
- likec4.config.json
- …
Directoryexternals
- specs.c4 // -> ../shared/specs.c4
- likec4.config.json
- …