Architectural Deep Dive
Welcome to the internal documentation of LegoDOM.
This isn't a "how to use" guide. This is a "how it works" guide. Understanding the soul of LegoDOM will make you a better contributor.
The Philosophy
"The Platform is the Runtime."
We avoid compilers, transpilers, and VDOMs. We use:
- ES6 Modules for organization
- Proxies for state
- TreeWalkers for scanning
- Regex for parsing
- MutationObservers for efficiency
- Shadow DOM for encapsulation
The Modular Architecture
LegoDOM evolved from a 1500-line IIFE to a clean, modular ES6 codebase organized in src/:
src/
├── index.js # The Assembler
├── core/ # Framework core
├── directives/ # Directive implementations (b-if, b-for, etc.)
├── features/ # Optional features (router, persistence, errors)
└── utils/ # Shared utilitiesThe Journey
Follow the path of a block from definition to pixels:
- Module Pattern - From IIFE to ES6 modules
- Registry - The block storage system
- Batcher - Render queue & RAF optimization
- Reactivity - Proxy-based state management
- Caching - LRU expression cache
- Init - How LegoDOM wakes up
- Registry - Native Web Components Integration
- Snap - The lifecycle & Shadow DOM
- Diffing - No VDOM? No problem
- Studs - The three-tier data system
- Scanner - Template parsing (Regex vs AST)
- Render - The "Loop of Truth" & Security
- Directives - Extracted directive system
- Events - Event handling & modifiers
- Router - The "Surgical" Update philosophy
- State - Global state & $db
- LegoDOM - The public API
- Directive Lifecycle - Scan, Execute, Destroy
Dive in.