Image Pipeline Playground
docs(architecture): add node registration guide for developers
Mohammad Rajaei71329a0d21f9
diff --git a/docs/architecture.md b/docs/architecture.mdnew file mode 100644index 0000000..483605e--- /dev/null+++ b/docs/architecture.md@@ -0,0 +1,59 @@+# Architecture & node registration++## Layers++```text+React Flow UI --REST/WS--> FastAPI+ ├─ Node Registry+ ├─ DAG Executor + Cache+ ├─ OpenCV node implementations+ └─ Python code generator+```++- Graphs are validated, topologically sorted, and executed node-by-node.+- Cache keys are content-addressed from `(node_type, params, input hashes, seed)`.+- Stochastic nodes re-run per sample with `seed + sample_index`.+- Codegen walks the same topo order and emits each node's `emit_python()` lines.++## Registering a new node++Create a module under `backend/app/nodes/`:++```python+from typing import Any+import cv2+import numpy as np+from app.engine.registry import BaseNode+from app.nodes.common import image_in, image_out, int_param, require_image++class BoxFilterNode(BaseNode):+ type = "box_filter"+ label = "Box Filter"+ category = "filters"+ description = "Normalized box filter."+ ports = [image_in(), image_out()]+ params = [int_param("ksize", "Kernel Size", 3, minimum=1, maximum=31)]++ def execute(self, inputs, params, seed: int = 0):+ image = require_image(inputs)+ k = int(params["ksize"])+ return {"image": cv2.boxFilter(image, -1, (k, k))}++ def emit_python(self, node_id, params, input_vars, output_vars):+ k = int(params["ksize"])+ return [+ f"{output_vars['image']} = cv2.boxFilter("+ f"{input_vars['image']}, -1, ({k}, {k}))"+ ]+```++Then register it in `backend/app/nodes/__init__.py`:++```python+from app.nodes.filters import BoxFilterNode # or your module++# inside register_builtin_nodes():+registry.register(BoxFilterNode())+```++The palette, inspector, executor, and codegen all discover the node through the registry metadata—no React changes required unless you need custom widgets.