# 5.3.1 Server Bootstrap and Runtime Setup

This diagram shows how the backend starts, mounts services, and becomes ready to handle API and realtime traffic.

```mermaid
sequenceDiagram
    autonumber
    participant Node as Node Runtime
    participant Index as Backend/index.ts
    participant App as Express App
    participant Auth as Better Auth
    participant Routes as Route Modules
    participant MinIO as MinIO
    participant RT as Socket.IO Gateway
    participant Rec as Recordings Worker
    participant Push as Push Worker

    Node->>Index: start process
    Index->>App: create express app
    Index->>App: configure helmet + cors + JSON middleware
    Index->>Auth: mount /api/auth/*
    Index->>Routes: mount videos/admin/devices/links/streams/events/recordings/ops
    Index->>MinIO: ensureMinioBucket()
    MinIO-->>Index: bucket ready
    Index->>RT: setupRealtimeGateway(server)
    Index->>Rec: startRecordingsWorker()
    Index->>Push: startPushWorker()
    Index->>App: listen on configured port
```
