# Setup and Run

## Prerequisites

- Java 17 (JDK)
- Maven 3.9+
- MQTT broker reachable at `localhost:1883` (or custom broker in config)
- Windows for bundled PowerShell/BAT process scripts

Optional:

- Python (for automatic MQTT simulator startup)
- Unreal + Pixel Streaming setup (for avatar integration)

## Recommended Startup Modes

### Mode A: Minimal local run (recommended first)

Use this mode to run only the Java application and MQTT pipeline.

In `src/main/resources/config/application.properties`:

```properties
mqtt_sim.enabled=false
unreal.enabled=false
```

### Mode B: Full integration run

Enable simulator and/or Unreal startup only after all referenced paths are valid on your machine.

## Build

```powershell
mvn clean compile
```

## Run from CLI

```powershell
mvn org.codehaus.mojo:exec-maven-plugin:3.5.0:java -Dexec.mainClass=vassistent.App
```

## Run from IDE

Start class:

- `vassistent.App`

## Send Test Messages

Publish payloads to configured topic (default: `PREDICTION`) in this format:

```json
{
  "valid": true,
  "_id": 1,
  "prediction": 0
}
```

Validation rules:

- `valid` must be `true`
- `_id` must exist
- `prediction` must be `0` or `1`

## Startup Validation Notes

The app validates configuration at startup (`AppConfigValidator`):

- if simulator is enabled, Python executable/script and simulator settings are validated;
- if Unreal integration is enabled, script/executable paths and related directories are validated;
- invalid configuration throws an `IllegalStateException` before UI startup.

## Shutdown Behavior

On shutdown, the app:

1. disconnects MQTT,
2. stops managed external processes,
3. deletes `data/health.db` (current behavior),
4. flushes and closes the logger.
