# Where Is the Main Entry Point of the Brush Application Located?

> Locate the main entry point of the Brush application at apps/brush-app/src/bin.rs. Discover how the fn main function initializes the CLI, processing pipeline, and application modes.

- Repository: [Arthur Brussee/brush](https://github.com/ArthurBrussee/brush)
- Tags: api-reference
- Published: 2026-05-14

---

**The main entry point of the Brush application is located in [`apps/brush-app/src/bin.rs`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/src/bin.rs), where the `fn main()` function initializes the CLI parser, sets up the processing pipeline, and launches either the GUI viewer or headless mode.**

The Brush application is a Rust-based 3D Gaussian splatting tool developed in the ArthurBrussee/brush repository. Understanding the main entry point of the Brush application is essential for developers contributing to the codebase or customizing the training pipeline. The executable logic resides in the `brush-app` crate, which orchestrates platform detection, argument parsing, and the async runtime that drives both desktop and command-line interfaces.

## Binary Declaration in the Cargo Manifest

The `brush` binary is declared in [`apps/brush-app/Cargo.toml`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/Cargo.toml) at lines 14-18. This configuration defines the binary name and maps it to the source file containing the entry point.

According to the repository source, the manifest specifies:

```toml
[[bin]]
name = "brush"
path = "src/bin.rs"

```

This declaration tells Cargo to compile [`src/bin.rs`](https://github.com/ArthurBrussee/brush/blob/main/src/bin.rs) as the executable named `brush` when running `cargo run` or `cargo build`.

## The Main Function Implementation

The actual **entry point** resides in [`apps/brush-app/src/bin.rs`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/src/bin.rs) within the `fn main()` function. This function is wrapped in a platform-specific guard to exclude it from WebAssembly builds:

```rust
#[cfg(not(target_family = "wasm"))]
fn main() -> Result<(), anyhow::Error> {
    // Entry point implementation
}

```

The function returns an `anyhow::Result` to enable ergonomic error handling throughout the initialization phase. When compiled for native targets (desktop operating systems), this function becomes the program's starting point.

## Entry Point Execution Flow

The `main` function in [`apps/brush-app/src/bin.rs`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/src/bin.rs) executes a specific initialization sequence before handing control to the user interface or training loop.

### CLI Argument Parsing

First, the entry point parses command-line arguments using the `brush-cli` crate:

```rust
let args = brush_cli::Cli::parse().validate()?;

```

This validates inputs such as dataset paths, training parameters, and viewer preferences before any heavy computation begins.

### Processing Pipeline Initialization

Next, the function initializes the **processing pipeline** by optionally creating a process handle based on the input source:

```rust
let init_process = args.source.map(|src| {
    brush_process::create_process(src, /* configuration parameters */)
});

```

The `brush_process::create_process` function, implemented in [`crates/brush-process/src/lib.rs`](https://github.com/ArthurBrussee/brush/blob/main/crates/brush-process/src/lib.rs), prepares the dataset and training context.

### UI vs. CLI Mode Selection

Finally, the entry point branches based on the `--with-viewer` flag:

**GUI Mode** – Launches an egui-based 3D viewer via `eframe::run_native`:

```rust
if args.with_viewer {
    eframe::run_native("Brush", native_opts, Box::new(|cc| {
        Ok(Box::new(App::new(cc, init_process)))
    }))?;
}

```

**Headless Mode** – Runs the training pipeline without graphical interface:

```rust
else {
    brush_process::burn_init_setup().await;
    let process = init_process.expect("Must provide a source");
    brush_cli::run_cli_ui(process, args.train_stream).await?;
}

```

The async runtime handles both paths, ensuring the `bvar` computation graph initializes correctly before training begins.

## Key Source Files Supporting the Entry Point

Several crates collaborate to provide the functionality invoked by the main entry point:

- **[`apps/brush-app/Cargo.toml`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/Cargo.toml)** – Declares the binary metadata and dependencies required for the desktop executable.
- **[`apps/brush-app/src/bin.rs`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/src/bin.rs)** – Contains the `fn main()` entry point and platform guards.
- **[`apps/brush-cli/src/lib.rs`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-cli/src/lib.rs)** (from the `brush-cli` crate) – Implements `brush_cli::Cli` for argument parsing and validation.
- **[`crates/brush-process/src/lib.rs`](https://github.com/ArthurBrussee/brush/blob/main/crates/brush-process/src/lib.rs)** – Provides `brush_process::create_process()` and `burn_init_setup()` for pipeline initialization.
- **[`crates/brush-render/src/lib.rs`](https://github.com/ArthurBrussee/brush/blob/main/crates/brush-render/src/lib.rs)** – Handles 3D rendering when the UI path is selected via `eframe`.

## Summary

- The **main entry point** of the Brush application is the `fn main()` function in [`apps/brush-app/src/bin.rs`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/src/bin.rs).
- The binary is declared in [`apps/brush-app/Cargo.toml`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/Cargo.toml) with the name `brush` pointing to [`src/bin.rs`](https://github.com/ArthurBrussee/brush/blob/main/src/bin.rs).
- The entry point uses `#[cfg(not(target_family = "wasm"))]` to exclude desktop-specific code from WASM builds.
- Execution flow includes CLI parsing (`brush_cli::Cli::parse()`), pipeline setup (`brush_process::create_process()`), and conditional UI launching (`eframe::run_native` vs headless CLI mode).

## Frequently Asked Questions

### What binary name should I use to run the Brush application from the command line?

The binary is named `brush` as defined in [`apps/brush-app/Cargo.toml`](https://github.com/ArthurBrussee/brush/blob/main/apps/brush-app/Cargo.toml). After building with `cargo build --release`, the executable appears as `./target/release/brush` (or `brush.exe` on Windows).

### Why does the main function have a `#[cfg(not(target_family = "wasm"))]` attribute?

This **platform guard** ensures the desktop entry point compiles only for native operating systems. The Brush application supports WebAssembly builds for web deployment, which use a different entry point mechanism, so this attribute prevents compilation errors when targeting `wasm32-unknown-unknown`.

### How does the application decide between GUI and CLI mode?

The `main` function checks the `args.with_viewer` boolean flag parsed from the command line. If `true`, it calls `eframe::run_native` to launch the egui-based 3D viewer. If `false`, it executes `brush_cli::run_cli_ui` to run the training process headlessly without graphical rendering.

### Where is the command-line argument parsing logic defined?

The CLI structure and parsing logic are implemented in the `brush-cli` crate, located in `apps/brush-cli/`. The entry point invokes `brush_cli::Cli::parse()` to deserialize arguments and `validate()` to ensure required parameters are present before starting the processing pipeline.