Skip to main content
This page details the bootstrapping and initialization process for the Palyra development environment and production-like deployments. It covers the transition from a fresh repository to a fully configured and validated daemon.

Environment Bootstrapping

Before running the Palyra CLI or daemon, the environment must be prepared with necessary dependencies and workspace materialization.

Developer Bootstrap

The repository provides two primary scripts for automated dependency installation and environment preparation:
  • scripts/dev/bootstrap.sh: For Unix-based systems.
  • scripts/dev/bootstrap.ps1: For Windows systems.
These scripts perform the following high-level tasks:
  1. Toolchain Validation: Ensures rustc, cargo, and npm are available.
  2. Protocol Buffers: Validates or installs protoc for gRPC stub generation Makefile#23-32.
  3. JS Workspace: Executes vp install to materialize the root JavaScript/TypeScript node_modules across the monorepo justfile#30-31.
  4. UI Preparation: Ensures the desktop UI assets are staged for the Tauri build justfile#44-45.

Automation with Just/Make

The project uses just (preferred) or make to orchestrate common setup tasks.
  • just dev: Runs the doctor check, prepares the UI, and builds the workspace justfile#16-20.
  • just doctor: Runs strict environment validation justfile#7-11.

The Setup and Onboarding Wizard

Palyra uses a guided onboarding system implemented in the CLI to generate initial configurations. This is handled by the palyra setup command (aliased to init) crates/palyra-cli/tests/cli_parity_report.md#30.

Wizard Flows

The OnboardingWizardRequest crates/palyra-cli/src/commands/operator_wizard.rs#24-30 supports three primary flows defined by WizardFlowKind crates/palyra-cli/src/commands/operator_wizard.rs#65-69:
FlowPurposeKey Actions
QuickstartRapid local setupAuto-detects environment, prompts for API keys, sets up loopback-only binding.
ManualCustom local/server setupAllows specific port configuration, TLS certificate paths, and advanced storage options.
RemoteConnecting to a remote daemonConfigures mTLS identities and remote base URLs for CLI-to-Daemon communication.

Implementation Logic

The wizard operates as a state machine using WizardSession and WizardStep crates/palyra-cli/src/commands/operator_wizard.rs#10-13. It can run in InteractiveWizardBackend (terminal prompts) or NonInteractiveWizardBackend (using CLI flags for CI/CD) crates/palyra-cli/src/commands/operator_wizard.rs#9-13. Sources: crates/palyra-cli/src/commands/operator_wizard.rs, crates/palyra-cli/tests/help_snapshots/setup-help.txt

Configuration Schema (palyra.toml)

The central configuration file is palyra.toml. It is parsed into the RootFileConfig struct crates/palyra-common/src/daemon_config_schema.rs#102-119.

Key Configuration Sections

Security and Redaction

To prevent accidental leakage of secrets in logs or support bundles, the system uses SECRET_CONFIG_PATHS crates/palyra-common/src/daemon_config_schema.rs#6-16. The function redact_secret_config_values recursively traverses the TOML document and replaces sensitive values with <redacted> crates/palyra-common/src/daemon_config_schema.rs#24-29.

Data Flow: Configuration Loading

The daemon loads configuration through a multi-step process: Sources: crates/palyra-daemon/src/config/load.rs#31-60, crates/palyra-common/src/daemon_config_schema.rs

Environment Variables

Palyra uses environment variables to override file-based configuration or provide secrets in containerized environments.
VariableDescription
PALYRA_STATE_ROOTThe directory where the SQLite database and logs are stored crates/palyra-cli/tests/wizard_cli.rs#14.
PALYRA_VAULT_DIRLocation of the encrypted secret vault crates/palyra-cli/tests/wizard_cli.rs#15.
PALYRA_BROWSERD_STATE_DIRStorage for headless browser profiles crates/palyra-cli/src/commands/doctor/recovery.rs#34.
PALYRA_BROWSERD_STATE_ENCRYPTION_KEYKey used to encrypt browser profile data crates/palyra-cli/src/commands/doctor/recovery.rs#33.

Environment Validation: The Doctor Command

The palyra doctor command is a diagnostic tool used to validate the health of the environment and perform automated repairs.

Diagnostic Pipeline

The doctor executes a series of DoctorCheck routines. If a check fails, it generates a DoctorRepairStep crates/palyra-cli/src/commands/doctor/recovery.rs#105-118.

Repair and Recovery

The doctor can perform several automated fixes:
  1. Config Migration: Updates palyra.toml to the latest schema version crates/palyra-cli/src/commands/doctor/recovery.rs#182-184.
  2. Registry Normalization: Fixes malformed JSON/TOML files in the auth_profiles.toml or routines/ directory crates/palyra-cli/src/commands/doctor/recovery.rs#195-198.
  3. Identity Recovery: Regenerates missing mTLS certificates or browser auth tokens crates/palyra-cli/src/commands/doctor/recovery.rs#192-194.

Doctor Data Structures

Sources: crates/palyra-cli/src/commands/doctor/recovery.rs#77-118, crates/palyra-cli/src/commands/doctor.rs