# poly-gui/poly architecture

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

- Interactive diagram: https://gitdiagram.com/poly-gui/poly
- Repository: https://github.com/poly-gui/poly

## Overview

Poly is a multi-language framework for building native GUI applications from portable application code. A representative workflow is React elements reconciled into widget descriptors, sent by the TypeScript SDK over RPC, and handled by a native runtime; the SDK also exposes list views and other widgets. The repository additionally includes a CLI and a shared Tailwind-style class parser. The excerpts show TypeScript and React call paths; runtime implementation links beyond the sampled Swift files are documented at a high level in the README and are marked unverified.

Main entry points: [`sdks/typescript/core/src/rpc/native-layer-service.np.ts`](https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/rpc/native-layer-service.np.ts) (Native RPC service), [`sdks/typescript/core/src/application.ts`](https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/application.ts) (Application transport), [`runtimes/swift/Sources/PolyNative/RPC/NativeLayerService.np.swift`](https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/RPC/NativeLayerService.np.swift) (Native RPC handlers), [`integrations/react/src/reconciler.ts`](https://github.com/poly-gui/poly/blob/main/integrations/react/src/reconciler.ts) (React reconciler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portable["Portable SDK"]
  node_app_sdk["Application transport<br/>[application.ts]"]
  node_native_rpc["Native RPC service"]
  node_portable_rpc["Callback RPC service"]
  node_message_factory["Message decoding"]
  node_list_view["List view<br/>[list-view.ts]"]
end

subgraph group_react["React Integration"]
  node_react_reconciler["React reconciler<br/>[reconciler.ts]"]
  node_react_widgets["React widgets<br/>[widget.ts]"]
  node_react_column["Column widget<br/>[column.ts]"]
end

subgraph group_runtime["Native Runtime"]
  node_swift_context["Application context"]
  node_swift_native_rpc["Native RPC handlers"]
  node_swift_portable_rpc["Portable RPC handlers"]
  node_swift_widgets["Native widgets<br/>[ListView.swift]"]
  node_window_manager["Window manager"]
  node_gtk_runtime["GTK runtime"]
end

subgraph group_shared["Shared Styling"]
  node_twx_parser["Tailwind class parser<br/>[colors.c]"]
end

subgraph group_cli["Developer CLI"]
  node_poly_cli["Poly CLI<br/>[poly.go]"]
end

node_developer(("App developer"))

node_developer -.->|"creates UI"| node_react_reconciler
node_react_reconciler -->|"creates widgets"| node_react_widgets
node_react_reconciler -->|"selects column"| node_react_column
node_react_widgets -->|"sends widget updates"| node_native_rpc
node_react_column -->|"sends updates"| node_native_rpc
node_app_sdk -->|"creates client"| node_native_rpc
node_app_sdk -->|"creates server"| node_portable_rpc
node_native_rpc -->|"decodes messages"| node_message_factory
node_portable_rpc -->|"decodes messages"| node_message_factory
node_list_view -->|"sends updates"| node_native_rpc
node_swift_context -.->|"configures runtime"| node_swift_native_rpc
node_swift_context -.->|"configures callbacks"| node_swift_portable_rpc
node_swift_native_rpc -.->|"dispatches widget operations"| node_swift_widgets
node_swift_native_rpc -.->|"manages windows"| node_window_manager
node_app_sdk -.->|"exchanges native RPC"| node_swift_native_rpc
node_swift_portable_rpc -.->|"invokes portable callbacks"| node_app_sdk
node_developer -.->|"uses tools"| node_poly_cli
node_developer -.->|"styles interfaces"| node_twx_parser

click node_react_reconciler "https://github.com/poly-gui/poly/blob/main/integrations/react/src/reconciler.ts"
click node_react_widgets "https://github.com/poly-gui/poly/blob/main/integrations/react/src/widget.ts"
click node_react_column "https://github.com/poly-gui/poly/blob/main/integrations/react/src/widget/column.ts"
click node_app_sdk "https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/application.ts"
click node_native_rpc "https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/rpc/native-layer-service.np.ts"
click node_portable_rpc "https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/rpc/portable-layer-service.np.ts"
click node_message_factory "https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/rpc/message-factory.np.ts"
click node_list_view "https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/widget/list-view.ts"
click node_swift_context "https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/ApplicationContext.swift"
click node_swift_native_rpc "https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/RPC/NativeLayerService.np.swift"
click node_swift_portable_rpc "https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/RPC/PortableLayerService.np.swift"
click node_swift_widgets "https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/Widgets/ListView.swift"
click node_window_manager "https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/WindowManager.swift"
click node_gtk_runtime "https://github.com/poly-gui/poly/tree/main/runtimes/gtk"
click node_twx_parser "https://github.com/poly-gui/poly/blob/main/libs/twx/src/colors.c"
click node_poly_cli "https://github.com/poly-gui/poly/blob/main/tools/poly-cli/cmd/poly/poly.go"

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_app_sdk,node_native_rpc,node_portable_rpc,node_message_factory,node_list_view toneBlue
class node_react_reconciler,node_react_widgets,node_react_column toneAmber
class node_swift_context,node_swift_native_rpc,node_swift_portable_rpc,node_swift_widgets,node_window_manager,node_gtk_runtime toneMint
class node_twx_parser toneRose
class node_poly_cli,node_developer toneIndigo
```

## Components

### Portable SDK

- [Application transport](https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/application.ts): `sdks/typescript/core/src/application.ts`
- [Native RPC service](https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/rpc/native-layer-service.np.ts): `sdks/typescript/core/src/rpc/native-layer-service.np.ts`
- [Callback RPC service](https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/rpc/portable-layer-service.np.ts): `sdks/typescript/core/src/rpc/portable-layer-service.np.ts`
- [Message decoding](https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/rpc/message-factory.np.ts): `sdks/typescript/core/src/rpc/message-factory.np.ts`
- [List view](https://github.com/poly-gui/poly/blob/main/sdks/typescript/core/src/widget/list-view.ts): `sdks/typescript/core/src/widget/list-view.ts`

### React Integration

- [React reconciler](https://github.com/poly-gui/poly/blob/main/integrations/react/src/reconciler.ts): `integrations/react/src/reconciler.ts`
- [React widgets](https://github.com/poly-gui/poly/blob/main/integrations/react/src/widget.ts): `integrations/react/src/widget.ts`
- [Column widget](https://github.com/poly-gui/poly/blob/main/integrations/react/src/widget/column.ts): `integrations/react/src/widget/column.ts`

### Native Runtime

- [Application context](https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/ApplicationContext.swift): `runtimes/swift/Sources/PolyNative/ApplicationContext.swift`
- [Native RPC handlers](https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/RPC/NativeLayerService.np.swift): `runtimes/swift/Sources/PolyNative/RPC/NativeLayerService.np.swift`
- [Portable RPC handlers](https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/RPC/PortableLayerService.np.swift): `runtimes/swift/Sources/PolyNative/RPC/PortableLayerService.np.swift`
- [Native widgets](https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/Widgets/ListView.swift): `runtimes/swift/Sources/PolyNative/Widgets/ListView.swift`
- [Window manager](https://github.com/poly-gui/poly/blob/main/runtimes/swift/Sources/PolyNative/WindowManager.swift): `runtimes/swift/Sources/PolyNative/WindowManager.swift`
- [GTK runtime](https://github.com/poly-gui/poly/tree/main/runtimes/gtk): `runtimes/gtk`

### Shared Styling

- [Tailwind class parser](https://github.com/poly-gui/poly/blob/main/libs/twx/src/colors.c): `libs/twx/src/colors.c`

### Developer CLI

- [Poly CLI](https://github.com/poly-gui/poly/blob/main/tools/poly-cli/cmd/poly/poly.go): `tools/poly-cli/cmd/poly/poly.go`

### Other components

- **App developer**

## Connections

- App developer → React reconciler: creates UI
- React reconciler → React widgets: creates widgets (evidence: `integrations/react/src/reconciler.ts`)
- React reconciler → Column widget: selects column (evidence: `integrations/react/src/reconciler.ts`)
- React widgets → Native RPC service: sends widget updates (evidence: `integrations/react/src/widget.ts`)
- Column widget → Native RPC service: sends updates (evidence: `integrations/react/src/widget/column.ts`)
- Application transport → Native RPC service: creates client (evidence: `sdks/typescript/core/src/application.ts`)
- Application transport → Callback RPC service: creates server (evidence: `sdks/typescript/core/src/application.ts`)
- Native RPC service → Message decoding: decodes messages (evidence: `sdks/typescript/core/src/rpc/native-layer-service.np.ts`)
- Callback RPC service → Message decoding: decodes messages (evidence: `sdks/typescript/core/src/rpc/portable-layer-service.np.ts`)
- List view → Native RPC service: sends updates (evidence: `sdks/typescript/core/src/widget/list-view.ts`)
- Application context → Native RPC handlers: configures runtime
- Application context → Portable RPC handlers: configures callbacks
- Native RPC handlers → Native widgets: dispatches widget operations
- Native RPC handlers → Window manager: manages windows
- Application transport → Native RPC handlers: exchanges native RPC
- Portable RPC handlers → Application transport: invokes portable callbacks
- App developer → Poly CLI: uses tools
- App developer → Tailwind class parser: styles interfaces
