MCPcopy Index your code
hub / github.com/Alex6357/alloy

github.com/Alex6357/alloy @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
80 symbols 146 edges 6 files 8 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Alloy - Solid + Rust

A "No-DOM" GUI Runtime: SolidJS Logic driving Rust GPUI Rendering.

Status Stack

Alloy is an experimental attempt to break free from the Electron paradigm. instead of shipping a full browser, we run compiled SolidJS logic in a lightweight QuickJS container, communicating via a high-performance Binary Command Buffer to a native Rust rendering engine (GPUI).

The Result? A desktop app architecture that retains the DX of React/Solid but targets the performance profile of native Rust applications.

demo


🗺️ The Evolution Roadmap

Alloy is designed with a 3-stage evolution path, moving from a hybrid experiment to a fully native platform.

🟢 Stage 0: The Hybrid MVP (Current)

  • Goal: Prove the "JS Logic -> Native Render" architecture.
  • Stack: SolidJS (JSX) + QuickJS + Rust GPUI.
  • Mechanism: JS writes drawing commands to a Uint8Array; Rust flushes and renders.
  • Status: ✅ Basic Concept Proven (You are here).

🟡 Stage 1: Protocol Standardization

  • Goal: Freeze the Binary Protocol (ABI).
  • Plan: Define a standard set of OpCodes (Create, Style, Layout).
  • Benefit: Any language that can emit this binary stream (Python, Go, Lua) can drive the UI.

🔵 Stage 2: The Native Era (Wasm)

  • Goal: Replace QuickJS with Wasmtime.
  • Plan: Design a component-based framework supporting both JSX and template syntax, natively compiling HTML/CSS/AssemblyScript into Wasm, while any other Wasm-compatible language can drive the UI.
  • Benefit: Near-native logic performance, Shared Memory threading, and reduced GC pauses.

🏗️ Architecture

Alloy uses a Command Buffer Pattern inspired by game engines. The Frontend does not touch the OS; it simply queues instructions.

graph LR
    subgraph "JS Realm (Logic)"
    A[SolidJS Component] -->|Reactivity| B[Custom Renderer]
    B -->|GenNode| C[Binary Encoder]
    C -->|Uint8Array| D[Shared Buffer]
    end

    subgraph "Rust Realm (Engine)"
    D -->|Flush| E[Command Parser]
    E -->|Apply| F[Shadow DOM]
    F -->|Render| G[GPUI Window]
    end

Performance Highlights

  • Zero DOM: No browser reflows/repaints. Layout is handled by Rust.
  • One FFI Call: We don't cross the JS/Rust bridge for every element. We batch commands and flush once per frame.
  • Binary Protocol: Commands are encoded in a compact binary format (avg 75% smaller than JSON).

🚀 Quick Start

Prerequisites

  • Rust (latest stable)
  • Node.js & npm
  • macOS (Verified) or Linux/Windows (Experimental support via GPUI)

Build & Run

  1. Build the Frontend Shim

    bash cd frontend npm install && npm run build

  2. Compile & Run the Engine bash cd .. cargo run --release


🔬 Technical Implementation

The Protocol

Communication happens via __alloy_flush(buffer). Example Payload (Create a `

`):

[OpCode: 1] [ID: 1] [Len: 3] [Bytes: "div"]

Supported Features (PoC)

  • Elements: div, button, text.
  • Styling: Basic Flexbox (flex-direction, gap, padding), Colors (#hex), Radius.
  • Events: onClick (dispatched from Rust back to JS).
  • Reactivity: Full SolidJS Signal/Effect support.

⚠️ Current Status: The "Counter-Only" Phase

This is a Proof of Concept validating the SolidJS → Binary → Rust architecture, realized through AI-Accelerated Development ("Vibe Coding").

While the architectural vision is intentional, much of the implementation boilerplate was generated by LLMs. As a result, the project is fast-moving but rough around the edges—currently, only the Logic Pipeline is fully functional.

  • Reactivity: Clicking the button updates the JS state, sends binary commands, and triggers a re-render.
  • 🚧 Styling: The Style engine is WIP. CSS properties are parsed, but due to the AI's limited context on GPUI internals, they don't yet visually apply in the Rust backend. (A perfect "Good First Issue" for human experts!)

Interested in the future of GUI? We need human insight to refine the AI-generated boilerplate, understand GPUI internals, and expand the CSS subset. Feel free to open issues or PRs!

📄 License

MIT

Extension points exported contracts — how you extend this code

CommandWriter (Interface)
(no doc) [2 implementers]
frontend/src/alloy/buffer.ts
Event (Interface)
(no doc)
frontend/src/alloy/buffer.ts

Core symbols most depended-on inside this repo

readU32
called by 8
frontend/src/alloy/buffer.ts
read_u32
called by 8
src/buffer.rs
writeU32
called by 7
frontend/src/alloy/buffer.ts
writeU8
called by 6
frontend/src/alloy/buffer.ts
writeString
called by 5
frontend/src/alloy/buffer.ts
parse_color
called by 5
src/main.rs
read_string
called by 5
src/buffer.rs
expand
called by 4
frontend/src/alloy/buffer.ts

Shape

Method 39
Function 25
Class 10
Enum 4
Interface 2

Languages

TypeScript71%
Rust29%

Modules by API surface

frontend/src/alloy/buffer.ts32 symbols
frontend/src/alloy/renderer.ts23 symbols
src/main.rs13 symbols
src/buffer.rs10 symbols
frontend/src/app.tsx2 symbols

For agents

$ claude mcp add alloy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact