# CODE-EXPORT: React Code Export System ## Overview A comprehensive code export system that transforms Nodegx (Noodl) projects into clean, maintainable React 19 applications. Unlike a simple "eject with TODOs" approach, this system generates **fully functional code** by including a small companion library (`@nodegx/core`) that provides Noodl-like reactive primitives. **Phase:** Future (Post Phase 3) **Total Estimated Effort:** 12-16 weeks **Strategic Value:** Very High - eliminates vendor lock-in concern --- ## Philosophy: The Companion Library Approach ### The Problem with Pure Code Export A naive code export faces a fundamental paradigm mismatch: | Noodl Model | React Model | Challenge | |-------------|-------------|-----------| | Push-based signals | Pull-based rendering | Signals → useEffect chains | | Global Variables | Component state | Cross-component sync | | Observable Objects | Plain objects | Change detection | | Event propagation | Props/callbacks | Parent/child/sibling events | | Visual states | CSS + useState | Animation transitions | Attempting to mechanically translate every pattern results in either: - **Unreadable code** (nested useEffect chains) - **TODO comments** (giving up on hard parts) ### The Solution: @nodegx/core Instead of fighting React's model, we provide a **tiny runtime library (~8KB)** that preserves Noodl's mental model while generating idiomatic code: ``` ┌─────────────────────────────────────────────────────────────────┐ │ project.json │ │ (Noodl Node Graph) │ └─────────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ Code Generator │ │ • Analyze component graph │ │ • Identify state boundaries │ │ • Generate React components │ │ • Preserve Function node code │ │ • Wire up reactive primitives │ └─────────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ Generated Project │ │ │ │ my-app/ │ │ ├── src/ │ │ │ ├── components/ ← Clean React components │ │ │ ├── stores/ ← From Variables/Objects/Arrays │ │ │ ├── logic/ ← Extracted Function node code │ │ │ ├── events/ ← Event channel definitions │ │ │ └── App.tsx ← Root with routing │ │ ├── package.json ← Depends on @nodegx/core │ │ └── vite.config.ts ← Modern build setup │ └─────────────────────────────────────────────────────────────────┘ ``` --- ## Task Series | Task | Name | Effort | Description | |------|------|--------|-------------| | CODE-001 | @nodegx/core Library | 2-3 weeks | Companion runtime library | | CODE-002 | Visual Node Generator | 1-2 weeks | UI components + styling | | CODE-003 | State Store Generator | 1-2 weeks | Variables, Objects, Arrays | | CODE-004 | Logic Node Generator | 2-3 weeks | Functions, Expressions, Logic | | CODE-005 | Event System Generator | 1-2 weeks | Send/Receive Event, Component scope | | CODE-006 | Project Scaffolding | 1-2 weeks | Routing, entry point, build config | | CODE-007 | CLI & Integration | 1-2 weeks | Export command, editor integration | **Total: 12-16 weeks** --- ## Noodl Feature → Generated Code Mapping ### Visual Nodes | Noodl Node | Generated Code | |------------|----------------| | Group | `
` with Flexbox/CSS | | Text | `` / `

` with text binding | | Image | `` with src binding | | Button | `