website/docs/how-it-works/project-graph.mdx
import ProjectGraph from '@site/src/components/Docs/ProjectGraph';
The project graph is a representation of all configured projects in the workspace and their relationships between each other, and is represented internally as a directed acyclic graph (DAG). Below is a visual representation of a project graph, composed of multiple applications and libraries, where both project types depend on libraries.
<ProjectGraph />:::info
The moon project-graph command can be used to view the structure of
your workspace.
:::
A relationship is between a dependent (downstream project) and a dependency/requirement (upstream project). Relationships are derived from source code and configuration files within the repository, and fall into 1 of 2 categories:
These are dependencies that are explicitly defined in a project's moon.*
config file, using the dependsOn setting.
dependsOn:
- 'components'
- id: 'utils'
scope: 'peer'
These are dependencies that are implicitly discovered by moon when scanning the repository. How an implicit dependency is discovered is based on a language's platform integration, and how that language's ecosystem functions.
{
// ...
"dependencies": {
"@company/components": "workspace:*"
},
"peerDependencies": {
"@company/utils": "workspace:*"
}
}
:::caution
If a language is not officially supported by moon, then implicit dependencies will not be resolved. For unsupported languages, you must explicitly configure dependencies.
:::
Every relationship is categorized into a scope that describes the type of relationship between the parent and child. Scopes are currently used for project syncing and deep Docker integration.
Great question, the project graph is used throughout the codebase to accomplish a variety of functions, but mainly: