The Architech CLI
The Generic Code Generation Engine
The Architech CLI is the core execution engine β a sophisticated, unopinionated platform that transforms TypeScript genome files into fully-functional projects.
What is the CLI?
The CLI is not a React tool, or a Next.js generator, or a database scaffolder. It's a generic code generation engine that can create any type of project based on blueprints provided by a marketplace.
Core Purpose
User writes: TypeScript Genome
β
CLI executes: Blueprint Actions
β
Result: Generated ProjectThe CLI doesn't care what you're building. It only cares about how to safely execute the instructions from marketplace blueprints.
CLI vs Marketplace: The Critical Separation
The CLI Provides:
- π§ Blueprint execution engine
- π§ Virtual File System (VFS)
- π§ AST-based file manipulation
- π§ Dependency resolution
- π§ Type-safe genome system
- π§ Error handling & rollback
The Marketplace Provides:
- π― Module blueprints (what to generate)
- π― Technology choices (React, Vue, etc.)
- π― Architectural patterns (TanStack Query, etc.)
- π― Templates and code snippets
The separation means: Same CLI can power a React marketplace, Vue marketplace, Angular marketplace, or your company's internal marketplace.
Key Features
1. TypeScript Genome System
Define projects with full IDE support:
import { defineGenome } from '@thearchitech.xyz/types';
export default defineGenome({
project: {
name: 'my-app',
framework: 'nextjs',
path: './my-app'
},
modules: [
{
id: 'framework/nextjs',
parameters: {
typescript: true, // β Full autocomplete
tailwind: true // β Type-safe
}
}
]
});2. Virtual File System (VFS)
Safe, atomic file operations:
- All changes in memory until commit
- Per-blueprint isolation
- Rollback on errors
- Pre-population for efficiency
3. AST-Based Manipulation
Reliable code modification via ts-morph:
- Add imports without breaking code
- Merge TypeScript files intelligently
- Wrap JSX components
- Handle complex syntax
4. Dynamic Blueprints
Blueprints as functions for conditional generation:
export default function(config: MergedConfiguration): BlueprintAction[] {
const actions = [...coreActions];
if (config.features.mfa) {
actions.push(...mfaActions);
}
return actions;
}5. Intelligent Dependency Resolution
Automatic module ordering via topological sort:
- Adapters before connectors
- Prerequisites validated
- Conflicts detected
6. Semantic Actions
High-level operations that hide complexity:
CREATE_FILE- Create filesENHANCE_FILE- Modify with ASTINSTALL_PACKAGES- Manage dependencies- Not low-level file operations!
Architecture Overview
The 7-Layer Execution Stack
Layer 1: CLI Command Layer
β (validates & loads genome)
Layer 2: Orchestrator Layer
β (resolves dependencies, creates VFS)
Layer 3: Blueprint Preprocessor
β (dynamic β static actions)
Layer 4: Blueprint Executor
β (analyzes, pre-populates VFS, expands forEach)
Layer 5: Action Handlers
β (routes actions)
Layer 6: Modifiers (AST)
β (complex file operations)
Layer 7: Virtual File System
β (atomic flush to disk)Each layer has a specific responsibility and interacts cleanly with adjacent layers.
Documentation Sections
Explore the CLI in depth:
Architecture β
Deep dive into the 7-layer system, execution flow, and core components.
Blueprint Actions β
Complete reference for semantic actions and the modifier system.
Design Decisions β
Why we made specific architectural choices and their trade-offs.
Limitations & Future β
Honest assessment of current limitations and proposed upgrades.
Reference β
Complete CLI API reference, commands, and configuration.
Who Should Read This?
If You Want To:
- Understand how The Architech works internally β Start with Architecture
- Create marketplace modules β Read Blueprint Actions
- Contribute to CLI development β Review Design Decisions
- Evaluate The Architech β Check Limitations & Future
- Use CLI commands β See Reference
Core Principles
The CLI is built on three foundational principles:
1. Simplicity for the Creator
Complexity must be in the CLI, never in the blueprint. Blueprint authors use semantic actions, not low-level operations.
2. Security by Default
Never corrupt a user's project. Every operation must be safe, atomic, and reversible.
3. Open Extensibility
Architecture must encourage and facilitate community contribution through clear abstractions.
What Makes This CLI Different
Traditional Code Generators:
- β Template-based (string replacement)
- β Fragile (regex breaks on edge cases)
- β Opinionated (tied to specific tech)
- β Risky (direct file writes)
- β Limited (can't modify existing files)
The Architech CLI:
- β AST-based (reliable modifications)
- β Safe (VFS with atomic operations)
- β Unopinionated (marketplace provides opinions)
- β Powerful (can enhance existing files)
- β Type-safe (TypeScript genomes + validation)
Quick Example: What the CLI Does
User Writes:
// my-app.genome.ts
export default defineGenome({
modules: [
{ id: 'framework/nextjs' },
{ id: 'database/drizzle' },
{ id: 'connector/drizzle-nextjs' }
]
});CLI Executes:
- Loads genome via tsx (TypeScript execution)
- Resolves order via topological sort (nextjs β drizzle β connector)
- Creates VFS for each blueprint
- Loads blueprints from marketplace
- Preprocesses if dynamic (function β actions)
- Executes actions via handlers
- Uses modifiers for AST manipulation
- Flushes to disk atomically
Result:
my-app/
βββ src/
β βββ app/
β β βββ api/users/route.ts β Generated by connector
β βββ db/
β β βββ schema.ts β Generated by drizzle
β βββ hooks/
β βββ use-users.ts β Generated by connector
βββ drizzle.config.ts β Generated by drizzle
βββ next.config.js β Generated by nextjs
βββ package.json β Merged by all modulesAll safe. All atomic. All type-checked.
Dive deep into the architecture to understand how this magic happens.