# How the SDK works

**Preview 0.45** Available · Preview 0.45. The API can change before 1.0: see [Release phases](/docs/resources/release-phases/).

The SDK runs the capture for you: the protocol, the steps, the batches, the baseline and the results of the session. You build the screens and decide what each step means.

## Two halves

The SDK is **two npm packages**, one per side of the wire:

- **In the browser, `@neurologyca/capture`**: the live client (`createProtocolClient`) and, from `@neurologyca/capture/record`, the recording client (`createRecordingClient`).
- **In your backend, `@neurologyca/capture-server`**: the proxy that adds the token (`createEngineProxy`), `createEngineAdmin` for people, enrolments and results, and, for deferred, the upload receiver (`createUploadReceiver`).

Browser (@neurologyca/capture) → Your backend (@neurologyca/capture-server: proxy + token + admin + receiver) → Engine

The token lives only in your backend.

## Two modes

- **On-device (real time)**: processed in the browser as you capture; for short captures, results arrive during the session and seconds after the last batch, while long captures take minutes to close. Video and audio never leave the device; landmarks and expression data go to Engine, plus the transcript and extra signals only if you turn them on. Limited by the device: the face detection on the GPU (WebGL 2) and, on phones, heat in long sessions.
- **Deferred (server-side)**: the SDK records the video and a step manifest and uploads them; our processing service handles them shortly after. It is not hours later: it just doesn't run on the device. Today you can record, upload and process with Neurologyca's processing service: nothing to deploy.

Which one, and how to combine the SDK with the HTTP API: [Integration paths](/docs/start/paths/).

## No token in the browser

Your page talks to your backend, and your backend's proxy adds the token. Create the client with your proxy's path and no `getToken`:

```js
import { createProtocolClient } from '@neurologyca/capture'

const client = createProtocolClient({ baseUrl: '/engine', taxonomy }) // your proxy: no key, no token in the page
```

## What you decide

The screens and their texts; consent before `captureProtocol`, and only from a gesture of the person; who closes each step and what a step without text says; who your users are and which ids each one can touch (`authorize` with `ownsAll`). The SDK and `capture-server` do the Engine routes, the token, the batches, the retries and the reservation. The full table is in [Integration paths](/docs/start/paths/#what-you-decide-and-what-the-sdk-does).

## The pages of this group

- [On-device (real time)](/docs/sdk/on-device/): the live client, step by step.
- [Deferred (server-side)](/docs/sdk/deferred/): recording and uploading.
- [Steps and marking](/docs/sdk/steps/): who closes a step, the clock and the manifest.
- [Results in your backend](/docs/sdk/results-backend/): reading results later, SSE or polling, and the webhook.
- [Your backend](/docs/sdk/backend/): the proxy, `createEngineAdmin` and the receiver.
- [Processing service](/docs/sdk/processing/): what our service does and what you expose.
- [Errors, warnings and retries](/docs/sdk/errors/): every code, by layer, and support.
- [SDK reference](/docs/sdk/reference/): every export, with its signature.
