Hojicha
The Elm Architecture for Terminal UIs in Rust
Hojicha implements The Elm Architecture for terminal applications. Built on Ratatui, inspired by Bubbletea.
Features
- Simple Architecture - Model-View-Update pattern
- High Performance - Priority event processing with adaptive queues
- Async Native - First-class async/await, cancellation, streams
- Component Library - Pre-built UI components
- Testing Utilities - Headless mode, deterministic testing
- Metrics - Built-in performance monitoring
Installation
[]
= "0.2" # Includes core + runtime
# Or if you want components:
# hojicha = { version = "0.2", features = ["pearls"] }
Or use individual crates if you need fine-grained control:
[]
= "0.2"
= "0.2"
= "0.2" # Optional: UI components
Quick Start
use *;
use ;
Architecture
The Elm Architecture consists of:
| Component | Purpose |
|---|---|
| Model | Application state |
| Message | Events that trigger state changes |
| Update | Handle events and update state |
| View | Render UI from state |
| Command | Side effects (async operations, I/O) |
Common Patterns
Async Operations
Timers
Stream Subscriptions
let stream = websocket.messages.map;
let subscription = program.subscribe;
Components
Available via hojicha-pearls:
Input: TextInput, TextArea, Button
Display: List, Table, Tabs, Modal, ProgressBar, Spinner
Layout: Grid, FloatingElement, StatusBar, Viewport
Testing
Performance Metrics
let program = new?
.with_priority_config;
// Export metrics
program.metrics_json;
program.metrics_prometheus;
Advanced Features
Priority Event Processing
- Critical: Quit, suspend
- High: User input (keyboard, mouse)
- Normal: User messages, timers
- Low: Resize, background tasks
Cancellable Operations
let handle = program.spawn_cancellable;
Documentation
- Cookbook - Real-World Patterns ⭐ NEW!
- Common Patterns
- Architecture Guide
- Development Guide
- Testing Guide
- API Reference
Examples
# Progressive Tutorial Series (Start Here!)
# Complete Applications
# Feature Examples
See examples/README.md for the complete list and learning path.
Contributing
See CONTRIBUTING.md.
License
GPL-3.0