Skip to content

Architecture

Phong VΓ΅ edited this page Mar 21, 2026 · 1 revision

πŸ—οΈ Architecture β€” Universe Plugin System

Overview

NetTool uses the Universe Architecture β€” a modular plugin system where each tool is a self-contained "civilization" that can be added without modifying existing code.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     config.json     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   WPF UI        β”‚ ──────────────────► β”‚   Go Engine      β”‚
β”‚                 β”‚                     β”‚                  β”‚
β”‚  ToolRegistry   β”‚ ◄────────────────── β”‚  Command         β”‚
β”‚  ITool modules  β”‚   stdout JSON line  β”‚  Dispatcher      β”‚
β”‚  Nested tabs    β”‚                     β”‚  (switch/case)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Interfaces

ITool (C#)

public interface ITool
{
    string Name { get; }           // Display name
    string Icon { get; }           // Emoji icon
    string Description { get; }    // Short description
    string Group { get; }          // "Web", "Network", "Discovery"
    int Order { get; }             // Sort order within group
    ToolViewModelBase ViewModel { get; }
    FrameworkElement CreateView();  // Factory for UI panel
}

ToolViewModelBase (C#)

Base class for all tool ViewModels:

  • OnStart() β€” called when user clicks Start
  • OnEngineOutput(string line) β€” parse JSON from engine
  • OnEngineExited(int exitCode) β€” cleanup
  • RunEngine(string command, string configJson) β€” launch engine process
  • AddLog(string message) β€” append to log panel

ToolRegistry (C#)

ToolRegistry.Register(new YourTool());  // 1 line to add

Adding a New Tool

Step 1: Go Engine Command

Create engine/cmd_yourtool.go:

func runYourTool(configPath string) {
    // Read config, do work, emit JSON lines to stdout
}

Step 2: Register in dispatcher

Add to engine/main.go switch:

case "yourtool":
    runYourTool(configPath)

Step 3: WPF Module (4 files)

Modules/YourTool/
β”œβ”€β”€ YourTool.cs        ← ITool implementation
β”œβ”€β”€ YourViewModel.cs   ← extends ToolViewModelBase
β”œβ”€β”€ YourPanel.xaml      ← UI layout
└── YourPanel.xaml.cs   ← code-behind (minimal)

Step 4: Register (1 line)

In ShellViewModel.cs:

ToolRegistry.Register(new YourTool());

Done! Tab appears automatically in the correct group.

JSON Protocol

Engine β†’ UI communication via JSON Lines on stdout:

{"key": "value", "latency_ms": 12.5}

Engine writes diagnostic info to stderr (not parsed by UI).

Group System

Group Icon Tools
Web 🌐 Load Test, HTTP Headers, SSL Checker, WebSocket
Network πŸ”§ Ping, Traceroute
Discovery πŸ” DNS, Port Scanner, IP Scanner, GeoIP, Whois

Groups are rendered as nested tabs: outer left sidebar + inner top tabs.

Clone this wiki locally