A small FastAPI service that validates serialised ReactFlow pipelines.
POST /pipelines/parse
Request — standard ReactFlow serialisation:
{ "nodes": [ { "id": "..." } ], "edges": [ { "id": "...", "source": "...", "target": "..." } ] }Extra ReactFlow fields (position, data, sourceHandle, animated, …) are
accepted and ignored.
Response:
{ "num_nodes": 3, "num_edges": 2, "is_dag": true }There is also a GET / health check returning { "status": "ok" }.
is_dag is computed with Kahn's topological sort (check_is_dag in
main.py) — O(V + E), no external graph library. Edges that reference a node id
not present in nodes are ignored, so a partially-loaded frontend state can't
crash the endpoint.
Using uv (a uv.lock is committed):
cd backend
uv sync # install from pyproject.toml / uv.lock
uv run uvicorn main:app --reload # http://localhost:8000Or with a plain virtualenv + pip:
cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload # http://localhost:8000Interactive API docs are available at http://localhost:8000/docs.
uv run pytest test_main.py -v # 14 testsCoverage includes empty/single-node graphs, linear chains, a diamond DAG, self-loops, 2- and 3-node cycles, disconnected components, and dangling edges.
Python ≥ 3.12. Dependencies are declared in pyproject.toml (and mirrored in
requirements.txt for the pip workflow): fastapi, uvicorn[standard],
pydantic v2, plus httpx and pytest for tests.