CLI Architecture
The Seven-Layer Execution System
The Architech CLI implements a sophisticated seven-layer architecture that transforms TypeScript genomes into generated projects through a series of well-defined, isolated stages.
The Complete Flow
Layer Descriptions
Layer 1: CLI Command Layer β
Entry point for user commands. Loads and validates TypeScript genomes using tsx.
Layer 2: Orchestrator Layer β
Coordinates the entire execution. Handles dependency resolution, blueprint loading, and VFS lifecycle management.
Layer 3: Blueprint Preprocessor β
Converts dynamic blueprint functions into static action arrays for execution.
Layer 4: Blueprint Executor β
Analyzes blueprints, pre-populates VFS, expands forEach actions, and delegates to action handlers.
Layer 5: Action Handler Layer β
Routes semantic actions to appropriate handlers for execution.
Layer 6: Modifier Layer β
Performs complex file modifications using AST manipulation via ts-morph.
Layer 7: Virtual File System β
Provides safe, atomic file operations with in-memory processing.
Core Subsystems
Beyond the 7 layers, several critical subsystems enable the CLI's functionality:
Type System β
How the types package provides shared contracts between CLI and Marketplace.
Dependency Resolution β
Topological sorting, capability registry, and prerequisite validation.
Caching System β
How the CacheManagerService optimizes blueprint loading and execution.
Key Architectural Decisions
The CLI's architecture embodies specific design choices:
- Per-Blueprint VFS Isolation - Each blueprint runs in its own sandbox
- AST Not Regex - Reliable code modification via ts-morph
- Dynamic Blueprints - Functions that generate actions based on config
- Semantic Actions - High-level operations, not primitives
- Fail-Fast Philosophy - Any error stops execution immediately
Each decision has deep rationale. See Design Decisions β for complete analysis.
Reading Guide
For Understanding:
- Start with Execution Flow
- Read each layer's page sequentially
- Study Type System
- Review Dependency Resolution
For Contributing:
- Understand Blueprint System
- Learn Blueprint Actions
- Study Modifiers
- Review Design Decisions
For Evaluating:
- Review Architecture Overview
- Check Limitations
- See Design Decisions for rationale
Next Steps
Begin with the Execution Flow β
Or jump to a specific topic: