tpt-appfront

Rust

Write your UI once in Rust and render it anywhere: native/WASM canvas (egui+taffy), reactive DOM, semantic HTML, terminal UI (ratatui), JSON-LD/AI-agent schema, and an OS-webview desktop shell — served to the right client by a smart backend router.

0 stars0 forks0 watchersApache License 2.0
ai-agentscross-platformeguireactive-programmingrustserver-side-renderingterminal-uiui-frameworkwasmwebassembly

Languages

Rust99.7%Shell0.2%Just0.2%
README

TPT AppFront

CI license

Write your UI once in Rust as a plain value, a UITree<Msg>, and render it to a browser DOM, a native window, a terminal, semantic HTML for crawlers, or a JSON-LD and AI-agent schema. One codebase, several targets.

use tpt_appfront::prelude::*;

#[derive(Debug, Clone, PartialEq)]
enum Msg {
    Increment,
}

fn counter_view(count: i32) -> UITree<Msg> {
    UITree::container(|c: &mut ContainerBuilder<Msg>| {
        c.heading(1, format!("Count: {count}"));
        c.button("Increment").on_click(Msg::Increment);
    })
}

Test it without a browser:

use tpt_appfront::test::Harness;

let count = Signal::new(0i32);
let mut h = Harness::new(counter_view(count.get()));
h.click("Increment");
assert_eq!(h.drain_msgs(), vec![Msg::Increment]);

The same counter_view renders to the DOM (tpt-appfront-dom), to a native window (tpt-appfront-canvas), to a terminal (tpt-appfront-tui), and to HTML (tpt-appfront-html). Other backends can read it too, as described below.

Documentation

Backends

BackendCrateTargetInteractiveImages / media / linksNotes
Reactive DOMtpt-appfront-dombrowser (wasm32)yes, all nodesyesMounts once, then updates only changed nodes. Hydrates server output
Canvastpt-appfront-canvasnative and wasm32yes, most nodescaptions onlyegui with taffy layout. Checkboxes and selects have no focus or key handlers yet
Terminaltpt-appfront-tuiany terminalkeyboard onlynot focusableratatui. Tab and arrows move focus, Enter activates
Semantic HTMLtpt-appfront-htmlservern/a (static)yesSSR and SSG, with data-ai-* and OpenGraph tags
JSON-LD and AI schematpt-appfront-ai-schemaservern/an/aStructured data for search engines and AI agents
Desktop webviewtpt-appfront-webviewnative windowyesyesHosts the DOM bundle in the system webview. Not published to crates.io yet
MCP servertpt-appfront-mcpstdioagent actionsn/aExposes each interactive node as an MCP tool

Check this table before you rely on a node type on a backend that is not the browser.

Status

Pre-1.0 (0.1.x). The DOM, HTML and server backends are the most exercised. The canvas and TUI backends are usable for simple UIs. Some items are still planned, including a native tray icon, GPU layout, and mobile. todo.md lists what is done and what is not. The crates have not been published to crates.io yet.

Quickstart

The CLI is not on crates.io yet, so run it from a checkout:

git clone https://github.com/tpt-solutions/tpt-appfront && cd tpt-appfront
cargo run -p tpt-appfront-cli -- init my-app --target dom   # or canvas, tui, server
cd my-app && trunk serve                                    # dom: browser

See docs/quickstart.md for the full set of commands, presets and options.

Workspace layout

  • crates/tpt-appfront — umbrella crate: feature flags for each backend, and a prelude
  • crates/tpt-appfront-core — the UITree AST, the Signal system, routing, stores, resources, forms, virtual scroll, styling, devtools
  • crates/tpt-appfront-macros — view!, rsx! and #[component]
  • crates/tpt-appfront-dom — reactive DOM backend (wasm32)
  • crates/tpt-appfront-canvas — egui and taffy canvas backend (glow renderer)
  • crates/tpt-appfront-tui — terminal backend (ratatui)
  • crates/tpt-appfront-html — semantic HTML backend (SSR and SSG)
  • crates/tpt-appfront-ai-schema — JSON-LD and AI-agent schema backend
  • crates/tpt-appfront-server — Axum smart router. Serves the right backend per client (browser, crawler, AI agent, social bot), plus PWA support and a POST /command bridge
  • crates/tpt-appfront-mcp — MCP server exposing the agent API as JSON-RPC tools over stdio
  • crates/tpt-appfront-webview — desktop shell (wry and tao) hosting the DOM bundle
  • crates/tpt-appfront-templates — starter UIs (login_form, dashboard_shell, settings_list) as plain tree builders
  • crates/tpt-appfront-test — headless test harness and accessibility and AI-affordance linter
  • crates/tpt-appfront-cli — the tpt-appfront CLI (init, dev, build, generate, ingest, benchmark, optimize, doctor, add, fmt, lint, completions)

Examples live in examples/, outside the workspace, each with its own Cargo.toml. They are built in CI. See docs/quickstart.md.

When the UITree model does not fit, see docs/escape-hatches.md for the { expr } composition pattern and the raw-egui escape hatch.

Contributing

This project takes issues only for now. Bug reports and feature requests are welcome; pull requests are not being accepted. See CONTRIBUTING.md.

License

Licensed under either of

at your option.