# Server

The mstransfer server is a FastAPI application. Run it with [`mstransfer serve`](<https://chrisagrams.github.io/mstransfer/cli/index.md#mstransfer-serve>), or build it in Python and serve it however you like.

- [HTTP API](<https://chrisagrams.github.io/mstransfer/server/http-api/index.md>): endpoints, headers, and transfer states
- [Embedding in FastAPI](<https://chrisagrams.github.io/mstransfer/server/embedding/index.md>): `create_app` and `make_router`
- [Authentication](<https://chrisagrams.github.io/mstransfer/server/auth/index.md>): API keys and custom auth providers
- [File providers](<https://chrisagrams.github.io/mstransfer/server/file-providers/index.md>): control what `/v1/files` lists and serves
- [Deployment](<https://chrisagrams.github.io/mstransfer/server/deployment/index.md>): Docker and running behind a reverse proxy

## Transfer lifecycle

Each upload is tracked in an in-memory registry under the `X-Transfer-ID` the client sends:

```
stateDiagram-v2
    [*] --> RECEIVING
    RECEIVING --> RECEIVED: body fully written
    RECEIVING --> ERROR: read/write failure
    RECEIVED --> DONE: store-as msz
    RECEIVED --> DECOMPRESSING: store-as mzml
    DECOMPRESSING --> DONE
    DECOMPRESSING --> ERROR
```

The registry keeps up to 1024 records. Past that, the least recently used finished (`DONE` or `ERROR`) record is evicted; in-progress transfers are never evicted. Records do not survive a restart.
