This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build the project
dotnet build
# Run the application
dotnet run --project src/WebsiteMonitor
# Build release version
dotnet build -c ReleaseServerMonitor is a .NET 8 WPF system tray application that monitors and manages local development servers by detecting processes with listening TCP ports.
- ProcessMonitorService: Polls running processes every 2 seconds, filters by listening ports, emits
ServersChangedevents when the server list changes - PortDetectionService: Wraps
GetExtendedTcpTableWindows API to get listening TCP ports by PID - ProcessTerminationService: Three-stage graceful shutdown (CloseMainWindow → Ctrl+C via console attach → Kill)
- ConfigurationService: Persists groups, assignments, and remembered servers to
%APPDATA%\WebsiteMonitor\config.json
- IpHlpApi.cs: P/Invoke for
iphlpapi.dll- usesMIB_TCPROW_OWNER_PIDstructures to map PIDs to listening ports - Kernel32.cs: P/Invoke for console attachment and Ctrl+C signal generation (
AttachConsole,GenerateConsoleCtrlEvent)
Uses CommunityToolkit.Mvvm with source generators:
[ObservableProperty]for bindable properties[RelayCommand]for command bindingMainViewModelmanages the server list,ServerRowViewModelrepresents individual servers
ProcessMonitorServicetimer fires → scans all processes → filters those with listening ports (viaPortDetectionService)- Server list change triggers
ServersChangedevent MainViewModel.OnServersChangedmarshals to UI thread, merges running servers with remembered (stopped) serversServerRowViewModelhandles stop/start/remove actions per server
Uses Hardcodet.NotifyIcon.Wpf. The tray icon is defined in App.xaml as a resource, configured in App.xaml.cs. Left-click toggles MainWindow visibility, which positions itself near the tray icon.