# perryts/perry architecture

> Architecture diagram of the GitHub repository perryts/perry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/perryts/perry
- Repository: https://github.com/perryts/perry

## Overview

Perry is a TypeScript compiler and native application platform, with JavaScript and WebAssembly as additional targets. The main workflow is source code through the compile driver and code generation to a standalone executable; platform-specific UI backends and the native runtime provide important parallel capabilities. The README documents broader runtime and platform support than the sampled source establishes, so those subsystems are shown at their documented directory level, with uncertain internal wiring omitted.

Main entry points: [`crates/perry/src/commands/compile/run_pipeline.rs`](https://github.com/perryts/perry/blob/main/crates/perry/src/commands/compile/run_pipeline.rs) (Compile driver), [`crates/perry-runtime`](https://github.com/perryts/perry/tree/main/crates/perry-runtime) (Native runtime), [`crates/perry-codegen/src/lib.rs`](https://github.com/perryts/perry/blob/main/crates/perry-codegen/src/lib.rs) (Native codegen), [`crates/perry/src`](https://github.com/perryts/perry/tree/main/crates/perry/src) (Perry CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compile["Compile frontend"]
  node_cli["Perry CLI"]
  node_driver["Compile driver<br/>[run_pipeline.rs]"]
  node_parser["Parser and HIR"]
end

subgraph group_emit["Code generation"]
  node_codegen["Native codegen<br/>[lib.rs]"]
  node_wasm["WebAssembly backend<br/>[lib.rs]"]
  node_javascript["JavaScript backend<br/>[lib.rs]"]
  node_ui["Native UI backends<br/>[lib.rs]"]
  node_swiftui["SwiftUI backend<br/>[lib.rs]"]
  node_wear["Wear tiles backend<br/>[lib.rs]"]
  node_glance["Glance backend<br/>[lib.rs]"]
end

subgraph group_runtime["Runtime platform"]
  node_runtime["Native runtime"]
  node_stdlib["Standard library"]
  node_abi["Native ABI<br/>[lib.rs]"]
end

subgraph group_targets["Platform targets"]
end

node_developer(("TypeScript developer"))
node_source["TypeScript source"]
node_native["Native executable"]
node_web["Web output"]
node_platform["Platform UI targets"]
node_threads["OS threads"]

node_developer -->|"writes"| node_source
node_source -->|"compiles"| node_cli
node_cli -->|"invokes"| node_driver
node_driver -->|"parses and lowers"| node_parser
node_driver -->|"generates native code"| node_codegen
node_driver -.->|"selects web target"| node_javascript
node_driver -.->|"selects wasm target"| node_wasm
node_driver -.->|"selects target"| node_ui
node_driver -.->|"selects target"| node_swiftui
node_driver -.->|"selects target"| node_wear
node_driver -.->|"selects target"| node_glance
node_codegen -->|"emits runtime calls"| node_runtime
node_driver -->|"links and packages"| node_native
node_codegen -->|"emits machine code"| node_native
node_javascript -->|"emits JavaScript"| node_web
node_wasm -->|"emits WebAssembly"| node_web
node_ui -->|"builds native widgets"| node_platform
node_swiftui -->|"builds native UI"| node_platform
node_wear -->|"builds tiles"| node_platform
node_glance -->|"builds UI"| node_platform
node_runtime -->|"supports native APIs"| node_stdlib
node_runtime -->|"exposes native interface"| node_abi
node_runtime -->|"provides thread support"| node_threads

click node_cli "https://github.com/perryts/perry/tree/main/crates/perry/src"
click node_driver "https://github.com/perryts/perry/blob/main/crates/perry/src/commands/compile/run_pipeline.rs"
click node_parser "https://github.com/perryts/perry/tree/main/crates/perry-parser"
click node_codegen "https://github.com/perryts/perry/blob/main/crates/perry-codegen/src/lib.rs"
click node_wasm "https://github.com/perryts/perry/blob/main/crates/perry-codegen-wasm/src/lib.rs"
click node_javascript "https://github.com/perryts/perry/blob/main/crates/perry-codegen-js/src/lib.rs"
click node_ui "https://github.com/perryts/perry/blob/main/crates/perry-codegen-arkts/src/lib.rs"
click node_swiftui "https://github.com/perryts/perry/blob/main/crates/perry-codegen-swiftui/src/lib.rs"
click node_wear "https://github.com/perryts/perry/blob/main/crates/perry-codegen-wear-tiles/src/lib.rs"
click node_glance "https://github.com/perryts/perry/blob/main/crates/perry-codegen-glance/src/lib.rs"
click node_runtime "https://github.com/perryts/perry/tree/main/crates/perry-runtime"
click node_stdlib "https://github.com/perryts/perry/tree/main/crates/perry-stdlib"
click node_abi "https://github.com/perryts/perry/blob/main/crates/perry-abi/src/lib.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_driver,node_parser,node_platform toneBlue
class node_codegen,node_wasm,node_javascript,node_ui,node_swiftui,node_wear,node_glance toneAmber
class node_runtime,node_stdlib,node_abi toneMint
class node_developer,node_source,node_native,node_web,node_threads toneIndigo
```

## Components

### Compile frontend

- [Perry CLI](https://github.com/perryts/perry/tree/main/crates/perry/src): `crates/perry/src`
- [Compile driver](https://github.com/perryts/perry/blob/main/crates/perry/src/commands/compile/run_pipeline.rs): `crates/perry/src/commands/compile/run_pipeline.rs`
- [Parser and HIR](https://github.com/perryts/perry/tree/main/crates/perry-parser): `crates/perry-parser`

### Code generation

- [Native codegen](https://github.com/perryts/perry/blob/main/crates/perry-codegen/src/lib.rs): `crates/perry-codegen/src/lib.rs`
- [WebAssembly backend](https://github.com/perryts/perry/blob/main/crates/perry-codegen-wasm/src/lib.rs): `crates/perry-codegen-wasm/src/lib.rs`
- [JavaScript backend](https://github.com/perryts/perry/blob/main/crates/perry-codegen-js/src/lib.rs): `crates/perry-codegen-js/src/lib.rs`
- [Native UI backends](https://github.com/perryts/perry/blob/main/crates/perry-codegen-arkts/src/lib.rs): `crates/perry-codegen-arkts/src/lib.rs`
- [SwiftUI backend](https://github.com/perryts/perry/blob/main/crates/perry-codegen-swiftui/src/lib.rs): `crates/perry-codegen-swiftui/src/lib.rs`
- [Wear tiles backend](https://github.com/perryts/perry/blob/main/crates/perry-codegen-wear-tiles/src/lib.rs): `crates/perry-codegen-wear-tiles/src/lib.rs`
- [Glance backend](https://github.com/perryts/perry/blob/main/crates/perry-codegen-glance/src/lib.rs): `crates/perry-codegen-glance/src/lib.rs`

### Runtime platform

- [Native runtime](https://github.com/perryts/perry/tree/main/crates/perry-runtime): `crates/perry-runtime`
- [Standard library](https://github.com/perryts/perry/tree/main/crates/perry-stdlib): `crates/perry-stdlib`
- [Native ABI](https://github.com/perryts/perry/blob/main/crates/perry-abi/src/lib.rs): `crates/perry-abi/src/lib.rs`

### Other components

- **TypeScript developer**
- **TypeScript source**
- **Native executable**
- **Web output**
- **Platform UI targets**
- **OS threads**

## Connections

- TypeScript developer → TypeScript source: writes
- TypeScript source → Perry CLI: compiles
- Perry CLI → Compile driver: invokes
- Compile driver → Parser and HIR: parses and lowers
- Compile driver → Native codegen: generates native code
- Compile driver → JavaScript backend: selects web target
- Compile driver → WebAssembly backend: selects wasm target
- Compile driver → Native UI backends: selects target
- Compile driver → SwiftUI backend: selects target
- Compile driver → Wear tiles backend: selects target
- Compile driver → Glance backend: selects target
- Native codegen → Native runtime: emits runtime calls
- Compile driver → Native executable: links and packages
- Native codegen → Native executable: emits machine code
- JavaScript backend → Web output: emits JavaScript
- WebAssembly backend → Web output: emits WebAssembly
- Native UI backends → Platform UI targets: builds native widgets
- SwiftUI backend → Platform UI targets: builds native UI
- Wear tiles backend → Platform UI targets: builds tiles
- Glance backend → Platform UI targets: builds UI
- Native runtime → Standard library: supports native APIs
- Native runtime → Native ABI: exposes native interface
- Native runtime → OS threads: provides thread support
