Skip to content

naranyala/starter-rust-webuiangular-rspack

Repository files navigation

Rust WebUI + Angular + Rspack Starter

Rust Angular Biome License

Build desktop-class applications with modern web technologies and Rust performance. A production-ready starter template featuring Clean Architecture, MVVM pattern, comprehensive error handling, connection pooling, and an integrated DevTools panel.


πŸš€ Quick Start

# Clone and run
git clone <repository-url>
cd starter-rust-webuiangular-rspack
./run.sh

Common Commands

./run.sh --build            # Build frontend + backend
./run.sh --build-frontend   # Build frontend only
./run.sh --build-rust       # Build backend only
./run.sh --release          # Build optimized release
./run.sh --run              # Run existing build
./run.sh --clean            # Clean artifacts
./run.sh --rebuild          # Clean + rebuild
./run.sh --help             # Show all options

✨ Features

πŸ—οΈ Architecture

  • Clean Architecture (Rust backend) - Domain, Application, Infrastructure, Presentation layers
  • MVVM Pattern (Angular frontend) - Models, ViewModels, Views separation
  • Event-Driven Design - Pub/sub event bus for decoupled communication
  • Plugin System - Extensible architecture for custom functionality

πŸ¦€ Backend (Rust)

  • WebUI Integration - Native desktop windowing without Electron overhead
  • SQLite Database - Embedded database with connection pooling (r2d2)
  • Enhanced Error Handling - Panic hooks, error tracking, terminal output
  • Comprehensive Logging - Multi-sink logging with JSON formatting
  • Cross-Platform - Windows, macOS, Linux support
  • Serialization - JSON, MessagePack, CBOR support via serde

🎨 Frontend (Angular)

  • Angular 21.1.5 - Latest Angular with Signals and modern features
  • Rspack Bundler - 10x faster builds than webpack
  • Biome Linter - Fast Rust-based linting and formatting
  • Error Interceptor - Global error catching and reporting
  • Event Bus Service - Reactive event management
  • DevTools Panel - Comprehensive debugging interface (5 tabs)

πŸ”§ Developer Experience

  • Hot Module Replacement - Fast development with live reload
  • Type Safety - Full TypeScript typing with strict mode
  • Code Quality - Biome linting and formatting enforced
  • Build Orchestration - Automated build pipelines
  • Configuration - TOML-based configuration management

πŸ“š Documentation

Document Description
πŸ“– Getting Started Installation, setup, and first run
πŸ›οΈ Architecture System architecture and design patterns
πŸ“¦ Project Structure Repository layout and organization
πŸ”¨ Build System Build pipeline and deployment
πŸ”Œ Communication Frontend-backend IPC patterns
⚠️ Error Handling Comprehensive error handling guide
πŸ”§ Biome Setup Linter and formatter configuration
πŸ“Š Connection Pooling Database pooling implementation
πŸ“‹ Dependencies Complete dependency reference
🎯 Improvements Suggested enhancements

πŸ—οΈ Project Structure

starter-rust-webuiangular-rspack/
β”‚
β”œβ”€β”€ πŸ“„ Cargo.toml                 # Rust package manifest
β”œβ”€β”€ πŸ“„ Cargo.lock                 # Dependency lock file
β”œβ”€β”€ πŸ“„ build.rs                   # Cargo build script
β”œβ”€β”€ πŸ“„ run.sh                     # Main run script
β”œβ”€β”€ πŸ“„ build-frontend.js          # Frontend build orchestration
β”œβ”€β”€ πŸ“„ build-dist.sh              # Distribution builder
β”œβ”€β”€ πŸ“„ post-build.sh              # Post-build processing
β”‚
β”œβ”€β”€ πŸ“‚ src/                       # Rust backend source
β”‚   β”œβ”€β”€ main.rs                   # Application entry point
β”‚   β”œβ”€β”€ utils_demo.rs             # Utility demonstrations
β”‚   β”‚
β”‚   └── πŸ“‚ core/                  # Clean Architecture
β”‚       β”œβ”€β”€ domain/               # Business entities & traits
β”‚       β”œβ”€β”€ application/          # Use cases & handlers
β”‚       β”œβ”€β”€ infrastructure/       # DB, logging, config, DI
β”‚       β”‚   β”œβ”€β”€ database/         # SQLite with connection pooling
β”‚       β”‚   β”œβ”€β”€ logging/          # Multi-sink logging
β”‚       β”‚   β”œβ”€β”€ error_handler.rs  # Enhanced error handling
β”‚       β”‚   └── di.rs             # Dependency injection
β”‚       └── presentation/         # WebUI integration
β”‚           └── webui/handlers/   # Event handlers
β”‚
β”œβ”€β”€ πŸ“‚ frontend/                  # Angular frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.ts               # Angular entry point
β”‚   β”‚   β”œβ”€β”€ index.html            # HTML template
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ views/             # Angular components
β”‚   β”‚   β”‚   β”œβ”€β”€ app.component.ts  # Root component
β”‚   β”‚   β”‚   β”œβ”€β”€ home/             # Home feature
β”‚   β”‚   β”‚   β”œβ”€β”€ demo/             # Demo feature
β”‚   β”‚   β”‚   └── devtools/         # πŸ› οΈ DevTools panel
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ viewmodels/        # MVVM ViewModels
β”‚   β”‚   β”‚   β”œβ”€β”€ event-bus.viewmodel.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ logging.viewmodel.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ window-state.viewmodel.ts
β”‚   β”‚   β”‚   └── error-dashboard.viewmodel.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ core/              # Core services
β”‚   β”‚   β”‚   β”œβ”€β”€ global-error.handler.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ global-error.service.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ error-interceptor.ts
β”‚   β”‚   β”‚   └── winbox.service.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ models/            # Data models
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ types/             # TypeScript types
β”‚   β”‚   └── πŸ“‚ environments/      # Environment configs
β”‚   β”‚
β”‚   β”œβ”€β”€ angular.json              # Angular CLI config
β”‚   β”œβ”€β”€ rspack.config.js          # Rspack bundler config
β”‚   β”œβ”€β”€ biome.json                # Biome linter config
β”‚   β”œβ”€β”€ tsconfig.json             # TypeScript config
β”‚   └── package.json              # NPM dependencies
β”‚
β”œβ”€β”€ πŸ“‚ config/                    # Runtime configuration
β”‚   └── app.config.toml           # Application config
β”‚
β”œβ”€β”€ πŸ“‚ docs/                      # Documentation
β”‚   β”œβ”€β”€ 01-introduction.md
β”‚   β”œβ”€β”€ 02-architecture.md
β”‚   β”œβ”€β”€ 03-build-system.md
β”‚   β”œβ”€β”€ 04-communication.md
β”‚   β”œβ”€β”€ 05-dependencies.md
β”‚   β”œβ”€β”€ 06-improvements.md
β”‚   β”œβ”€β”€ 07-getting-started.md
β”‚   β”œβ”€β”€ 08-project-structure.md
β”‚   β”œβ”€β”€ 09-errors-as-values.md
β”‚   └── REFACTORING_CONNECTION_POOLING.md
β”‚
β”œβ”€β”€ πŸ“‚ thirdparty/                # Third-party libraries
β”‚   └── webui-c-src/              # WebUI C source
β”‚
└── πŸ“‚ static/                    # Static assets (runtime)
    β”œβ”€β”€ js/
    └── css/

πŸ› οΈ Technology Stack

Backend

Technology Version Purpose
Rust 1.93+ Core language
WebUI 2.5.0-beta.4 Desktop windowing
SQLite 0.32 Embedded database
r2d2 0.8 Connection pooling
serde 1.0 Serialization
log 0.4 Logging facade
backtrace 0.3 Stack traces

Frontend

Technology Version Purpose
Angular 21.1.5 UI framework
TypeScript 5.9 Type safety
Rspack 1.7.6 Bundler
Biome 2.4.4 Linter/formatter
Bun 1.3 Package manager
WinBox 0.2.82 Window management
RxJS 7.8.2 Reactive extensions

Build Tools

Tool Purpose
Cargo Rust build system
Angular CLI Angular build tool
Rspack Fast webpack-compatible bundler
Biome Fast linter and formatter

🎯 Key Capabilities

Desktop Application Features

  • Native window management with WinBox integration
  • System information monitoring
  • File system operations
  • Database CRUD operations
  • Real-time event bus communication

Developer Tools

  • DevTools Panel (5 tabs):

    • πŸ–₯️ Backend - Stats, logs, bindings
    • 🎨 Frontend - Events, errors, memory
    • πŸ“‘ Events - Event history and payloads
    • 🌍 Environment - Browser info, features
    • ⚑ Actions - Test scenarios, benchmarks
  • Error Dashboard - Visual error tracking

  • Console Logging - Structured error output

  • Performance Benchmarks - Event bus, signals

Data Management

  • SQLite database with connection pooling
  • User management (CRUD operations)
  • Event history tracking
  • Log aggregation and retrieval

πŸ“¦ Installation

Prerequisites

  • Rust 1.93+ (install)
  • Bun 1.3+ (install)
  • Node.js 18+ (optional, Bun can be used instead)

Setup

# Clone repository
git clone <repository-url>
cd starter-rust-webuiangular-rspack

# Install frontend dependencies
cd frontend
bun install

# Build and run
cd ..
./run.sh

Platform-Specific Requirements

Linux

# WebKit2GTK (required for WebUI)
sudo apt install libwebkit2gtk-4.1-dev  # Debian/Ubuntu
sudo dnf install webkit2gtk4.1-devel   # Fedora

macOS

# Xcode Command Line Tools
xcode-select --install

Windows

# Visual Studio Build Tools
# WebView2 runtime (included in Windows 10+)

πŸ”§ Configuration

Application Config (config/app.config.toml)

[app]
name = "Rust WebUI SQLite Demo"
version = "1.0.0"

[window]
title = "Rust WebUI Application"
width = 1280
height = 800

[database]
path = "app.db"
create_sample_data = true

[logging]
level = "info"
file = "logs/application.log"
append = true

[communication]
transport = "webview_ffi"
serialization = "json"

Environment Variables

Variable Description Default
RUST_LOG Log level info
RUSTWEBUI_DIST_DIR Custom dist directory ./dist

πŸ§ͺ Testing

Backend Tests

cd frontend
cargo test

Frontend Tests

cd frontend
bun run test

Linting

cd frontend
bun run lint      # Check
bun run lint:fix  # Auto-fix

Formatting

cd frontend
bun run format      # Check
bun run format:fix  # Auto-fix

πŸš€ Deployment

Development Build

./run.sh --build

Release Build

./run.sh --release

Distribution Package

./build-dist.sh build-release

Output will be in target/release/ with platform-specific packaging.


πŸ› Troubleshooting

Common Issues

Build Fails with "module not found"

# Clean and rebuild
./run.sh --clean
./run.sh --rebuild

Frontend Build Errors

# Reinstall dependencies
cd frontend
rm -rf node_modules bun.lock
bun install

Database Errors

# Remove and recreate database
rm app.db
./run.sh

WebUI Window Not Showing

  • Ensure WebKit2GTK is installed (Linux)
  • Check WebView2 runtime (Windows)
  • Verify port is not in use

Getting Help

  1. Check documentation
  2. Review ERROR_HANDLING_GUIDE.md
  3. Inspect application logs in logs/application.log
  4. Check DevTools panel for runtime errors

πŸ“ License

MIT License - See LICENSE file for details.


🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

Code Quality Standards

  • All code must pass bun run lint and bun run format
  • Backend code must pass cargo clippy
  • New features should include tests
  • Documentation should be updated for API changes

πŸ“Š Performance Benchmarks

Metric Value Notes
Frontend Build Time ~30s Production build
Backend Build Time ~45s Debug profile
Cold Start Time ~2s First launch
Memory Usage ~50MB Idle application
Event Bus Throughput 10,000+ events/sec Benchmark test

🎯 Roadmap

Completed

  • βœ… Clean Architecture implementation
  • βœ… MVVM frontend pattern
  • βœ… Connection pooling (r2d2)
  • βœ… Enhanced error handling
  • βœ… DevTools panel
  • βœ… Biome linting setup

In Progress

  • πŸ”„ Integration testing framework
  • πŸ”„ Performance monitoring
  • πŸ”„ Plugin marketplace

Planned

  • ⏳ WebSocket transport layer
  • ⏳ Multi-window support
  • ⏳ Theme customization
  • ⏳ Auto-update mechanism

Built with ❀️ using Rust and Angular

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published