# OpenNoodl Codebase Quick Navigation ## πŸ—ΊοΈ Package Map ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ MONOREPO ROOT β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ package.json β†’ Workspace config, global scripts β”‚ β”‚ lerna.json β†’ Monorepo management β”‚ β”‚ scripts/ β†’ Build and CI scripts β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β–Ό β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ ⚑ EDITOR (GPL) β”‚ β”‚ RUNTIME (MIT) β”‚ β”‚ UI LIBRARY β”‚ β”‚ noodl-editor β”‚ β”‚ noodl-runtime β”‚ β”‚ noodl-core-ui β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ Electron app β”‚ β”‚ β€’ Node engine β”‚ β”‚ β€’ React componentsβ”‚ β”‚ (DESKTOP ONLY) β”‚ β”‚ β€’ Data flow β”‚ β”‚ β€’ Storybook (web) β”‚ β”‚ β€’ React UI β”‚ β”‚ β€’ Event system β”‚ β”‚ β€’ Styling β”‚ β”‚ β€’ Property panels β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β–Ό β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ 🌐 VIEWER (MIT) β”‚ β”‚ β”‚ noodl-viewer-reactβ”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ React runtime β”‚ β”‚ β”‚ β€’ Visual nodes β”‚ β”‚ β”‚ β€’ DOM handling β”‚ β”‚ β”‚ (WEB - Runs in β”‚ β”‚ β”‚ browser) β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ ⚑ PLATFORM LAYER (Electron) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ noodl-platform β”‚ platform-electron β”‚ platform-node β”‚ β”‚ (abstraction) β”‚ (desktop impl) β”‚ (server impl) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ⚑ = Electron Desktop Application (NOT accessible via browser) 🌐 = Web Application (runs in browser) ``` ## πŸ–₯️ Architecture: Desktop vs Web **Critical Distinction for Development:** | Component | Runtime | Access Method | Purpose | | ---------------- | ---------------- | ------------------------------------- | ----------------------------- | | **Editor** ⚑ | Electron Desktop | `npm run dev` β†’ auto-launches window | Development environment | | **Viewer** 🌐 | Web Browser | Deployed URL or preview inside editor | User-facing applications | | **Runtime** | Node.js/Browser | Embedded in viewer | Application logic engine | | **Storybook** 🌐 | Web Browser | `npm run start:storybook` β†’ browser | Component library development | **Important for Testing:** - When working on the **editor**, you're always in Electron - Never try to open `http://localhost:8080` in a browser - that's the webpack dev server internal to Electron - The editor automatically launches as an Electron window when you run `npm run dev` - Use Electron DevTools (View β†’ Toggle Developer Tools) for debugging the editor - Console logs from the editor appear in Electron DevTools, NOT in the terminal --- ## πŸ“ Key Directories ### noodl-editor (Main Application) ``` packages/noodl-editor/src/ β”œβ”€β”€ editor/src/ β”‚ β”œβ”€β”€ models/ # 🎯 Business logic & data β”‚ β”‚ β”œβ”€β”€ projectmodel.ts β†’ Project state β”‚ β”‚ β”œβ”€β”€ nodegraphmodel.ts β†’ Graph structure β”‚ β”‚ β”œβ”€β”€ componentmodel.ts β†’ Components β”‚ β”‚ β”œβ”€β”€ nodelibrary/ β†’ Node type registry β”‚ β”‚ β”œβ”€β”€ AiAssistant/ β†’ AI features β”‚ β”‚ └── sidebar/ β†’ Sidebar state β”‚ β”‚ β”‚ β”œβ”€β”€ views/ # πŸ–₯️ UI components β”‚ β”‚ β”œβ”€β”€ nodegrapheditor.ts β†’ Canvas/graph editor β”‚ β”‚ β”œβ”€β”€ panels/ β†’ Property panels β”‚ β”‚ β”œβ”€β”€ NodePicker/ β†’ Node creation UI β”‚ β”‚ β”œβ”€β”€ documents/ β†’ Document views β”‚ β”‚ └── popups/ β†’ Modal dialogs β”‚ β”‚ β”‚ β”œβ”€β”€ utils/ # πŸ”§ Utilities β”‚ β”‚ β”œβ”€β”€ CodeEditor/ β†’ Monaco integration β”‚ β”‚ β”œβ”€β”€ filesystem.ts β†’ File operations β”‚ β”‚ └── projectimporter.js β†’ Import/export β”‚ β”‚ β”‚ β”œβ”€β”€ store/ # πŸ’Ύ Persistent state β”‚ β”‚ └── AiAssistantStore.ts β†’ AI settings β”‚ β”‚ β”‚ └── pages/ # πŸ“„ Page components β”‚ └── EditorPage/ β†’ Main editor page β”‚ β”œβ”€β”€ main/ # ⚑ Electron main process β”‚ └── main.js β†’ App entry point β”‚ └── shared/ # πŸ”— Shared utilities └── utils/ └── EventDispatcher.ts β†’ Pub/sub system ``` ### noodl-runtime (Execution Engine) ``` packages/noodl-runtime/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ nodes/ # πŸ“¦ Node implementations β”‚ β”‚ └── std-library/ β”‚ β”‚ β”œβ”€β”€ data/ β†’ Data nodes (REST, DB, etc.) β”‚ β”‚ β”œβ”€β”€ logic/ β†’ Logic nodes β”‚ β”‚ └── events/ β†’ Event nodes β”‚ β”‚ β”‚ β”œβ”€β”€ node.js # Base node class β”‚ β”œβ”€β”€ nodedefinition.js # Node definition API β”‚ β”œβ”€β”€ noderegister.js # Node registry β”‚ β”œβ”€β”€ nodescope.js # Component scope β”‚ └── nodecontext.js # Runtime context β”‚ └── noodl-runtime.js # Main runtime entry ``` ### noodl-viewer-react (React Runtime) ``` packages/noodl-viewer-react/src/ β”œβ”€β”€ nodes/ # 🎨 Visual nodes β”‚ β”œβ”€β”€ basic/ β†’ Group, Text, Image β”‚ β”œβ”€β”€ controls/ β†’ Button, Input, Checkbox β”‚ β”œβ”€β”€ navigation/ β†’ PageRouter, Page β”‚ └── std-library/ β†’ Standard library nodes β”‚ └── react-component-node.js # React node wrapper ``` ### noodl-core-ui (Component Library) ``` packages/noodl-core-ui/src/ β”œβ”€β”€ components/ β”‚ β”œβ”€β”€ common/ # 🧩 Basic components β”‚ β”‚ β”œβ”€β”€ Icon/ β”‚ β”‚ └── ActivityIndicator/ β”‚ β”‚ β”‚ β”œβ”€β”€ inputs/ # πŸ“ Form controls β”‚ β”‚ β”œβ”€β”€ TextInput/ β”‚ β”‚ β”œβ”€β”€ PrimaryButton/ β”‚ β”‚ └── Checkbox/ β”‚ β”‚ β”‚ β”œβ”€β”€ layout/ # πŸ“ Layout components β”‚ β”‚ β”œβ”€β”€ Box/ β”‚ β”‚ β”œβ”€β”€ Container/ β”‚ β”‚ └── Tabs/ β”‚ β”‚ β”‚ β”œβ”€β”€ popups/ # πŸ’¬ Dialogs & menus β”‚ β”‚ β”œβ”€β”€ MenuDialog/ β”‚ β”‚ └── PopupToolbar/ β”‚ β”‚ β”‚ └── ai/ # πŸ€– AI UI components β”‚ β”œβ”€β”€ AiChatBox/ β”‚ └── AiChatMessage/ β”‚ β”œβ”€β”€ preview/ # πŸ“± Preview/Launcher UI β”‚ └── launcher/ β”‚ β”œβ”€β”€ Launcher.tsx β†’ Main launcher container β”‚ β”œβ”€β”€ LauncherContext.tsx β†’ Shared state context β”‚ β”‚ β”‚ β”œβ”€β”€ components/ # Launcher-specific components β”‚ β”‚ β”œβ”€β”€ LauncherProjectCard/ β†’ Project card display β”‚ β”‚ β”œβ”€β”€ FolderTree/ β†’ Folder hierarchy UI β”‚ β”‚ β”œβ”€β”€ FolderTreeItem/ β†’ Individual folder item β”‚ β”‚ β”œβ”€β”€ TagPill/ β†’ Tag display badge β”‚ β”‚ β”œβ”€β”€ TagSelector/ β†’ Tag assignment UI β”‚ β”‚ β”œβ”€β”€ ProjectList/ β†’ List view components β”‚ β”‚ β”œβ”€β”€ GitStatusBadge/ β†’ Git status indicator β”‚ β”‚ └── ViewModeToggle/ β†’ Card/List toggle β”‚ β”‚ β”‚ β”œβ”€β”€ hooks/ # Launcher hooks β”‚ β”‚ β”œβ”€β”€ useProjectOrganization.ts β†’ Folder/tag management β”‚ β”‚ β”œβ”€β”€ useProjectList.ts β†’ Project list logic β”‚ β”‚ └── usePersistentTab.ts β†’ Tab state persistence β”‚ β”‚ β”‚ └── views/ # Launcher view pages β”‚ β”œβ”€β”€ Projects.tsx β†’ Projects tab view β”‚ └── Templates.tsx β†’ Templates tab view β”‚ └── styles/ # 🎨 Global styles └── custom-properties/ β”œβ”€β”€ colors.css β†’ Design tokens (colors) β”œβ”€β”€ fonts.css β†’ Typography tokens └── spacing.css β†’ Spacing tokens ``` #### πŸš€ Launcher/Projects Organization System (Phase 3) The Launcher includes a complete project organization system with folders and tags: **Key Components:** - **FolderTree**: Hierarchical folder display with expand/collapse - **TagPill**: Colored badge for displaying project tags (9 predefined colors) - **TagSelector**: Checkbox-based UI for assigning tags to projects - **useProjectOrganization**: Hook for folder/tag management (uses LocalStorage for Storybook compatibility) **Data Flow:** ``` ProjectOrganizationService (editor) ↓ (via LauncherContext) useProjectOrganization hook ↓ FolderTree / TagPill / TagSelector components ``` **Storage:** - Projects identified by `localPath` (stable across renames) - Folders: hierarchical structure with parent/child relationships - Tags: 9 predefined colors (#EF4444, #F97316, #EAB308, #22C55E, #06B6D4, #3B82F6, #8B5CF6, #EC4899, #6B7280) - Persisted via `ProjectOrganizationService` β†’ LocalStorage (Storybook) or electron-store (production) --- ## πŸ” Finding Things ### Search Patterns ```bash # Find a file by name find packages/ -name "*NodeGraph*" -type f # Find where a function is defined grep -rn "function processNode" packages/ # Find where something is imported/used grep -r "import.*from.*nodegraphmodel" packages/ # Find all usages of a component grep -r "; } interface Connection { fromId: string; fromPort: string; toId: string; toPort: string; } // Component structure (componentmodel.ts) interface ComponentModel { name: string; graph: NodeGraphModel; metadata: Record; } ``` --- ## πŸ“ Path Aliases ```typescript // Configured in tsconfig.json @noodl-models/ β†’ packages/noodl-editor/src/editor/src/models/ @noodl-utils/ β†’ packages/noodl-editor/src/editor/src/utils/ @noodl-contexts/ β†’ packages/noodl-editor/src/editor/src/contexts/ @noodl-hooks/ β†’ packages/noodl-editor/src/editor/src/hooks/ @noodl-constants/ β†’ packages/noodl-editor/src/editor/src/constants/ @noodl-core-ui/ β†’ packages/noodl-core-ui/src/ @noodl/platform β†’ packages/noodl-platform/src/ ``` --- ## 🚨 Common Issues ### Build Problems ```bash # Clear caches rm -rf node_modules/.cache rm -rf packages/*/node_modules/.cache # Reinstall dependencies rm -rf node_modules npm install ``` ### TypeScript Errors ```bash # Check for circular dependencies npx madge --circular packages/noodl-editor/src ``` ### Electron Issues ```bash # Clear app data (macOS) rm -rf ~/Library/Application\ Support/OpenNoodl/ # Rebuild native modules npm run rebuild ``` --- _Quick reference card for OpenNoodl development. Print or pin to your IDE!_