Odin is organized around commands, services, strongly typed models, platform integrations, and terminal UI.
src/
commands/ CLI command handlers (snapshot, restore, sync, ports, ps, kill, etc.)
core/ application context and typed errors
integrations/ Windows tools, Git, GitHub, PowerShell, VS Code, Process management
models/ serde-compatible snapshot and config types
services/ snapshot, restore, sync, config, secrets, storage, process management
ui/ Ratatui dashboard views (main dashboard, process dashboard)
utils/ filesystem, logging, checksums, banner, terminal helpers
Thin CLI handlers that parse arguments and delegate to services.
Environment & Snapshot:
snapshot.rs- Capture machine staterestore.rs- Restore from snapshotdiff.rs- Compare live vs snapshotexport.rs- Generate restore scriptsinit.rs- Initialize config
Process & Port Management:
ports.rs- List listening ports with process infops.rs- Launch interactive process dashboardkill.rs- Kill processes by port/PID
Diagnostics & Sync:
dashboard.rs- Show status dashboarddoctor.rs- Health checksync.rs- GitHub backupconfig.rs- Configuration managementupdate.rs- Check and install updates
Core business logic and workflows.
State Management:
snapshot_service.rs- Collect machine state, generate restore scriptsrestore_service.rs- Read snapshots and stage package installsstorage.rs(SnapshotStore) - Canonical snapshot file paths and persistencesync_service.rs- Git repo management and GitHub integration
Configuration & Secrets:
config_service.rs- Manageconfig.yamlsecret_service.rs- Store GitHub token in OS credential storeupdate_service.rs- Check GitHub Releases, download updates
Diagnostics:
doctor_service.rs- Health checks and diagnosticsdiff_service.rs- State comparison
NEW - Process Management:
process_service.rs- Port/process discovery and managementget_listening_ports()- List all listening ports via netstatfind_process_by_pid()- Lookup process infokill_process()- Safe process terminationget_all_processes()- Snapshot all running processes with resource metrics
Platform-specific code for Windows, Git, GitHub, and system tools.
Windows System Integrations:
process.rs- NEW: netstat parsing, taskkill execution, sysinfo cachingget_listening_ports()- Parse netstat output, resolve process names (50-100x faster with sysinfo caching)find_process_by_port()- Find PID from portkill_process_by_id()- Execute taskkill /PIDProcessInfo,PortInfodata models
package_managers.rs- winget, Chocolatey, Scoop discoveryvscode.rs- VS Code and extension discoverypowershell.rs- PowerShell profile discoverywindows_terminal.rs- Windows Terminal settingsprocess.rs- General process execution with exit code handling
Git & GitHub:
git.rs- Git config discovery and restorationgithub.rs- GitHub API for releases and syncsync.rs- Push snapshots as git commits
Strongly-typed serde models for snapshot and config data.
Snapshot Models:
machine.rs- OS, CPU, memory, disk infoenvironment.rs- Environment variables, PATHpackages.rs- Package manager datagit.rs- Git configurationvscode.rs- VS Code extensions
NEW - Process Models:
process.rsProcessInfo- PID, name, status, resource usagePortInfo- Port, protocol, address, associated processProcessStats- CPU %, memory, threads, status
Configuration Models:
config.rs- User configuration structurereport.rs- Doctor/diff report output
Ratatui-based interactive terminal dashboards.
Main Dashboard:
dashboard.rs- Status overview with snapshot metadata
NEW - Process Dashboard:
process_dashboard.rs- Interactive process monitor (htop-style)- Real-time process list with sorting/filtering
- Keyboard controls (arrow keys, K to kill, 1-4 to sort)
- Resource metrics (CPU %, memory, threads)
- Safe process killing with confirmation
- 500ms refresh rate for live updates
Helper functions and terminal utilities.
filesystem.rs- Directory/file operationslogging.rs- Structured loggingchecksum.rs- File integrity verification- NEW -
banner.rs- Colorful ASCII art banner with command list terminal.rs- Terminal detection and helpers
Command Layer
ports.rs ─→ ProcessService ─→ Integration Layer
ps.rs ─→ ProcessService ─→ Integration Layer
kill.rs ─→ ProcessService ─→ Integration Layer
ProcessService (business logic)
├─ get_listening_ports() ──→ process::get_listening_ports()
├─ find_process_by_pid() ──→ sysinfo::System
├─ kill_process() ──→ process::kill_process_by_id()
└─ get_all_processes() ──→ sysinfo::System
Integration Layer (Windows system calls)
├─ netstat -ano (parse port output)
├─ taskkill /PID /F (kill process)
├─ sysinfo::System (efficient process metrics cache)
└─ WMI via PowerShell (process name resolution)
UI Layer (if interactive)
└─ process_dashboard.rs ──→ ratatui rendering ──→ terminal
Command Layer
snapshot.rs ──→ SnapshotService ──→ Integrations ──→ Storage
SnapshotService (orchestration)
├─ collect_machine_info()
├─ collect_packages()
├─ collect_vscode()
├─ collect_git()
└─ generate_restore_scripts()
Integrations (discovery)
├─ package_managers (winget, choco, scoop)
├─ vscode (VS Code extensions)
├─ git (config files)
└─ windows_terminal (settings)
Storage (SnapshotStore)
├─ machine.json
├─ packages.json
├─ vscode_extensions.json
├─ git_config.json
└─ restore.ps1
- Integration layer isolated under
integrations/for future Linux/macOS support - Platform-specific code doesn't leak into services or models
- Snapshot models are platform-agnostic
odin restoreis dry-run by default (--applyrequired)odin killrequires--forceflag- Interactive mode is explicit (TUI dashboards)
- No destructive operations without confirmation
- Uses
sysinfocrate for cached process metrics (50-100x faster than WMI queries per-process) - netstat stdout parsing for port discovery
- Smart caching layer to avoid redundant system calls
- All snapshot data is serde-compatible JSON
- Config is YAML (human-editable, type-safe struct)
- Reports are JSON-compatible for scripting
- No stringly-typed data in core logic
- Services expose clean, single-responsibility functions
- Integrations are pluggable (new tool = new integration module)
- UI components are isolated from business logic
- Commands are thin dispatchers (no business logic in handlers)
- Create
src/commands/my_command.rswith handler function - Add command enum variant to
src/cli.rs - Add args struct if needed
- Call
MyService::do_something()from command handler - Return result (text or JSON)
- Create
src/services/my_service.rs - Implement struct with public functions
- Call integrations as needed
- Return strongly-typed models
- Export from
src/services/mod.rs
- Create
src/integrations/my_tool.rs - Implement tool discovery/management
- Return integration-specific models or errors
- Call from services, not commands
- Export from
src/integrations/mod.rs
- Language: Rust 2021 edition
- CLI: Clap for argument parsing
- TUI: Ratatui for interactive dashboards
- System: sysinfo for process/system metrics
- Serialization: serde with JSON/YAML
- Colors: colored crate for terminal colors
- Async: tokio for async workflows
- Process: subprocess via std::process with PowerShell fallback
Windows integration is centralized and isolated, making Linux and macOS support straightforward when needed.