Skip to main content

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.

License: MIT Python 3.9+


๐Ÿš€ 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

  1. Detect operating system (Windows, macOS, Linux)
  2. Execute appropriate networking command:
    • Windows โ†’ netstat -ano
    • macOS/Linux โ†’ lsof -i -P -n (planned)
  3. Capture and parse raw output
  4. Structure into typed objects:
    • Protocol (TCP/UDP)
    • Local IP and Port
    • Foreign IP and Port
    • Connection State
    • Process ID (PID)
    • Process Name
  5. Normalize into internal models
  6. Provide CLI, snapshot, or streaming output
  7. 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

  1. Open the Portviz sidebar from the Activity Bar
  2. Browse running ports in the Live tab
  3. Click any process to expand port details
  4. Use the Kill button to terminate processes
  5. Save snapshots and compare them in the Snapshots tab
  6. Define and manage services in the Orchestration tab
  7. 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 lsof integration
  • 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

portviz-1.0.2.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

portviz-1.0.2-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

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

Hashes for portviz-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d54209d49357c91c56d8f33f8440d3624bcae7b85249babb160f6be710aa05c2
MD5 fc946b50add29bbccb87ae9227a9f540
BLAKE2b-256 4796799d8edc015047dfbf067c131326ae7d261ea771f04dda01d88b2c1c193c

See more details on using hashes here.

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

Hashes for portviz-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3407b98b48efd775f735b6ac7a233260b542ed3cd6d1353cda11480ce119dd67
MD5 c0865e52f5fe6533b86822bee762aa60
BLAKE2b-256 fc80037f42219827fc3f33bd531e0e672378e2cca86accdf73f87fb7148bf4ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page