Windows-based real-time port inspection CLI tool
Project description
๐ Portviz
Modern Port & Process Inspector for Developers โ CLI + VS Code Extension
Portviz is a developer-focused tool for inspecting active network ports, identifying bound processes, monitoring service changes in real time, and safely terminating processes. Available as both a Python CLI and a fully-featured VS Code extension with a rich interactive dashboard.
It eliminates the need for OS-specific commands like netstat, lsof, or taskkill and provides a unified workflow for managing ports โ whether from the terminal or directly inside your editor.
๐ Vision
Portviz is being built in structured phases:
- โ Core port inspection engine (Python)
- โ Production-ready CLI with rich output and JSON streaming
- โ VS Code extension with interactive dashboard, snapshots, orchestration, and live monitoring
- ๐ Cross-platform abstraction (Windows โ macOS/Linux expansion)
- ๐ Project-level orchestration and service topology visualization
The long-term goal is to evolve Portviz into a modular developer utility that integrates seamlessly into modern development workflows.
๐ฏ Problem It Solves
During development, port conflicts are a constant frustration:
- ๐ด "Port already in use" errors interrupt your workflow
- ๐ Finding the culprit requires memorizing OS-specific commands
- ๐ Killing processes safely demands careful PID lookups
- ๐ Managing multiple services across different ports is tedious
Traditional Approach
| Platform | Find Process | Kill Process |
|---|---|---|
| macOS/Linux | lsof -i :3000 |
kill -9 <PID> |
| Windows | netstat -ano | findstr :3000 |
taskkill /PID <PID> /F |
The Portviz Way
portviz port 3000 # Find what's using port 3000
portviz kill --port 3000 # Kill it with one command
portviz watch # Monitor all services in real-time
Or just open the Portviz sidebar in VS Code โ see everything at a glance, kill processes with a click, and manage your entire service stack visually.
๐ฆ Installation
CLI โ Via pip (Recommended)
pip install portviz
CLI โ From Source
git clone https://github.com/aadish-25/portviz.git
cd portviz
pip install -e .
VS Code Extension
The extension is bundled in the vscode-extension/ directory. To install locally:
cd vscode-extension
npm install
npm run build
npx @vscode/vsce package
Then install the generated .vsix file in VS Code via Extensions โ Install from VSIX.
Verify CLI Installation
portviz --version
โจ Current Features (v1.0.2)
๐ Port Inspection (CLI)
- Full port report with detailed information
- Summarized port statistics
- LISTEN-only filtering
- Public vs local-only port detection
- Dual-stack (IPv4 + IPv6) detection
- Per-port inspection and analysis
๐ง Process Management (CLI + Extension)
- Kill by PID with safety checks
- Kill by port (auto-detect associated processes)
- Structured termination results
- Safe PID mapping and verification
- Auto-restart detection for Windows services
๐ธ Snapshot System (CLI + Extension)
- Save current port state to disk
- List all saved snapshots with metadata
- Diff snapshots to detect changes (new/closed services)
- Track service changes between snapshots
- Compare any two snapshots or snapshot vs live state (Extension)
- Rename and delete snapshots (Extension)
- Grouped diff view by process (Extension)
- Configurable max snapshot limit (Extension)
๐ Real-Time Monitoring (CLI + Extension)
- Live dashboard mode with Rich-based UI (CLI)
- Stream mode for lightweight monitoring (CLI)
- NDJSON streaming for automation pipelines (CLI)
- Event-based service start/stop detection
- Auto-refresh with configurable interval (Extension)
- Live CPU and memory usage per process (Extension)
- Highlight animation on newly-appeared PIDs (Extension)
๐งพ JSON Support (CLI)
All major CLI commands support structured JSON output for:
- Automation and scripting
- Logging and auditing
- External integrations
- Tool chaining and pipelines
๐ VS Code Extension
A fully-featured extension with a four-tab interactive dashboard:
๐ Overview Tab
- Summary cards: listening ports, public ports, process count, UDP ports
- Risk insight section showing publicly-exposed services ranked by severity
- Last-updated timestamp
๐ด Live Tab
- Expandable process list with PID, port count, and live CPU/memory badges
- Per-port details: protocol, bind address, public/local badge
- Auto-detected framework hints (~40 frameworks by process name, ~15 by port)
- Filter controls: hide system processes, public-only, show UDP
- Sort by name, PID, or port count
- One-click kill with confirmation dialog
- Open in browser for TCP ports
๐ธ Snapshots Tab
- Save, rename, and delete named snapshots
- Compare any two snapshots with grouped diff view
- Compare snapshot vs current live state
- Swap compare selections
โ๏ธ Orchestration Tab
- Auto-detect running services by matching ports/processes against known patterns
- Create/edit/duplicate/delete service definitions with:
- Service name, role, port, working directory
- Start commands and environment variables
- Group/stack assignment
- Start/stop services via integrated VS Code terminals
- Service stacks โ group related services, bulk start, ungroup, or delete
- Status tracking: running / starting / stopped / error
- Timeout detection for service startup
- Free-text search/filter across services
๐ Notifications
- Port opened / port closed toast alerts (configurable)
- Public port (
0.0.0.0) exposure warnings (on by default) - Watch list: get alerts when specific ports go up or down
- Service start timeout errors
- Kill result confirmations
โ๏ธ Configuration Options
| Setting | Default | Description |
|---|---|---|
portviz.autoRefreshInterval |
5s |
Live tab auto-refresh interval |
portviz.cliTimeout |
15s |
CLI call timeout |
portviz.serviceStartTimeout |
30s |
Max wait for service to appear on its port |
portviz.maxSnapshots |
15 |
Maximum saved snapshots |
portviz.notifications.portOpened |
false |
Toast when a new port starts listening |
portviz.notifications.portClosed |
false |
Toast when a port stops listening |
portviz.notifications.publicPort |
true |
Warning when a port binds to 0.0.0.0 |
portviz.resourceMonitor.enabled |
true |
Enable per-process CPU/memory polling |
portviz.resourceMonitor.refreshInterval |
10s |
Resource monitor poll interval |
๐๏ธ Architecture Overview
Portviz follows a layered, modular architecture designed for extensibility:
1๏ธโฃ Core Engine (Python)
- OS detection and platform abstraction
- System command execution (
netstat -ano) - Raw output parsing and structured data normalization
- Port summary generation
- Safe process termination
2๏ธโฃ CLI Layer (Python)
- Argparse-based command routing
- Rich-formatted terminal dashboard
- JSON output serialization
- Snapshot management commands
- Watch/event streaming modes
3๏ธโฃ Storage Layer (Python)
- Snapshot persistence via
platformdirs - OS-specific user data directories
- Structured snapshot diffing
4๏ธโฃ VS Code Extension (TypeScript)
- Webview-based dashboard with four tabs
- CLI integration via child process spawning
- Service orchestration with terminal management
- Resource monitoring (CPU/memory per PID)
- Notification system with change detection
- Snapshot management with visual diffs
This separation ensures the core engine is reusable across both CLI and IDE contexts.
๐ง How It Works
- Detect operating system (Windows, macOS, Linux)
- Execute appropriate networking command:
- Windows โ
netstat -ano - macOS/Linux โ
lsof -i -P -n(planned)
- Windows โ
- Capture and parse raw output
- Structure into typed objects:
- Protocol (TCP/UDP)
- Local IP and Port
- Foreign IP and Port
- Connection State
- Process ID (PID)
- Process Name
- Normalize into internal models
- Provide CLI, snapshot, or streaming output
- Allow safe termination via PID mapping
The VS Code extension calls the CLI with --json and renders the structured data in the webview dashboard.
๐ฅ๏ธ Usage Examples
CLI โ Basic Commands
# Show full port report
portviz report
# Get JSON output for automation
portviz report --json
# View port summary statistics
portviz summary
# List only listening ports
portviz list
# Show public (externally accessible) ports
portviz list --public
# Show local-only listening ports
portviz list --local
# Inspect a specific port
portviz port 3000
# Kill process by PID
portviz kill --pid 12345
# Kill all processes using port 3000
portviz kill --port 3000
CLI โ Snapshot Management
# Save current port state
portviz snapshot save
# List all snapshots
portviz snapshot list
# Diff last two snapshots (detect changes)
portviz snapshot diff
# Diff specific snapshots
portviz snapshot diff snapshot1.json snapshot2.json
CLI โ Real-Time Monitoring
# Watch ports in live dashboard mode
portviz watch
# Stream port events (lightweight)
portviz watch --stream
# Stream events in JSON format
portviz watch --stream --json
VS Code Extension
- Open the Portviz sidebar from the Activity Bar
- Browse running ports in the Live tab
- Click any process to expand port details
- Use the Kill button to terminate processes
- Save snapshots and compare them in the Snapshots tab
- Define and manage services in the Orchestration tab
- Check the Overview tab for risk insights on public-facing ports
๐งฉ Project Structure
portviz/
โ
โโโ pyproject.toml # Python project config
โโโ README.md
โโโ LICENSE
โ
โโโ portviz/ # Python CLI package
โ โโโ __init__.py
โ โโโ __main__.py # Entry point
โ โโโ version.py # Version management
โ โโโ services.py # Data collection orchestration
โ โ
โ โโโ actions/ # Process actions (kill, etc.)
โ โ โโโ process.py
โ โ
โ โโโ cli/ # Command-line interface
โ โ โโโ commands.py # Command handlers
โ โ โโโ parser.py # Argument parsing
โ โ โโโ formatter.py # Rich output formatting
โ โ โโโ json_utils.py # JSON serialization
โ โ
โ โโโ collectors/ # OS-specific data collectors
โ โ โโโ windows.py # Windows netstat parser
โ โ
โ โโโ core/ # Core domain logic
โ โ โโโ models.py # Data models (PortEntry, etc.)
โ โ โโโ processors.py # Data filtering & analysis
โ โ โโโ summary.py # Summary generation
โ โ
โ โโโ storage/ # Persistence layer
โ โโโ snapshot.py # Snapshot save/load/diff
โ
โโโ vscode-extension/ # VS Code extension
โโโ package.json # Extension manifest & config
โโโ tsconfig.json
โโโ esbuild.js # Build configuration
โ
โโโ src/
โ โโโ extension.ts # Extension entry point
โ โ
โ โโโ views/
โ โ โโโ dashboardViewProvider.ts # Webview dashboard (4 tabs)
โ โ
โ โโโ services/
โ โ โโโ cliRunner.ts # CLI child process integration
โ โ โโโ snapshotService.ts # Snapshot CRUD & diffing
โ โ โโโ orchestrationService.ts # Service management & terminals
โ โ โโโ notificationService.ts # Port change notifications
โ โ โโโ resourceMonitor.ts # CPU/memory monitoring
โ โ
โ โโโ types/
โ โโโ report.ts # Port data types
โ โโโ snapshot.ts # Snapshot types
โ โโโ orchestration.ts # Service orchestration types
โ
โโโ media/
โโโ main.js # Webview frontend logic
โโโ styles.css # Dashboard styling
๐ฎ Future Enhancements
๐ Cross-Platform Expansion
- Full macOS support with
lsofintegration - Linux support for major distributions
- Unified abstraction layer across all platforms
- Platform-specific optimizations and command normalization
๐บ๏ธ Service Topology Visualization
- Visual architecture map showing frontend โ backend โ database flows
- Live status indicators (running/stopped/error) on the graph
- Interactive service graph with clickable nodes
- Export architecture diagrams for documentation
โ๏ธ Developer Experience Improvements
- Interactive CLI mode with autocomplete
- Smart port conflict suggestions ("Port 3000 in use, try 3001?")
- Docker container awareness and integration
- Permission safety checks before killing processes
- Performance optimizations for large port lists
- Custom output templates for reporting
- Plugin system for extensibility
- Watch mode filters (by port range, process name, etc.)
๐ก๏ธ Advanced Features
- Process tree visualization (parent/child relationships)
- Historical port usage analytics
- Alert rules for suspicious port activity
- Export to various formats (CSV, XML, HTML reports)
- Network traffic statistics per port
- Automated port cleanup on service exit
- Snapshot import/export for sharing configs across teams
๐ Ecosystem Integration
- CI/CD pipeline integration for port conflict detection
- Docker Compose compatibility for container port mapping
- Kubernetes port forwarding management
- npm wrapper for JavaScript ecosystem
- REST API for remote control
- Web dashboard for team visibility
๐ VS Code Extension โ Next Steps
- VS Code Marketplace publication
- Multi-select and batch operations on individual services
- Export/import for snapshots and orchestration configs
- Automated testing and CI/CD for the extension
- Status bar integration with quick actions
- Keyboard shortcuts for common operations
๐ง Tech Stack
CLI
- Python 3.9+ โ Core engine
- Rich โ Beautiful terminal UI and live dashboards
- Pyfiglet โ ASCII art banners
- Platformdirs โ Cross-platform storage paths
- Subprocess โ System command execution
VS Code Extension
- TypeScript โ Extension logic and services
- VS Code Webview API โ Interactive dashboard UI
- esbuild โ Fast bundling
- HTML/CSS/JS โ Webview frontend with accessibility support
๐ค Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Areas for Contribution
- macOS and Linux platform support
- VS Code extension testing and improvements
- Documentation and examples
- Bug fixes and performance optimizations
๐ Project Status
Current Version: v1.0.2 Status: Stable โ Production Ready
| Component | Status |
|---|---|
| CLI Engine | โ Production ready |
| VS Code Extension | โ Feature complete (pre-marketplace) |
| Windows Support | โ Full support |
| macOS Support | ๐ Planned |
| Linux Support | ๐ Planned |
๐ License
MIT License โ see LICENSE file for details.
Copyright (c) 2026 Aadish Sonawane
โญ Star this repo if you find it useful!
Made with โค๏ธ by Aadish Sonawane
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file portviz-1.0.2.tar.gz.
File metadata
- Download URL: portviz-1.0.2.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d54209d49357c91c56d8f33f8440d3624bcae7b85249babb160f6be710aa05c2
|
|
| MD5 |
fc946b50add29bbccb87ae9227a9f540
|
|
| BLAKE2b-256 |
4796799d8edc015047dfbf067c131326ae7d261ea771f04dda01d88b2c1c193c
|
File details
Details for the file portviz-1.0.2-py3-none-any.whl.
File metadata
- Download URL: portviz-1.0.2-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3407b98b48efd775f735b6ac7a233260b542ed3cd6d1353cda11480ce119dd67
|
|
| MD5 |
c0865e52f5fe6533b86822bee762aa60
|
|
| BLAKE2b-256 |
fc80037f42219827fc3f33bd531e0e672378e2cca86accdf73f87fb7148bf4ce
|