Stack
psys uses modern web technologies for a fast and responsive experience:Framework
Next.js 15.0.0 with App Router and React 19.0.0
Language
TypeScript 5.x with strict mode enabled
Styling
Tailwind CSS 3.4 with custom theme and animations
UI Library
shadcn/ui components built on Radix UI
Key Dependencies
package.json (excerpt)
Architecture Overview
Data Flow
psys follows a straightforward data collection and rendering pipeline:-
Data Collection (
lib/connections.ts)- Executes
ss -tlnpto get listening ports - Executes
ss -tnpto get established connections - Reads process info from
/proc/{pid}/command/proc/{pid}/cmdline - Queries Docker containers via
docker psfor container labels - Parses and normalizes addresses, ports, and process names
- Executes
-
API Layer (
app/api/connections/route.ts)- Exposes GET endpoint at
/api/connections - Calls
getConnectionsData()from lib/connections.ts - Returns JSON with listeners and connections arrays
- Marked as
dynamic = "force-dynamic"for real-time data
- Exposes GET endpoint at
-
Frontend (
components/connections-dashboard.tsx)- Fetches data from API every 5 seconds
- Transforms data into React Flow nodes and edges
- Renders dual views: interactive diagram and sortable table
- Provides process kill functionality via
/api/connections/kill
File Structure
Next.js Configuration
The Next.js configuration is minimal, optimized for development experience:next.config.ts
- devIndicators: Disabled for cleaner UI during development
- outputFileTracingRoot: Ensures proper file tracing for standalone builds
TypeScript Configuration
psys uses strict TypeScript with ES2017 target:tsconfig.json
@/* for clean imports throughout the codebase.
Development Scripts
The
start:bg script runs the app on port 30999 in the background using nohup, perfect for long-running monitoring.Platform Requirements
Optional dependencies:- Docker: For container name detection and labeling
- Permissions: To see all system processes, run with elevated privileges (not recommended for daily use)
Data Types
The core data structures defined inlib/connections.ts:5-33:
Rendering Strategy
- Client-side rendering: The main dashboard is a client component (
"use client") for real-time updates - Dynamic API routes: All API routes use
export const dynamic = "force-dynamic"to prevent caching - Polling: The frontend polls
/api/connectionsevery 5 seconds for fresh data - React Flow: Nodes and edges are computed client-side from the connections data