Introducing a new way to review your PRs.

Read the announcement

hcavarsan / pipedash

One dashboard for CI/CD pipelines across multiple providers

View on GitHub

19 documents · Updated Nov 23, 2026

docs / web-service

Web service and realtime API

The Rust web host presents Pipedash through an HTTP API and a WebSocket connection. It joins the core services to browser and device clients, serves the web app when enabled, sends live events and push alerts, and provides short-lived downloads for rendered run logs.

Service boundary

The web service is the shared boundary for local desktop hosts and standalone server hosts. It builds one route tree under /api/v1, then applies state, authentication, host ownership, demo, and origin checks before a request reaches a route.

The service state holds the current core context, storage access, device pairing data, event stream, push relay settings, and download tickets. The state can represent setup, a configuration error, a ready host, or a locked desktop host. This lets the API report a useful state while the core is not ready. Setup can apply a new configuration, and a repaired configuration can start the core without restarting the host. The health endpoint reports setup, configuration, initialization, database, and ready states without treating a failed health query as a healthy host.

The main service states are:

StateAPI purpose
SetupExpose health and setup flows before the core is created.
Configuration errorKeep the host available so its error can be reported and fixed.
ReadyServe provider, pipeline, log, device, metrics, settings, storage, vault, and push features.
Locked desktop hostLet the shared client see health and vault status while host-only work waits for unlock.

References: crates/…/state.rs• L38-60 crates/…/state.rs• L79-137 crates/…/health.rs• L13-101 crates/…/tests.rs• L63-121 crates/…/main.rs• L137-225 crates/…/setup.rs• L54-124 crates/…/setup.rs• L143-190 crates/…/vault.rs• L146-216

HTTP API

The HTTP API groups product actions by resource. The route groups cover setup and health, providers and pipelines, pipeline views, run logs, devices, plugins, cache, metrics, preferences, settings, storage, vault, sign-in, and push services. The settings group exposes general settings for both reading and update. The route tree also exposes a separate download path for one-time log tickets.

The host uses two related route views. The full application view can fall back to the embedded frontend. The host view serves API routes only and is used by desktop sharing and WebSocket request forwarding.

The request boundary follows this order:

  1. Cross-origin checks reject unsafe browser writes and WebSocket upgrades unless the origin matches the host. An explicit allow-all setting can relax this rule.
  2. Demo mode rejects changes that are not part of the read-only demo contract.
  3. Authentication accepts the operator bearer token or a paired device token where required.
  4. Hosted mode prevents a paired device from changing host-owned settings.
  5. The selected route calls the core service and returns its result.

This separation keeps a remote device useful without giving it control of the machine that shares the data. Health, setup status, vault status, WebSocket upgrade, and selected download reads remain available during the states where normal API work is blocked. API failures use one JSON shape with a stable code, a human-readable message, and optional details. The HTTP status maps the kind of failure, such as not found, unauthorized, conflict, rate limited, unavailable, timeout, or upstream failure.

References: crates/…/lib.rs• L115-179 crates/…/lib.rs• L181-243 crates/…/lib.rs• L245-295 crates/…/main.rs• L243-271 crates/…/error.rs• L12-105 crates/…/settings.rs• L16-45 crates/…/tests.rs• L60-109 crates/…/tests.rs• L130-235 crates/…/tests.rs• L255-310 crates/…/tests.rs• L362-496 crates/…/tests.rs• L91-200

Pipeline API

The pipeline API turns the core pipeline service into browser-facing views and actions. It lets clients read cached pipeline data and run history, inspect any known run, and control a run without exposing provider-specific calls to the client.

The main pipeline capabilities are:

CapabilityClient result
Pipeline discoveryCached pipelines, optionally limited to one provider.
Build monitoringPaginated run history and details for a selected run number.
Run controlTrigger, cancel, force-cancel, review, enable, or rerun a run or job.
Trigger preparationA draft with the inputs needed for a new run or rerun.
External statusA CCTRAY XML feed with links back to the pipeline pages.

The service keeps the API result aligned with the provider and core result. A provider authentication failure remains an upstream or permission error rather than looking like a failed login to the Pipedash API. Run details can also be requested for older history instead of being limited to the newest page. After a cancel or trigger action, later reads show the resulting run state.

The following flow shows how a client moves from cached pipeline data to a run action and then reads the updated result.

sequenceDiagram
    participant Client
    participant API as Pipeline API
    participant Core as Pipeline service
    participant Provider

    Client->>API: GET cached pipelines
    API->>Core: Read cached pipeline view
    Core-->>API: Pipelines
    API-->>Client: Pipeline list
    Client->>API: POST trigger or cancel run
    API->>Core: Apply run action
    Core->>Provider: Request provider action
    Provider-->>Core: Action result
    Core-->>API: Updated result
    API-->>Client: Success or stable API error
    Client->>API: POST run history query
    API->>Core: Read current history
    Core-->>API: Updated run state
    API-->>Client: Run history page

References: crates/…/pipelines.rs• L76-102 crates/…/pipelines.rs• L104-177 crates/…/pipelines.rs• L180-266 crates/…/tests.rs• L241-355 crates/…/tests.rs• L357-394

Pipeline views

Pipeline views give clients a way to organize the pipeline list into named groups and saved navigation choices. A view can contain pipelines, nest under another view, hide items, and expose a filtered page for the main client.

The API also supports pinned repositories and pipelines. It returns a compact menu snapshot for desktop tray use, selection and batch membership changes for editors, eligible-parent data for view editing, and search-based navigation. A view page can filter by several pipeline statuses at once. Invalid status values return a stable bad-request result. These contracts keep the main client, view editor, and desktop tray aligned.

References: crates/…/pipeline_views.rs• L75-91 crates/…/pipeline_views.rs• L93-167 crates/…/pipeline_views.rs• L170-254 crates/…/tests.rs• L155-255 crates/…/tests.rs• L257-360 crates/…/tests.rs• L362-426

WebSocket API

The WebSocket endpoint at /api/v1/ws gives browsers and paired devices one long-lived channel for live events and API requests. A client first identifies itself, then can send request frames through the same host route tree and receive response frames with matching request IDs.

The connection supports these client actions:

  • auth checks an operator or paired-device token.
  • claim uses a one-time pairing code and returns a new device token.
  • request forwards an HTTP-like method, path, and optional body to the API.
  • notification-preferences sets filters and can replay notifications after a known event ID.

After authentication, the event bus sends pipeline changes and other core events to the connection. Notification events pass through the client or device preferences before delivery. A revoked device receives a removal error and must reconnect after pairing again. Vault lock also tells connected clients that the host is no longer ready.

The connection also protects the host from a bad or slow client. It requires authentication within a short window, limits admitted and active requests, sends periodic pings, closes when the host stops, and closes a client that falls too far behind the event stream.

This diagram shows how a WebSocket connection moves from identity to API access and live updates.

sequenceDiagram
    participant Client
    participant WS as WebSocket endpoint
    participant State as App state
    participant API as Host API
    participant Bus as Event bus

    Client->>WS: Upgrade /api/v1/ws
    Client->>WS: auth or claim frame
    WS->>State: Check token or consume pairing code
    State-->>WS: Client identity
    WS-->>Client: auth-ok or auth-error
    Client->>WS: request frame
    WS->>API: Dispatch /api/v1 request
    API-->>WS: HTTP status and body
    WS-->>Client: response frame
    Bus-->>WS: Core event
    WS-->>Client: Event or filtered notification

References: crates/…/ws.rs• L75-135 crates/…/ws.rs• L182-209 crates/…/ws.rs• L256-323 crates/…/ws.rs• L325-481 crates/…/ws.rs• L551-637 crates/…/tests.rs• L127-239 crates/…/tests.rs• L263-423 crates/…/tests.rs• L464-539 crates/…/tests.rs• L612-795

Push API

The push API connects server-side Pipedash alerts to a configured push relay. Operators can inspect or change the relay setting and can list, register, remove, or test iOS push subscriptions. The relay URL may come from the host environment or from stored settings.

The service also watches core events in the background. It sends pipeline failure alerts and recorded device alerts to subscriptions that match each device's notification preferences. A successful relay response records delivery. A relay response that says the subscription is gone removes that subscription so future alerts do not target it.

Push operation depends on a relay URL. Without one, registration and test delivery stop with a clear configuration error rather than creating unusable registrations.

References: crates/…/push.rs• L47-90 crates/…/push.rs• L123-254 crates/…/push.rs• L185-234 crates/…/push.rs• L292-339 crates/…/push.rs• L377-443 crates/…/main.rs• L220-225

Static frontend

When the embedded frontend is enabled, the service serves the built web app from its fallback route. It returns the app entry page for the root and client-side routes, returns built files with their content type, and returns a real not-found response for missing asset-like paths.

The normalized base path is written into the entry page. This allows the same frontend to run at the root or below a path such as /pipedash/. Invalid path segments are rejected before the server starts. Hashed assets receive long immutable cache life. The entry page is not cached so a new app version can load.

The frontend can be disabled for an external development or deployment frontend. In that mode, the Rust host keeps the API and returns not found for frontend fallback requests. When embedded assets are enabled, release builds in the repository build the frontend before packaging. Development builds and explicit skips create or use a small placeholder when no dist/index.html exists, while builds outside the repository require that file to already exist.

References: crates/…/static_files.rs• L13-45 crates/…/static_files.rs• L49-101 crates/…/lib.rs• L270-287 crates/…/main.rs• L33-109 crates/…/main.rs• L230-247 crates/…/tests.rs• L21-89 crates/…/build.rs• L4-56 crates/…/Cargo.toml• L18-23 crates/…/Cargo.toml• L67-71 crates/…/dist_placeholder.rs• L21-70

Demo mode

Demo mode presents sample data without allowing visitors to alter the host. It blocks provider and setting changes, pipeline actions, storage exports, push administration, and other writes that could change or expose the demo's source state.

The mode keeps safe reads and selected product demonstrations open. It also permits refresh and query actions needed to show the product, plus device-owned push and preference changes for the connected demo device. Pairing still uses demo-safe device names instead of exposing the owner's machine name.

Blocked changes return the DEMO_READ_ONLY error. This gives the frontend a stable way to explain why an action is unavailable.

References: crates/…/demo.rs• L20-57 crates/…/demo.rs• L60-87 crates/…/lib.rs• L251-267

Download tickets

Run-log downloads use a two-step ticket flow so the browser can download a prepared export without placing the full log in a URL or asking the download request to repeat the export work. An authenticated client requests a ticket for a log revision and receives a random ticket value.

The later GET /api/v1/downloads/{ticket} consumes the ticket and streams the text file. Tickets expire after one minute, work only once, and are limited while pending. The service sanitizes the requested file name and marks the response as non-cacheable with no referrer so the ticket and log content do not persist in normal browser caches. Request tracing also replaces the ticket value with a redacted path.

This diagram shows the ticket lifecycle from a log revision to one streamed download.

sequenceDiagram
    participant Client
    participant API as Web API
    participant Logs as Log service
    participant Tickets as Ticket store

    Client->>API: POST log download-ticket
    API->>Logs: Prepare export for revision
    Logs-->>API: Export stream and safe file name
    API->>Tickets: Store one-time ticket
    API-->>Client: Ticket
    Client->>API: GET downloads/{ticket}
    API->>Tickets: Take ticket
    Tickets-->>API: Export or expired/missing
    API-->>Client: Stream log or 404

A cache clear also invalidates related tickets. Vault lock clears them as part of shutting down the core. This keeps a ticket from outliving the log data or session that supports it.

References: crates/…/run_logs.rs• L77-94 crates/…/run_logs.rs• L157-210 crates/…/download_tickets.rs• L19-69 crates/…/main.rs• L52-58 crates/…/tests.rs• L291-298 crates/…/vault.rs• L200-216

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep HTTP route paths and WebSocket forwarded paths aligned. WebSocket clients prepend /api/v1 before dispatch.
  • Preserve the distinction between public health or status routes and routes that require an operator or paired-device token.
  • Keep health status and HTTP status aligned. A failed database probe must report an unavailable service rather than an ok response.
  • When adding a host-owned route, update both the host-management guard and the demo read-only policy if the action can change state.
  • Keep download-ticket invalidation tied to run-log cache clearing, vault locking, and host shutdown behavior.
  • When changing core event names or notification preference rules, update both WebSocket delivery and push-relay delivery.
  • When changing the frontend base path or build mode, keep server normalization, entry-page base href behavior, and packaged dist availability consistent.
  • Preserve the stable API error code and HTTP status mapping when adding a domain error or changing a route contract.
  • Keep pipeline run actions and their follow-up reads consistent so trigger and cancel results appear in history. Preserve provider authentication errors as provider failures rather than API login failures.
  • Keep pipeline view membership, page grouping, pinned items, menu snapshots, and navigation results aligned when changing view operations.
  • Keep CORS response behavior and cross-origin request rejection aligned. Read requests may remain open while browser writes and WebSocket upgrades must keep the origin boundary.
  • Keep CCTRAY links aligned with the request scheme, host, and configured frontend base path.

Important failure modes

TriggerConsequenceGuard
Core is not ready or a desktop vault is lockedNormal API requests return a not-ready or host-locked response.Health, setup, and vault routes stay open so the client can show the next action.
Health probe cannot query the databaseThe health endpoint returns 503 Service Unavailable with database_error instead of reporting a healthy host.The probe checks the provider store and maps query failure to an unavailable response.
Unknown or missing bearer token on a protected routeThe request is rejected as unauthorized.Operator tokens and paired device tokens are checked separately.
Paired device tries to change host-owned stateThe request returns HOST_MANAGED instead of changing the server.Host ownership is checked after device identity is known.
Browser write or WebSocket upgrade comes from a foreign originThe request or upgrade is rejected before it reaches the route.Same-origin checks run by default. An explicit allow-all setting is required to relax them.
WebSocket client does not authenticate or falls behind eventsThe connection closes.Authentication timeout, event lag handling, and bounded request queues force reconnect.
Download ticket is reused, expired, or cleared with the log cache or vault lockThe download returns not found.Tickets are one-time, short-lived, and tied to cache and session lifetime.
Push relay reports a removed subscriptionThat device stops receiving future alerts.The stale subscription is deleted after the relay response.
Embedded frontend build has no usable dist/index.html outside a repository checkoutThe package build stops instead of serving an incomplete app.The build step requires the asset; repository builds create a placeholder for non-release checks.
Pipeline provider rejects its credentials during a pipeline requestThe client receives a provider authentication error instead of a false Pipedash API login error.The pipeline service preserves the upstream error class and status.

Key files

FileWhy to read it
crates/…/lib.rsShows route assembly and the shared security and host-state gates.
crates/…/state.rsDefines the state that connects the web boundary to the core and host modes.
crates/…/mod.rsMaps API resource groups and the download endpoint.
crates/…/main.rsShows server startup, setup recovery, vault-aware startup, configuration, origin policy, frontend mode, graceful shutdown, and serving.
crates/…/tests.rsShows the server's defaults and contracts for base paths, origin checks, WebSocket upgrades, ticket redaction, and shutdown.
crates/…/error.rsDefines the stable JSON error contract and domain-to-HTTP status mapping.
crates/…/setup.rs and crates/…/vault.rsExplain setup application, configuration recovery, vault unlock, and vault lock.
crates/…/health.rs and crates/…/tests.rsDefine the health states and the database availability contract.
crates/…/pipelines.rsDescribes the browser-facing pipeline, run history, run control, and CCTRAY routes.
crates/…/pipeline_views.rs and crates/…/tests.rsExplain pipeline grouping, saved navigation, pins, menu snapshots, and editor operations.
crates/…/tests.rsShows the API contracts for history, run actions, provider errors, and CCTRAY links.
crates/…/settings.rsDefines the general settings read and update boundary.
crates/…/ws.rsDescribes authentication, request forwarding, event delivery, pairing, and connection limits.
crates/…/push.rs and crates/…/push.rsExplain push subscription management and event-driven alert delivery.
crates/…/static_files.rs and crates/…/build.rsExplain embedded frontend fallback, base paths, asset caching, and asset build rules.
crates/…/demo.rsDefines the read-only demo contract.
crates/…/run_logs.rs and crates/…/download_tickets.rsExplain log export preparation and one-time download behavior.

See also: application-hosts for the host role, desktop-runtime for the desktop process that can own and share this service, client-notifications for live and push alert behavior, and authentication-and-pairing for client identity and pairing.