Skip to content

Conversation

@productdevbook
Copy link
Owner

@productdevbook productdevbook commented Dec 19, 2025

🗺️ PortKiller Architecture Roadmap

💡 Based on suggestion from @poyotanp in #53

Vision: Shared Backend Architecture

flowchart TB
    subgraph Core["🦀 portkiller-core (Rust Library)"]
        Scanner["📡 Port Scanner<br/>• macOS ✅<br/>• Linux 🚧<br/>• Windows 🚧"]
        Killer["💀 Process Killer<br/>• SIGTERM ✅<br/>• SIGKILL ✅<br/>• Graceful ✅"]
        Config["⚙️ Config Store<br/>• favorites ✅<br/>• watched ✅<br/>• JSON sync ✅"]
        Models["📦 Models<br/>• PortInfo ✅<br/>• ProcessType ✅<br/>• Filter ✅"]
    end

    subgraph Clients["Frontends"]
        CLI["🖥️ Rust CLI ✅<br/>• list, kill, fav, watch<br/>• TUI (ratatui)<br/>• JSON output"]
        Swift["🍎 Swift GUI 🚧<br/>• SwiftUI<br/>• Menu Bar<br/>• Sparkle"]
        Future["🔮 Future<br/>• Tauri (Linux/Win)<br/>• Wails"]
    end

    subgraph Storage["💾 Shared Storage"]
        JSON["~/.portkiller/config.json"]
    end

    Core --> CLI
    Core -->|"FFI (uniffi)"| Swift
    Core --> Future
    Config <--> JSON
    Swift <--> JSON
Loading

✅ This PR: Phase 1 Complete

Core Library (backend/core/)

Component Status Description
Scanner (macOS) lsof parsing
Scanner (Linux) 🚧 ss/netstat (stub ready)
Scanner (Windows) 🚧 netstat (stub ready)
Process Killer SIGTERM → SIGKILL
Config Store JSON at ~/.portkiller/
Models PortInfo, ProcessType, WatchedPort, PortFilter

CLI (backend/cli/)

Feature Status
portkiller list
portkiller kill <port>
portkiller fav add/rm/list
portkiller watch add/rm/list
portkiller config
TUI (ratatui)
JSON output

📋 Roadmap

gantt
    title PortKiller Rust Backend Roadmap
    dateFormat  YYYY-MM-DD
    section Phase 1
    Core Library (macOS)   :done, p1a, 2024-12-19, 1d
    Rust CLI + TUI         :done, p1b, 2024-12-19, 1d
    section Phase 2
    Linux Scanner          :p2a, after p1b, 3d
    Windows Scanner        :p2b, after p2a, 3d
    section Phase 3
    Swift FFI (uniffi)     :p3a, after p2b, 7d
    Replace PortScanner.swift :p3b, after p3a, 3d
    section Phase 4
    Release Binaries       :p4a, after p3b, 2d
    Tauri GUI (optional)   :p4b, after p4a, 14d
Loading

🧪 Test

cd backend

# Run tests (37 passing)
cargo test

# List ports (macOS)
cargo run --bin portkiller -- list

# Kill process
cargo run --bin portkiller -- kill 3000

# TUI mode
cargo run --bin portkiller

🤖 Generated with Claude Code

…d process management

- Added core library structure in `lib.rs` with modules for configuration, error handling, process killing, models, and scanning.
- Created data models for port and process information, including `PortInfo`, `ProcessType`, `PortFilter`, and `WatchedPort`.
- Implemented port filtering functionality in `port_filter.rs` with comprehensive filtering options.
- Developed macOS-specific port scanning using `lsof` in `darwin.rs`.
- Added Linux and Windows scanner modules with placeholders for future implementation.
- Included tests for models and filtering logic to ensure correctness.
- Add portkiller-ffi crate with UniFFI bindings for Swift integration
- Create XCFramework build script for universal macOS library
- Add RustPortScanner Swift wrapper for seamless integration
- Remove Swift PortScanner - now fully powered by Rust backend
- Update AppState to use Rust scanner exclusively
- Simplify Settings UI with "Powered by Rust" badge
- Update gitignore for Frameworks/ and .build/rust/
- Update backend README with FFI documentation

BREAKING: Swift PortScanner removed, Rust backend is now required

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@productdevbook productdevbook marked this pull request as draft December 19, 2025 21:01
productdevbook and others added 9 commits December 20, 2025 00:01
* refactor: move get_process_commands to utils.rs

* feat: Implement Linux Port Scanner
…t forwarding

- Implemented a new module for Kubernetes that includes service and namespace discovery via kubectl, port forward connection configuration, process management for kubectl port-forward and socat, and connection monitoring with auto-reconnect functionality.
- Created data models for Kubernetes namespaces, services, and port forward configurations.
- Developed a process manager to handle kubectl and socat processes, including lifecycle management and error handling.
- Exposed Kubernetes functionality through FFI, allowing interaction with Swift, including fetching namespaces and services, managing port forward connections, and monitoring their states.
- Added necessary tests for the new functionality to ensure reliability and correctness.
- Updated error handling in config_store and connection_manager for better clarity.
- Replaced `std::sync::RwLock` with `parking_lot::RwLock` for improved performance.
- Enhanced async file operations in config_store and connection_manager.
- Simplified code structure in various modules, including discovery and process_manager.
- Improved formatting and consistency in model definitions and tests.
- Added default implementations where necessary for better usability.
- Cleaned up unnecessary unwraps and improved error handling across the codebase.
…nux, and Windows

- Added macOS port scanner using lsof (darwin.rs)
- Added Linux port scanner using ss (linux.rs)
- Created Windows port scanner interface (windows.rs)
- Introduced scanner module to manage platform-specific implementations
- Added utility functions for address parsing (utils.rs)
- Defined domain models for port and process information (port.rs, watched.rs)
- Established configuration and process killer ports for user settings management
…ux, and Windows

- Deleted PortInfo, ProcessType, WatchedPort models and their associated tests.
- Removed DarwinScanner and LinuxScanner implementations along with their tests.
- Eliminated WindowsScanner stub and related code.
- Cleaned up scanner module and utility functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add cross-platform CLI tool with background daemon (pk)

3 participants