iToverDose/Software· 12 JUNE 2026 · 16:05

Build a 128MB Desktop AI Agent without Electron or SPAs

A new architecture combining lightweight tools replaces bloated frameworks for local AI agents. Discover how to cut app size by 85% while keeping full functionality.

DEV Community4 min read0 Comments

A wave of frustration hit many developers when they realized that modern desktop applications often come with baggage rather than benefits. The trade-offs between Electron’s convenience and its resource hunger, or Tauri’s efficiency and Rust’s steep learning curve, left few ideal options. When local AI agents entered the scene, the problem grew worse: Python’s dominance in AI came with packaging nightmares that alienated non-technical users.

That’s why a new approach emerged—one that strips away the bloat without sacrificing power. The ERTH Stack, built on ElectroBun, Robyn, Turso, and HTMX, delivers a fully functional desktop AI agent in just 128MB. No Chromium. No heavy runtimes. No client-side JavaScript frameworks. Just a lean, local-first system designed for speed, security, and simplicity.

Why Traditional Desktop Stacks Are Failing Developers

Building a cross-platform desktop app used to mean choosing between bloated frameworks and steep learning curves. Electron made it easy to develop but produced applications that consumed hundreds of megabytes of RAM and disk space, even for simple tasks. A basic "Hello World" often ballooned to over 200MB.

Tauri solved the footprint issue by using native WebViews and Rust, but it introduced new hurdles. Developers had to learn Rust, a language known for its strict syntax and steep learning curve, which slowed down rapid prototyping and forced teams to specialize in multiple languages.

For AI-centric applications, Python became the default choice due to its rich ecosystem of machine learning libraries. However, packaging Python applications with their dependencies into a single, double-clickable executable remained a persistent challenge. Non-technical users struggled to install these bundles, and the final package size often exceeded reasonable limits.

These constraints forced developers to make painful trade-offs between performance, usability, and development speed.

The ERTH Stack: A Lightweight, Local-First Architecture

The ERTH Stack reimagines desktop application development by combining four carefully selected technologies into a cohesive, high-performance system. The architecture distributes responsibilities across layers, ensuring minimal overhead while maintaining full functionality.

The stack is structured as follows:

  • ElectroBun (E) acts as the lightweight shell, binding directly to the OS-native WebKit engine on macOS and WebView2 on Windows.
  • Robyn (R), a high-performance Python web framework, runs as a background sidecar process to handle AI logic and database operations.
  • Turso (T), a local-first database based on libSQL, stores data in a physical file with near-instant query performance and seamless cloud-edge sync.
  • HTMX (H) replaces heavy frontend frameworks with hypermedia-driven UI components, eliminating client-side JavaScript while enabling dynamic updates.

This heterogeneous design allows each component to specialize in its role, avoiding the overhead of monolithic frameworks like Electron.

Breaking Down the ERTH Components

ElectroBun: A Minimalist UI Shell

Electron’s reliance on Chromium has long been a sore point for developers seeking efficiency. ElectroBun replaces Chromium with the native WebKit engine, drastically reducing memory usage and startup time. The main process runs on Bun, a fast JavaScript runtime, enabling near-instant launches while keeping idle memory consumption to a fraction of traditional desktop apps.

Robyn: The Python Sidecar Engine

Python remains the language of choice for AI orchestration, but running it directly in the main process can introduce instability. Robyn solves this by acting as a sidecar process managed by the Bun shell. It handles AI inference, local LLM loading, and database operations through a lightweight HTTP interface. By dynamically assigning a port at runtime, Robyn avoids conflicts and ensures smooth operation even when multiple instances are running.

Turso: Local-First Database with Cloud Sync

The database layer uses Turso, a SQLite-compatible solution optimized for local-first applications. Data is stored in a local file (local_edge.db) with query latencies as low as 0.1ms. A background thread continuously syncs incremental changes to the Turso cloud database, ensuring offline resilience and seamless recovery when connectivity is restored.

HTMX: Hypermedia UI Without the Bloat

Client-side frameworks like React and Vue have dominated frontend development, but they come with their own set of challenges—bundle sizes, state management, and build tool complexity. HTMX shifts the paradigm by treating the UI as a hypermedia receiver. The backend renders HTML fragments, which HTMX swaps into the DOM dynamically. This eliminates the need for client-side JavaScript, reducing both complexity and performance overhead.

Overcoming the Debugging Challenges

Building a cross-language, cross-process application is no small feat, and the ERTH Stack faced several technical hurdles during development.

  • Watchdog Self-Healing: The Bun main process and Python sidecar operate independently, raising the risk of crashes. A watchdog system was implemented to probe the Python backend every three seconds. If a crash is detected, the watchdog triggers a silent restart and reassigns a new dynamic port, ensuring uninterrupted service.
  • Preflight Request Management: HTMX sends cross-origin requests with custom headers, triggering mandatory OPTIONS preflight checks. To prevent deadlocks, Robyn’s Rust-based core was configured to bypass authentication middleware for these preflight requests.
  • Port Security: To prevent unauthorized access to the Python sidecar, communication is safeguarded using UUIDv7 short-lived tokens. These tokens are injected during startup and verified before any IPC or HTTP requests are processed.

Building the Future of Local-First AI Agents

The ERTH Stack proves that high-performance, secure, and user-friendly desktop applications no longer require compromises. By leveraging lightweight tools and a modular architecture, developers can create AI agents that run efficiently on local hardware while maintaining cloud connectivity.

The open-source implementation is available on GitHub, inviting developers to experiment, contribute, and adapt the stack for their own projects. For those interested in a deeper dive, an engineering blueprint is available in the book ERTH Assistant: Local-First + AI Sidecar Desktop Architecture, complete with step-by-step guides, code samples, and platform-specific optimizations.

The future of desktop development is local-first, lightweight, and developer-friendly. With stacks like ERTH, the era of bloated applications is coming to an end.

AI summary

Yerel AI ajanları için devrim niteliğinde ERTH Stack mimarisi hakkında detaylı rehber. Elektron’un yükünden kurtulun, yerel tabanlı ve yüksek performanslı masaüstü uygulamaları keşfedin.

Comments

00
LEAVE A COMMENT
ID #5PCGNS

0 / 1200 CHARACTERS

Human check

4 + 3 = ?

Will appear after editor review

Moderation · Spam protection active

No approved comments yet. Be first.