Skip to main content
The Palyra daemon (palyrad) exposes a multi-surface HTTP transport layer built on the Axum framework. This layer serves as the primary interface for the Web Console, the Canvas interactive environment, and OpenAI-compatible client integrations. It operates alongside the gRPC Gateway service, sharing a unified AppState but implementing distinct security, rate-limiting, and session management policies for each API surface.

System Architecture and Data Flow

The HTTP transport layer is initialized via build_router, which assembles the routing tree and attaches middleware pipelines based on the path prefix.

HTTP Surface Organization

PrefixPurposeAuth Mechanism
/admin/v1Low-level daemon management and diagnostics.Bearer Token / Principal Headers
/console/v1Backend for the React-based Operator Dashboard.Session Cookie + CSRF Token
/canvas/v1Interactive “Canvas” tool execution and state.Canvas-specific Tokens
/v1OpenAI-compatible Chat Completions and Models API.API Tokens (Managed in Access Registry)
/Serves the static SPA assets for the Web Dashboard.Public (Assets) / Protected (Logic)

Code Entity Map: HTTP Routing

The following diagram maps the logical API surfaces to their implementation handlers and the shared state. Title: HTTP Routing and State Association Sources: crates/palyra-daemon/src/transport/http/router.rs#17-157, crates/palyra-daemon/src/app/state.rs#30-61

Middleware Pipeline and Security Guards

Palyra implements a layered middleware strategy to enforce security boundaries between the local CLI, remote admin tools, and the web-based console.

1. Security Headers

All responses from the /admin, /console, and web UI surfaces are injected with strict security headers via apply_admin_console_security_headers crates/palyra-daemon/src/transport/http/middleware.rs#37-52. This includes:
  • Cache-Control: no-store
  • X-Frame-Options: DENY
  • Content-Security-Policy: frame-ancestors 'none'
  • X-Content-Type-Options: nosniff

2. Rate Limiting

Rate limiting is enforced per-IP bucket using a window-based approach. The /admin surface has a higher budget for loopback (CLI) traffic compared to external IPs.

3. Console Session & CSRF

The /console/v1 surface uses a “Double Submit Cookie” pattern for CSRF protection. Sources: crates/palyra-daemon/src/transport/http/middleware.rs#28-52, crates/palyra-daemon/src/transport/http/middleware.rs#172-204, crates/palyra-daemon/src/transport/http/handlers/console/auth.rs#19-111

API Surface Implementation

Admin API (/admin/v1)

Primarily used for diagnostics and low-level control of the daemon. It requires x-palyra-principal and x-palyra-device-id headers for context.

Console API (/console/v1)

A rich API surface designed for the React Dashboard (apps/web).

OpenAI-Compatible API (/v1)

Allows standard LLM clients to use Palyra as a provider. Title: Console Authentication and Handoff Flow Sources: crates/palyra-daemon/src/transport/http/handlers/console/auth.rs#127-170, crates/palyra-control_plane/src/client.rs#85-91

Handler Organization and Data Transformation

Handlers are organized into modules under transport::http::handlers. They serve as a translation layer between HTTP/JSON and the internal Protobuf-based service logic.
ModuleResponsibilityKey Entities
admin::coreCore daemon status and run control.admin_status_handler
console::diagnosticsAggregated health for the UI.console_diagnostics_handler
compatOpenAI protocol translation.CompatChatCompletionsRequest
web_uiStatic asset serving for the SPA.web_ui_entry_handler

Static Asset Serving

The web_ui_entry_handler crates/palyra-daemon/src/transport/http/handlers/web_ui.rs#16-34 resolves the dashboard location by checking:
  1. PALYRA_WEB_DIST_DIR environment variable.
  2. A web/ directory relative to the current executable.
  3. The apps/web/dist path in the source tree.
It serves index.html for all non-file paths to support SPA client-side routing crates/palyra-daemon/src/transport/http/handlers/web_ui.rs#191-193. Sources: crates/palyra-daemon/src/transport/http/handlers/console/mod.rs#1-30, crates/palyra-daemon/src/transport/http/handlers/web_ui.rs#125-148