> ## Documentation Index
> Fetch the complete documentation index at: https://desme.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get from zero to your first dbgflow session in a few minutes.

**1. Install the library and CLI**

Add the `dbgflow` crate to your project and install the CLI tool:

```bash theme={null}
cargo add dbgflow
cargo install dbgflow
```

> [!NOTE]
>
> dbgflow requires Rust 1.85 or later. Run `rustup update stable` if you are on an older toolchain.

**2. Run the built-in demo**

Before touching your own code, run the demo to confirm the toolchain is working and to see what the UI looks like:

```bash theme={null}
dbgflow demo --serve
```

This generates a sample session at `artifacts/demo-session.json` and opens the browser UI at `http://127.0.0.1:3000`.

You will see two pipelines in the graph — one with a simulated test failure and one with a passing test. Use the playback controls at the bottom of the screen to step through execution events.

> [!TIP]
>
> You can pass `--port 8080` (or any other port) if 3000 is already in use.

**3. Instrument your code**

Import the prelude, mark the types you want to inspect with `#[ui_debug]`, and mark the functions you want to trace with `#[trace]`:

```rust theme={null}
use dbgflow::prelude::*;

#[ui_debug]
struct State {
    counter: usize,
}

#[trace]
fn step(state: &mut State) {
    state.counter += 1;
    state.emit_snapshot("after step");
}
```

* `#[ui_debug]` registers the type as a data node in the graph and makes `emit_snapshot` available on it. Call `emit_snapshot` at any point to capture the current field values.
* `#[trace]` marks a function as a graph node. Every call is recorded as a pair of `function_enter` / `function_exit` events.

To link a test to the graph, annotate it with `#[dbg_test]`:

```rust theme={null}
#[cfg(test)]
mod tests {
    use super::*;

    #[dbg_test]
    fn state_flow() {
        let mut state = State { counter: 0 };
        step(&mut state);
        assert_eq!(state.counter, 2); // intentional failure
    }
}
```

> [!WARNING]
>
> `#[dbg_test]` does not support async tests. Use it only on synchronous test functions.

**4. Run tests with session capture**

Use `dbgflow test` instead of `cargo test` to capture execution sessions while your tests run:

```bash theme={null}
dbgflow test --serve
```

To target a specific project or pass extra arguments to `cargo test`:

```bash theme={null}
dbgflow test --manifest-path /path/to/project/Cargo.toml --serve -- --lib
```

Sessions are saved to `artifacts/test-sessions/run-<timestamp>/` by default — one JSON file per `#[dbg_test]` function.

> [!NOTE]
>
> `dbgflow test` always sets `RUST_TEST_THREADS=1` so that session capture stays deterministic. If your tests rely on parallel execution, be aware of this constraint.

**5. Explore the browser UI**

When the `--serve` flag is present, the browser opens automatically after tests complete, focused on the first failing test session.

Here is what you will find in the UI:

**Graph canvas** — Each `#[trace]` function appears as a function node (marked `fn`), each `#[ui_debug]` type as a data node (marked `db`), and each `#[dbg_test]` test as a test node (marked `t`). Edges show call relationships and test-to-function links. Node colors indicate status: gray for idle, orange for running, green for success, and red for failure.

**Left panel** — Click any node to open the detail panel. It shows the node type, execution status, the function's source code with Rust syntax highlighting, captured input arguments, and all snapshots emitted during the call. Drag the panel edge to resize it.

**Playback controls** — The bar at the bottom lets you play, pause, step forward and backward, scrub the timeline, switch between pipelines, jump to a specific event by number, and adjust playback speed from 0.25x to 4x.

**Canvas navigation** — Scroll to zoom. Use the canvas mode toggle to switch between panning the viewport and dragging individual nodes to reposition them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.