# Install

> Build the desktop app or the browser version from source, or run either on the built-in simulator.

Flowscope is built from source. The repository has one `Makefile` with every task; `make help` lists them.

## Requirements

| Tool | Why | How to get it |
|---|---|---|
| rustup | Installs the pinned toolchain | [rustup.rs](https://rustup.rs) |
| Rust 1.98.0 with `clippy`, `rustfmt` and the `wasm32-unknown-unknown` target | Pinned in `rust-toolchain.toml` | Installed automatically by rustup on the first `cargo` command in the repository |
| `wasm-bindgen-cli` | Browser build only | `cargo install wasm-bindgen-cli --version <version> --locked`, with the version from `Cargo.lock` |
| `wasm-opt` (binaryen) | Browser build only, optional | Used for release builds when it is on your `PATH` |
| Python 3 | `make serve` only | Serves the built files with `python3 -m http.server` |

> [!IMPORTANT]
> The `wasm-bindgen-cli` version must match the `wasm-bindgen` crate in `Cargo.lock` exactly. Look it up with `grep -A1 'name = "wasm-bindgen"' Cargo.lock`.

## Desktop

Run the app on live data:

```bash
make hub            # a local data hub on port 8790 (another terminal)
make desktop        # debug build, every market from the hub at HUB_URL
```

`make desktop` reads the hub at `HUB_URL`, by default `http://127.0.0.1:8790`, the one `make hub` starts. The app takes every market and its history from a data hub; without one it has no market data. See [History and data](/docs/app/history-and-data#hub).

For daily use, build the optimized binary:

```bash
make release        # writes target/release/flowscope
./target/release/flowscope
```

The desktop window opens at 1680 × 1000 points and can shrink to 960 × 600. It renders with wgpu.

On the first start Flowscope opens the **Orderflow desk** preset. After that it restores the layout you used last. See [Layouts](/docs/app/layouts).

### What the desktop keeps on disk

The desktop keeps no market data: every chart's history comes from the data hub again each session. It keeps your layouts and preferences in your data directory under `flowscope/store/`, and its log under `flowscope/logs/`. Details are in [History and data](/docs/app/history-and-data#local-persistence).

## Browser

The browser version is the same terminal compiled to WebAssembly.

```bash
make web            # release build into web/dist
make web-dev        # faster, unoptimized build into web/dist
make serve          # build, then serve web/dist on http://localhost:8080
```

`make serve` takes a port: `make serve PORT=9000`. A plain static server has no `/hub`: add `?hub=<url>` for a hub elsewhere; without a hub the app has no market data. `make dev` serves the build through the website, with a hub behind `/hub`.

The build script compiles `flowscope-web` for `wasm32-unknown-unknown`, runs `wasm-bindgen --target web`, runs `wasm-opt -O3` on release builds when available, and copies `web/index.html` next to the output. The page draws into a `<canvas id="flowscope">`.

To host the build elsewhere, serve the contents of `web/dist` as static files.

> [!NOTE]
> The uncompressed bundle is about 13 MB, fonts included. `wasm-opt` and HTTP compression bring it down considerably.

### Differences from the desktop

| | Desktop | Browser |
|---|---|---|
| Engine threads | One worker per core minus one | None; the engine runs up to 8 ms per frame |
| Memory budget for markets | 3 GB | 768 MB |
| Layouts and preferences | `flowscope/store/` in the data directory | `localStorage` |
| Data hub | `FLOWSCOPE_HUB_URL` | The website's `/hub`, or `?hub=<url>` |
| Fullscreen shortcut <kbd>F11</kbd> | Yes | Use the browser's own |
| Snapshots | Clipboard and a PNG file | Clipboard |

## Simulator

Flowscope has a built-in synthetic exchange: random-walk prices, a deep book that churns and a steady tape, roughly like a busy BTC perpetual (150 trades and 10 book updates of 60 levels per second, 1 000 levels deep). Use it to try the interface offline or to measure performance.

```bash
make desktop-sim    # desktop on the simulator (sets FLOWSCOPE_SIM=1)
make serve-sim      # browser build; open http://localhost:8080/?sim
```

In the browser, any query string that contains `sim` starts the simulator. The bottom bar shows a **Simulator** status dot while it runs.

## Release builds

Two tasks package Flowscope for others:

| Task | Result |
|---|---|
| `make dist` | A Linux tarball in `dist/`: `flowscope-<version>-<arch>-linux.tar.gz` with the binary, the app icon, a desktop entry, the README and the licences, plus a `.sha256` file. macOS and Windows builds are made on those systems; nothing cross-compiles. |
| `make web-dist` | A deployable static folder in `web/dist`: the optimised WebAssembly build with hashed, precompressed files, ready for any static host or CDN. |

```bash
make dist
tar xzf dist/flowscope-*-linux.tar.gz -C ~/opt
```

## Check a build

```bash
make check          # formatting, clippy (native and wasm), all tests
make probe          # connect to every venue headless and print what arrives
```

`make probe` is a quick way to confirm that your network reaches every venue before you open the app.

## Next steps

```cards
[The workspace](/docs/app/workspace) Find your way around the window.
[Settings](/docs/app/settings) Environment variables such as presets and the performance overlay.
[Recorder quickstart](/docs/recorder/quickstart) Record history around the clock and serve it through a data hub.
```
