Skip to main content
This page documents the organization of the Palyra codebase, the configuration of its Cargo workspace, and the task orchestration layer used for development and CI/CD.

Workspace Architecture

Palyra is managed as a Rust-centric monorepo using a Cargo workspace to coordinate multiple crates, while also hosting application-specific code for web, desktop, and mobile platforms.

Cargo Workspace Configuration

The root Cargo.toml defines the workspace members and shared metadata. It uses a centralized versioning and dependency management strategy to ensure consistency across the platform.
PropertyValue
Rust Edition2021 Cargo.toml#23
Rust Version1.91 Cargo.toml#26
ResolverVersion 2 Cargo.toml#20
LicensePCSL v1.1 (referenced as LICENSE) Cargo.toml#24
The workspace enforces strict linting across all crates, including denying unsafe_op_in_unsafe_fn Cargo.toml#85 and various Clippy lints such as dbg_macro Cargo.toml#90 and todo Cargo.toml#91.

Monorepo Layout

The repository is organized into functional directories:
  • crates/: Core logic, libraries, and the primary Rust binaries.
  • apps/: Platform-specific client applications.
  • schemas/: Cross-language protocol definitions.
    • schemas/proto/: Protobuf definitions for gRPC services (Gateway, Auth, Node, etc.) crates/palyra-daemon/build.rs#7-14.
    • schemas/json/: JSON schemas for envelopes and configuration.
  • scripts/: Automation for bootstrapping, protocol generation, and CI gates.

Workspace Dependency Graph

The following diagram illustrates how the primary binaries consume internal crates. Crate Relationship Diagram Sources: Cargo.toml#1-19, crates/palyra-daemon/Cargo.toml#22-34, crates/palyra-cli/Cargo.toml#25-32

Task Runner and Orchestration

Palyra uses a dual-interface task runner system supporting both make and just. These runners wrap complex operations like gRPC stub generation, environment validation, and security auditing.

Primary Commands

The Makefile and justfile provide identical targets for core workflows:
  • make doctor: Runs strict environment checks via the CLI’s doctor command to ensure the local toolchain is compatible Makefile#10.
  • make dev: The standard entry point for developers. It validates the environment, ensures the desktop UI is built, and compiles the workspace Makefile#16-19.
  • make protocol: Validates .proto files and generates Rust stubs using scripts/protocol/generate-stubs.sh Makefile#29-32.
  • make security: Executes a suite of audits including cargo audit, cargo deny, and custom scripts to check for high-risk patterns or leaked artifacts Makefile#56-62.

Pre-push Integrity

A git hook .githooks/pre-push:4 executes scripts/run-pre-push-checks.sh. This script supports two profiles:
  1. fast (default): Checks JS workspace health, rustfmt, module budgets, and runs the deterministic core smoke suite scripts/run-pre-push-checks.sh#49-72.
  2. full: Includes all fast checks plus clippy, full workspace tests, and the workflow regression matrix scripts/run-pre-push-checks.sh#74-108.
Sources: Makefile#1-170, justfile#1-177, scripts/run-pre-push-checks.sh#1-129

Protocol and Build Logic

The codebase uses a “Schema-First” approach. gRPC services are defined in schemas/proto and compiled into Rust modules during the build phase of the daemon and CLI.

Build-time Code Generation

Both palyra-daemon and palyra-cli utilize build.rs scripts to invoke tonic-build. This ensures that any change to the .proto files triggers a recompilation of the dependent Rust code. Protocol Build Flow Key services compiled include: Sources: crates/palyra-daemon/build.rs#3-38, crates/palyra-cli/build.rs#3-38

Environment Bootstrapping

Initial setup is handled by platform-specific scripts:
  • scripts/dev/bootstrap.sh (Linux/macOS)
  • scripts/dev/bootstrap.ps1 (Windows)
These scripts prepare the local environment before make dev can be successfully executed.

Artifact Hygiene

The repository maintains strict rules against committing runtime artifacts. The .gitignore excludes target/, node_modules/, and various .tmp or .log files .gitignore:1-34. The task runner includes artifact-hygiene checks to ensure that no generated data (like SQLite databases or temporary certificates) is accidentally tracked Makefile#63-64. Sources: scripts/dev/bootstrap.sh, scripts/dev/bootstrap.ps1, Makefile#63-68, .gitignore#1-72