Rule Engine
The Rule Engine is the core component that validates architectural constraints. It allows you to define “Source” vs “Target” relationships that are forbidden.
Structure of a Rule
A rule consists of:
- Source Pattern: Regex string matching the “User” (the asset having the dependency).
- Target Pattern: Regex string matching the “Dependency” (the asset being used).
- Type: Currently supports
Forbidden. - Description: Human-readable explanation of why this rule exists.
Regex Matching
The engine uses C# Regular Expressions (System.Text.RegularExpressions) to match asset names or paths.
.*Core.*matches any path containing “Core”.^Assets/Scripts/UI/.*matches scripts strictly inside the UI folder.
Built-in Presets
Nexus Graph comes with built-in presets you can switch between in the Tool:
1. Default
General common sense rules.
- UI cannot depend on Core: Prevents UI systems from tightly coupling with business logic (often it should be the reverse or event-driven).
- View cannot depend on Model: Enforces MVC separation.
2. Clean Architecture
Strict enforcement of Domain-Driven Design / Clean Architecture layers.
Core -> UI(Forbidden)Core -> Scene(Forbidden)Domain -> Infrastructure(Forbidden)
3. Mobile Safe
Rules focused on performance.
*Resources* -> *(Forbidden): Discourages use ofResourcesfolder due to memory overhead.Scene -> Editor(Forbidden): Ensures runtime scenes don’t accidentally reference Editor scripts (which causes build failures).