routeflow
Real-time execution flow visualization for FastAPI applications.
FastAPI documents the contract of an API — routes, params, response shapes — but says nothing about what actually happens when a request runs. As soon as an app grows past a few endpoints, execution logic spreads across services, middleware, dependencies, and background tasks, and debugging means mentally reconstructing a flow that should have been visible in the first place.
routeflow makes that flow visible: mark a function with @track, and
every request that calls it gets traced — order, timing, logs, and errors —
and rendered live as an interactive node graph in a tab next to your
Swagger docs.
Status: functional for local development — the tracer, middleware, in-memory store, and flow-view UI all work end to end. Not yet published to PyPI; install from source for now (see below).
Quickstart
pip install routeflow
from fastapi import FastAPI
from routeflow import RouteFlow
from routeflow.tracing import track
app = FastAPI()
RouteFlow(app)
@track
def charge_card(amount: int) -> None:
... # call out to whatever actually charges the card
@app.post("/orders")
def create_order(amount: int):
charge_card(amount)
return {"amount": amount, "status": "ok"}
Run it (uvicorn myapp:app), hit POST /orders, then open:
http://127.0.0.1:8000/__routeflow__/app/
That's the flow view — pick an endpoint in the sidebar, pick a trace, and you'll see the request's actual call tree: which functions ran, in what order, how long each took, and — if something raised — exactly where.
What @track gives you
- Nested spans, for free. Call another
@track-decorated function from inside one, and the call tree builds itself viacontextvars— no manual parent/child wiring. - Sync and async. Works on both
defandasync defthe same way. - Arguments, captured and redactable. Call args are recorded on the
span by name; pass
redact=to mask specific ones (a password, a token) orcapture_args=Falseto skip a function entirely. - Errors, observed not altered. An exception is recorded on the span and then always re-raised unchanged — RouteFlow never changes what your code does, only what you can see about it.
The flow view
- Sidebar lists every endpoint that's been hit, with request count, p95 latency, and error rate.
- Pick an endpoint to see its recent traces; pick a trace to see its node graph — timing and status on every node, an error highlighted exactly where it happened.
- Updates live over a WebSocket as new requests come in — no refresh needed.
- Sits in its own tab next to your existing Swagger
/docs, light/dark themed.
Turning it off
RouteFlow is on by default — it's a dev tool, and "add one line, it just works" is the point. But traces can include captured arguments and full stack traces, so it must never ship to production silently:
ROUTEFLOW_ENABLED=0
set in the environment disables it completely — no middleware installed, no
route mounted, your app handed back untouched. RouteFlow(app, enabled=False)
does the same from code, e.g. enabled=settings.debug.
Try it
examples/demo_app.py is a small shop app with a
nested call tree and one request that fails on purpose, so there's
something worth looking at the first time you open the flow view:
uv run --with fastapi --with uvicorn python examples/demo_app.py
How it works
See ARCHITECTURE.md for the mechanism: the
contextvars-based span model, the ASGI middleware that opens/closes a
trace per request, the in-memory ring buffer, and the mounted REST/WebSocket
server the flow view reads from.
Development
This project uses uv for dependency management.
uv sync --extra dev # install package + dev deps into .venv
uv run pytest -q # run tests
uv run routeflow about # run the CLI
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file routeflow-0.2.0.tar.gz.
File metadata
- Download URL: routeflow-0.2.0.tar.gz
- Upload date:
- Size: 65.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36cd86ef4dd833bb0d7478fbf2cd776814e2cc5d275773a7bb0e2f07659088a2
|
|
| MD5 |
6f04964c729071329f6951b64b76bbfb
|
|
| BLAKE2b-256 |
bbd9e9c15d7296476c59eeee9b1fec57e6a3ef1298965e32e8d14ec7102aba75
|
File details
Details for the file routeflow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: routeflow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 33.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afa5e01553ab348d6bd084dc4780475330136516cb9d0c8c54412fdac4cb4c35
|
|
| MD5 |
7ac59173944b615e4a3781f9e0b76957
|
|
| BLAKE2b-256 |
9e752f527abe3f63ecd73338244acca6496c0205d68b657165f766afca9635eb
|