# Building from Source

## Prerequisites

| Tool              | Version                    | Notes                              |
| ----------------- | -------------------------- | ---------------------------------- |
| **Visual Studio** | 2022 (Community or higher) | C++17 workload required            |
| **Windows SDK**   | 10.0.22621+                | Included with VS 2022              |
| **Node.js**       | 18 LTS or newer            | For effects server + frontend      |
| **npm**           | 9+                         | Bundled with Node.js               |
| **Inno Setup**    | 6.x                        | Only needed to build the installer |

### External SDKs (C++ Engine)

The following SDKs must be obtained separately and placed in the correct paths before building:

| SDK        | Path                                  | Notes                           |
| ---------- | ------------------------------------- | ------------------------------- |
| GLEW       | `exaplay_backend/mgx-dep/glew/`       | OpenGL extension wrangler       |
| GLM        | `exaplay_backend/mgx-dep/glm/`        | Math library                    |
| FFMPEG     | `exaplay_backend/mgx-dep/ffmpeg/`     | Audio/video demuxer             |
| PortAudio  | `exaplay_backend/mgx-dep/portaudio/`  | Cross-platform audio I/O        |
| WebView2   | `exaplay_backend/exa-dep/webview2/`   | Chromium-based web UI embedding |
| Medialooks | `exaplay_backend/exa-dep/medialooks/` | H.264 / ProRes decoder          |
| VIOSO SDK  | `exaplay_backend/exa-dep/vioso/`      | Warp/blend calibration          |
| QLM SDK    | `exaplay_backend/exa-dep/qlm/`        | Soraco licensing                |

***

## Building the C++ Engine

```cmd
cd exaplay_backend
```

1. Open `exaplay3.sln` in Visual Studio 2022.
2. Set the build configuration to **Release | x64**.
3. Build → **Build Solution** (`Ctrl+Shift+B`).

The output binary is placed in `exaplay_backend/x64/Release/exaplay3.exe`.

***

## Building the Frontend

```bash
cd exaplay_frontend
npm install
npm run build          # Output to ./html/
```

For production bundles used by the installer:

```bash
npm run build:win      # Build + copy service files + create ZIP
```

The built HTML/JS/CSS is placed in `exaplay_frontend/html/` and then deployed to `output/html/`.

***

## Running the Effects Server

```bash
cd exaplay_backend
npm install
node server.js         # Starts on port 3001
```

For development with auto-restart:

```bash
npx nodemon server.js
```

***

## Running Tests

### Effects Server (Jest)

```bash
cd exaplay_backend
npm test
```

All tests are in `__tests__/`. The test suite uses **Supertest** to test the Express API directly without a running server.

***

## Building the Installer

1. Ensure the frontend has been built (`npm run build:win`).
2. Ensure the C++ engine binary is in `output/`.
3. Open `exaplay_installer/Exaplay3_Installer.iss` in **Inno Setup 6**.
4. Press **F9** (Build) to compile the installer.

The resulting `Exaplay3_Setup.exe` is saved to the output directory configured in the `.iss` file.

***

## Development Tips

* The frontend dev server (`npm run dev`) proxies API calls to `localhost:8123` — you must have the C++ engine running.
* The effects server (`server.js`) can run independently; the frontend degrades gracefully when it is absent.
* Use `-log` flag on the engine for verbose output to `Documents\Exaplay3\logs\`.
* ESLint + Prettier are configured for the frontend: `npm run lint` in `exaplay_frontend/`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.exaplay.one/v3/developer-reference/building.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
