Guidance for Claude Code (and other AI assistants) working in this repository.
Kratos FlowGraph is a browser-based, node-graph editor for configuring
KratosMultiphysics simulations. Users wire nodes
(analysis stages, solvers, materials, processes, model parts, outputs) on a canvas, and FlowGraph
generates the Kratos ProjectParameters.json (and material files).
It is not a bundled SPA. It is:
- a small Express + EJS server (
app.js) that serves a single canvas page and optionally launches Kratos, plus - a large library of plain-ESM litegraph.js node
modules served statically from
public/js/nodes/.
There is no build step for the application itself. The published NPM package is
kratos-flowgraph, exposed as a runnable CLI.
npm install
npm start # node app.js — serves the editor on http://localhost:8182
npm run devstart # nodemon app.js — auto-reload during development- Port and Kratos paths come from
config/default.json(via theconfigpackage). Switch config files withNODE_ENV(e.g.NODE_ENV=debug→config/debug.json). - The CLI entry point is
bin/kratos-flowgraph.js; itchdirs to the package root (so CWD-relative lookups insrc/module_importer.jsandconfigwork) and then importsapp.js. - The editor UI needs no Kratos install;
kratos_root/working_dir/python_binaryare only used by the optional/run_simulationroute.
| Path | Role |
|---|---|
app.js |
Express server: serves public/, renders views/index.ejs, routes /upload_json, /run_simulation. |
bin/kratos-flowgraph.js |
CLI launcher (chdir to package root, then run app). |
src/module_importer.js |
Auto-discovers node/widget files under public/js/nodes & public/js/widgets. |
views/index.ejs |
The entire UI: toolbar, <canvas class="graphcanvas">, JSON side panel. |
public/js/code.js |
Bootstraps the litegraph editor; wires the toolbar; exposes window.graph/window.graphcanvas. |
public/js/side.js |
Side panel toggle (openNav), addViewerNode, experimental LLM hook. |
public/js/litegraph/litegraph.core.js |
Vendored litegraph engine. |
public/js/extensions/*.js |
Core customisations: extended_menu (categorized add-node menu), draw_node/draw_widget, compute_size, remove_node/remove_widget, custom_node_panel, selection_import, load_project_parameters (import ProjectParameters → graph). |
public/js/nodes/** |
The node library, organized by Kratos domain (see the docs Node Reference). |
public/js/model_manager.js, problem_manager.js |
Track model parts / global problem state across connections. |
config/default.json |
Runtime config (host, port, kratos_root, working_dir, python_binary). |
doc/ |
VitePress documentation (see below). |
scripts/screenshots/capture.spec.js |
Playwright screenshot capture for the docs. |
Drop a .js file under public/js/nodes/<category>/ that defines a class and calls
LiteGraph.registerNodeType("Category/Sub/Name", Class). It is auto-discovered — no manifest to
edit. The registered type path drives the context-menu category. Reuse existing slot types so the
node connects to the rest of the library. See doc/development/adding-a-node.md for a template.
The docs live in doc/ (VitePress) with screenshots under doc/public/screenshots/.
npm run docs:dev # local docs dev server
npm run docs:build # build static docs into doc/.vitepress/dist
npm run docs:screenshots # Playwright: boot the app, capture UI screenshots (needs `npx playwright install chromium` once)- NPM: bump
versioninpackage.json, push, then create a GitHub Release. The.github/workflows/publish.ymlworkflow publisheskratos-flowgraphusing theNPM_TOKENsecret. Verify the tarball withnpm pack --dry-run. - Docs: pushing to
mastertriggers.github/workflows/docs.yml, which builds and deploys the VitePress site to GitHub Pages (requires Pages source = "GitHub Actions", one-time).
Whenever a new feature, node, or user-facing change is added, you MUST update
CLAUDE.md,README.md, and thedoc/VitePress documentation in the same change. If the change alters the UI, regenerate the Playwright screenshots withnpm run docs:screenshots. A feature is NOT complete until these are updated.
Concretely, when you change behaviour:
- Update
CLAUDE.mdif the architecture, commands or workflow changed. - Update
README.mdif the quick-start, features or install steps changed. - Update the relevant page(s) under
doc/(guide, node reference, or development). - Re-run
npm run docs:screenshotsif the UI changed, and commit the updated images.
- Node names, slot types and emitted JSON should match the Kratos schema for the concept modelled.
- Runtime dependencies (
express,cors,ejs,config) live underdependencies— do not move them back todevDependencies, or the published CLI will not run. package-lock.jsonis gitignored; there is no committed lockfile.- Prefer extending existing base classes (
Material,AnalysisStage,Process, …) for new nodes.