Architecture

Pytron-kit is built on a modular architecture designed for security, high-performance IPC, and developer simplicity. It avoids the "Local Server" overhead by using a direct native bridge, which ensures zero port conflicts and a smaller security surface area.

graph TD subgraph "Frontend Process (Web Technology)" UI[<b>Pytron UI</b><br>React Components / Web Components] Client[<b>Pytron Client</b><br>JavaScript Bridge & State Manager] AppJS[<b>User Frontend App</b><br>React/Vite/Next.js] UI --> AppJS AppJS --> Client end subgraph "IPC Bridge (Inter-Process Communication)" Msg[JSON Message Passing] end subgraph "Backend Process (Python)" Kit[<b>Pytron Kit</b><br>Window Manager & Server] UserPy[<b>User Backend Code</b><br>@app.expose / Business Logic] Kit --> UserPy end Client <-->|RPC Calls & Events| Msg Msg <-->|Bridge Interface| Kit %% Data Flow UserPy -.->|State Updates| Kit Kit -.->|Sync State| Client Client -.->|Update Signals| AppJS

The Polyglot Stack

Pytron-kit is a polyglot framework that leverages the best tools for each layer:

  • Python: The core of the framework (90%+). Handles the CLI, window management, and business logic.
  • JavaScript / TypeScript: Powers the frontend bridge (pytron-client), UI components (pytron-ui), and template scaffolding.
  • Rust: Provides the high-security "Agentic Shield" bootloader and payload encryption layer.
  • C / C++: Low-level OS integration (Win32, GTK, Cocoa), Android JNI bridge, and Nuitka-compiled machine code.
  • Kotlin / Java: Android-specific lifecycle management and native platform hooks.
  • HTML / CSS: The backbone of all user interfaces and frontend layouts.

Direct Native Communication

Most "Python-as-UI" frameworks spin up a local HTTP server (Flask/FastAPI) and talk via network ports. Pytron-kit uses a direct native bridge. This means zero latency, zero open ports, and zero firewall issues.

python
from pytron import App
app = App() 
app.run()

Encapsulated State Sync

Pytron-kit implements a reactive system. When you update data in Python, it's automatically diffed and pushed across the native bridge to the Pytron Client, which triggers a re-render in your UI.

Architecture Decisions

We explicitly chose WebView2 (Edge/Chromium) for Windows and WebKit for Mac/Linux to keep distribution sizes under 30MB, while maintaining the option to switch to a full Chrome Engine (Mojo) for applications requiring 100% rendering parity.