# Architecture — Source Implementation Guide Technical reference for the client and server modules behind the LLM Plugin sidebar. > **The design rationale — processing flow, rules, priorities and *why* they > are the way they are — lives in [docs/en/design.md](./design.md).** This document is > the "what each module does" catalog; design.md covers "why this order / rule". ## Big picture ``` Editor sidebar (vibe_ui) ──Send──► /llm-plugin/generate ──► Ollama / OpenAI / Custom ▲ │ │ ▼ addMessageToUI response { response, model, elapsed } importFlowFromMessage ◄──────────────────────────────┘ │ ├── extractFlowNodes (LLMJsonParser → Vibe Schema → FlowConverterCore.toNodeRed) ├── rebuildWorkspaceFromSnapshot (additive wires + property preservation │ + CanvasLayout positions x / y) └── applyWorkspaceDiff → remove / update-in-place / addLink-removeLink → RED.nodes.import for the ADDED nodes only (falls back to replaceWorkspaceFlow = clear + re-import, when the diff cannot express it) ``` Three independent core modules under `src/core/` form the conversion + layout backbone: | Module | Owns | Reference | |--------|------|-----------| | `flow_converter_core.js` | Vibe Schema ↔ Node-RED JSON + type detection helpers | [docs/en/vibe-schema.md](./vibe-schema.md) | | `canvas_layout.js` | Topological layout, width-aware spacing, comment placement, group boxes, collision settling | [docs/en/layout.md](./layout.md) | | `llm_json_parser.js` | JSON repair, fuzzy alias matching, schema extraction | (inline JSDoc) | Everything else is plugin-specific glue — see the file map below, then the module reference for each file. ## File map ``` llm_plugin.js Node-RED plugin entry point — loads server.js llm_plugin.html Sidebar + settings HTML templates, marked.js and DOMPurify includes llm-plugin_styles.css All plugin CSS docs/ All developer docs (this folder) — en/ + jp/ src/ client.js Script loader (browser entry) + settings dialog controller common.js Shared helpers (escapeHtml, notice, el, randomId, …) prompt_system.txt System prompt for Agent: the Vibe Schema rules prompt_ask.txt System prompt for Ask: read the flow, explain it core/ canvas_layout.js Layout engine (UMD) flow_converter_core.js Vibe Schema converter (UMD) llm_json_parser.js LLM JSON parsing (UMD) chat_manager.js Chat session CRUD + checkpoint persistence importer.js Extract LLM output, rebuild & import into editor ui_core.js Message rendering, flow export vibe_ui.js Sidebar build + generation workflow llm_core.js Shared LLM engine (settings/creds/providers/prompts) server.js HTTP endpoints + chat/checkpoint persistence node/ The `llm-request` node (palette category: llm-plugin) llm-request/ msg.payload in, the model's reply out ``` ## Loading sequence (client) `llm_plugin.html` includes `