How abdenasser/neohtop works
Major Components
• Frontend (UI):
• Built using SvelteKit with TypeScript and organized under the "src" directory.
• Contains UI elements/components (in “src/lib/components” such as AppInfo, Toolbar, Stats panels, modals, etc.) to render process data, system statistics, search/filter functionality, and theming.
• Backend (System Monitoring and Process Management):
• Implemented in Rust and managed via Tauri.
• Resides in the "src-tauri" directory – includes modules for commands (commands.rs), monitoring system and process details (monitoring folder with process_monitor.rs, system_monitor.rs, etc.), and UI bridge (in the ui folder for window management).
• Application Shell & Integration:
• Tauri config (tauri.conf.json and Cargo configs) coordinates communication between the frontend and backend.
• The integration leverages Tauri’s API to allow the SvelteKit frontend to call backend commands (using IPC mechanisms offered by Tauri).
Relationships and Data Flow
• The frontend, built in Svelte, interacts with the backend via Tauri’s command invocation system. This is the primary communication channel.
• User actions (e.g., performing a process search, refreshing stats, or executing process kill commands) trigger events in the Svelte components, which then call the underlying Rust commands.
• The Rust backend is responsible for querying system metrics (CPU, memory usage, process list) and managing process state. Once data is processed, it is sent back to the frontend for rendering.
• Showing arrowed two-way communications, where the frontend requests data to be fetched or a process to be manipulated, and the backend pushes updates to the UI.
Architectural Patterns and Design Principles
• Separation of Concerns: There is a clear split between the UI logic (presentation) and system-level operations (business logic / system monitoring).
• Modularization: Both the frontend (with distinct components for toolbars, stats, modals) and backend (with separate modules for commands, process monitoring, and UI integration) exhibit high cohesiveness.
• Use of IPC (Inter-Process Communication): The design relies on Tauri continuously bridging JS and Rust code, ensuring smooth data flow.
Technologies and Frameworks
• Frontend:
• SvelteKit, Svelte, TypeScript, CSS (with custom theming via variables)
• Vite as a bundler (configuration shown in vite.config.js)
• Backend:
• Rust, Tauri framework (with its configuration in tauri.conf.json and Cargo.toml)
• Additional tooling/configuration:
• Prettier for code formatting, Husky for git hook enforcement, and GitHub Actions for CI/CD workflows.