# Visual Programming Framework A browser-based flowchart-to-C code generator with typed measurement system, procedure libraries, and live MathJax-rendered expressions. ## Architecture The app is built as vanilla HTML/CSS/JS with no framework. All state lives in the DOM (custom elements) and is serialised to localStorage. ### File dependency order (bottom to top) ``` index.html ← entry point, templates, page layout │ dom.js ← $, $id, svgNamespace, STORAGE_KEY (global constants) helpers.js ← data-source lookups, string escaping, dropdown refresh error.js ← modal error overlay draw.js ← SVG path routing, link interaction, path deletion │ wcblock.js ← WCBlock base class (drag/drop, link system) blocks-algo.js ← Algorithm tab blocks (WCStart, WCEnd, WCOutput, WCDecision, │ WCAssign, WCExpression, WCVarRef) blocks-data.js ← Data & Measurement tab blocks (WCQuantity, WCUnit, WCBoolean, │ WCScalar, WCString, WCArray) blocks-proc.js ← Procedure blocks (WCProcedure, WCProcCall) wcprogram.js ← WCProgram + block registry + registration calls │ persist.js ← localStorage save/load/new app.js ← bootstraps the workspace, creates defaults, wires UI ``` ### Module overview | File | Lines | Exports | Purpose | |------|-------|---------|---------| | `dom.js` | 23 | `$`, `$id`, `svgNamespace`, `STORAGE_KEY` | Query shortcuts and app-wide constants | | `helpers.js` | ~240 | 12 functions | Data-source lookup, string escaping, dropdown refresh utilities | | `error.js` | 32 | `showError`, `closeError` | Error overlay modal | | `draw.js` | 208 | 6 functions | SVG path routing, shadow link, link creation/deletion | | `wcblock.js` | ~236 | `WCBlock` | Base class: drag/drop, link system, code traversal | | `blocks-algo.js` | ~460 | 7 classes | Algorithm tab blocks (start, end, output, decision, assign, expression, varref) | | `blocks-data.js` | ~570 | 6 classes | Data & Measurement tab blocks (quantity, unit, boolean, scalar, string, array) | | `blocks-proc.js` | ~280 | 2 classes | Procedure blocks (definition, call) | | `wcprogram.js` | ~370 | `WCProgram` + registry | Root container, ID counter, node factory, code generation, block registration | | `persist.js` | ~245 | `saveWorkspace`, `loadWorkspace`, `newWorkspace`, helpers | localStorage serialisation | | `app.js` | ~390 | 7 functions + `main()` | Application bootstrap, OpenGL defaults, event wiring | | `style.css` | ~480 | — | All styles | | `index.html` | ~380 | — | Page layout + `