How dukedesouth/portwatch works
portwatch is a terminal port and process monitor. Its main workflow scans listening ports, enriches them with process metrics, classifies them by service and risk, and presents a refreshable interactive view with filtering, sorting, and confirmed process termination. The CLI also supports JSON and direct-kill modes, plus demo data. The process-enrichment implementation was not sampled, so its internal data sources are not shown.
Main entry points: app.tsx Interactive app · cli.tsx CLI modes · PortTable.tsx Port table · usePortData.ts Refresh and state
Components 16
CLI and interaction
- CLI modes
src/cli.tsx - Interactive app
src/app.tsx
Port discovery
- Refresh and state
src/hooks/usePortData.ts - Listening-port scan
src/services/ports.ts
Enrichment and classification
- Process enrichment
src/services/processes.ts - Service and risk catalog
src/services/portdb.ts
Terminal presentation
- Status header
src/components/Header.tsx - Port table
src/components/PortTable.tsx - Shortcut bar
src/components/StatusBar.tsx - Kill confirmation
src/components/KillConfirm.tsx - JSON output
src/cli.tsx
Demo and termination
- Sample port data
src/services/demo.ts - Process termination
src/services/killer.ts
Other components
- Terminal user
- OS port utilities
- Terminal display
Connections 24
- Terminal user → CLI modes: runs
- CLI modes → Interactive app: renders TUI
- CLI modes → Listening-port scan: scans ports
- CLI modes → Process enrichment: enriches data
- CLI modes → Service and risk catalog: classifies ports
- CLI modes → Process termination: kills process
- CLI modes → JSON output: prints JSON
- Refresh and state → Listening-port scan: scans ports
- Refresh and state → Process enrichment: enriches data
- Listening-port scan → OS port utilities: queries listeners
- Interactive app → Refresh and state: reads refreshed data
- Interactive app → Sample port data: loads sample data
- Interactive app → Service and risk catalog: counts risk levels
- Interactive app → Process termination: kills selected process
- Interactive app → Status header: supplies status
- Interactive app → Port table: supplies port rows
- Interactive app → Shortcut bar: supplies filter state
- Interactive app → Kill confirmation: shows confirmation
- Port table → Service and risk catalog: looks up metadata
- Status header → Terminal display: renders status
- Port table → Terminal display: renders ports
- Shortcut bar → Terminal display: renders shortcuts
- Kill confirmation → Terminal display: renders prompt
- JSON output → Terminal display: prints result