$ account oldj
SwitchHosts is a cross-platform desktop application for managing the system hosts file (`/etc/hosts`). Built with Tauri (Rust backend) and React (TypeScript frontend), it provides a rich GUI for creating, editing, toggling, and organizing hosts entries into groups, folders, and remote subscriptions. The application supports multiple write modes (append/overwrite), syntax-highlighted editing via CodeMirror, DNS resolution for domain-based entries, import/export with preview and conflict detection, a local HTTP API for third-party integration (e.g., Alfred, Raycast), and a system tray with a mini-window. It also includes a privileged helper daemon on macOS for passwordless writes, atomic file operations with transaction rollback, and crash recovery mechanisms. The architecture follows a clear separation: the Rust backend handles storage (atomic writes, manifest, entries, trashcan, history), hosts application (aggregation, elevation, writing, recovery), DNS resolution, HTTP API server, and system tray lifecycle. The React frontend manages UI state with Jotai, uses Mantine for components, and communicates with the backend via Tauri IPC commands. The codebase is well-tested with unit tests (Vitest, Rust `#[test]`), E2E tests (Playwright), and a shared fixture for append-mode behavior between Rust and JS. Internationalization covers 16 languages with a proxy-based lazy translation system. Key strengths include a robust storage layer with transactional safety, a generic tree component with drag-and-drop, a reusable DNS provider registry, and a find/replace engine with UTF-16 offset handling. The project demonstrates high craftsmanship in data durability (atomic writes, crash recovery tests) and cross-platform considerations (elevation strategies, tray behavior). However, the codebase has some complexity in recovery logic and platform-specific code that may require careful maintenance.