Module System Architecture
Module Package Structure
Modules are packaged as.imodspec files, which are XML-based manifests that define:
- Module metadata (id, version, dependencies)
- Templates to be registered
- Factory extensions for lifecycle hooks
- Metadata providers for designer integration
Template Execution Pipeline
Template Registration
Templates are discovered and registered through
TemplateRegistration classes. Each template gets a unique ID and is bound to metadata models.Location: source/Modules/Intent.Modules.Common/Templates/IntentTemplateBase.cs:120
Decorator Injection
Decorators are added to templates to modify their behavior. Decorators are ordered by priority and executed in sequence.
Location: source/Modules/Intent.Modules.Common/Templates/IntentTemplateBase.cs:20-48
Template Configuration
Templates are configured through lifecycle hooks:
OnCreated()- Called after template creationOnConfigured()- Called after all templates are configuredAfterTemplateRegistration()- Called after all templates are registered
Core Architectural Patterns
Base Template Classes
All templates inherit fromIntentTemplateBase which provides:
Model Binding
Templates can be bound to metadata models from designers, enabling model-driven code generation.
Type Resolution
Built-in type resolution system for cross-template references and dependency tracking.
Output Targeting
Templates target specific output locations (projects, folders) through
IOutputTarget.Lifecycle Hooks
Multiple lifecycle hooks for initialization, configuration, and execution phases.
Decorator Pattern Implementation
Decorators extend template functionality without modifying the base template. They’re used for:- Adding cross-cutting concerns (logging, validation)
- Injecting code into specific locations
- Modifying template output
- Adding dependencies and imports
Location: source/Modules/Intent.Modules.Common/Templates/DecoratorBase.cs:7-21
Decorators with lower priority values execute first. Default priority is 0.
Factory Extension Lifecycle
FactoryExtensionBase allows modules to hook into the Software Factory execution process:
Location: source/Modules/Intent.Modules.Common/Plugins/FactoryExtensionBase.cs:41-56
Execution Phases
Execution Phases
OnStart- Software Factory initializationOnBeforeMetadataLoad- Before designer metadata is loadedOnAfterMetadataLoad- After metadata is availableOnBeforeTemplateRegistrations- Before templates are registeredOnAfterTemplateRegistrations- After all templates are registeredOnBeforeTemplateExecution- Before templates executeOnAfterTemplateExecution- After templates have runOnBeforeCommitChanges- Before changes are written to diskOnAfterCommitChanges- After all changes are committed
Metadata Provider System
Metadata providers expose designer models to templates through strongly-typed APIs:Model Definition
Models are defined in Intent Architect designers (Domain Designer, Services Designer, etc.)
Type Resolution and Dependencies
The type resolution system enables templates to reference types from other templates:Location: source/Modules/Intent.Modules.Common/Templates/IntentTemplateBase.cs:362-390
- Type Sources: Templates register themselves as type sources for others to discover
- Dependency Tracking: When a template resolves a type from another template, a dependency is automatically created
- Collection Formatters: Control how collection types are formatted (e.g.,
List<T>,T[],IEnumerable<T>)
Learn More
Deep dive into the type resolution system and how to use
GetTypeName() methodsSoftware Factory Execution Context
TheISoftwareFactoryExecutionContext provides access to application-wide services:
- File system operations
- Template discovery and lookup
- Event bus for inter-module communication
- Configuration and settings
- Logging infrastructure
Location: source/Modules/Intent.Modules.Common/Templates/IntentTemplateBase.cs:150-154
Next Steps
Quick Start
Build your first module in under 10 minutes
Template Development
Learn how to create templates
Decorator Development
Extend templates with decorators
Factory Extensions
Hook into the execution lifecycle