This document outlines the tasks required to implement a real-time nmap visualization system using Svelte for the frontend and a Python FastAPI backend.
- Create a requirements.txt file with FastAPI, uvicorn, websockets, and asyncio
- Set up project structure with appropriate folders (routes, services, models)
- Create main.py with FastAPI app initialization
- Implement basic health check endpoint
- Create NmapService class to handle subprocess interaction
- Implement method to run nmap scan asynchronously
- Add line-by-line output parsing for progress, ports, and phases
- Implement timeout and error handling for nmap process
- Create WebSocket endpoint for real-time nmap output streaming
- Implement connection management (connect/disconnect handlers)
- Add message formatting for different event types (output, progress, port discovery)
- Implement broadcast mechanism for multiple clients
- Create endpoint to start nmap scan with parameters
- Implement endpoint to retrieve scan history
- Add endpoint to get current scan status
- Create API for retrieving saved scan results
- Design database schema for scan results
- Implement database connection (SQLite for simplicity)
- Create data models and repositories
- Add service to store and retrieve scan history
- Set up new Svelte project using SvelteKit or Vite
- Configure build system and development environment
- Set up basic routing structure
- Add necessary dependencies (charting libraries, terminal emulator)
- Create layout components (header, sidebar, main content)
- Implement scan configuration form
- Build progress indicator components (progress bar, phase indicator)
- Create terminal output component with syntax highlighting
- Implement network map visualization
- Create port visualization component
- Build vulnerability highlight system
- Add timeline visualization for scan phases
- Set up WebSocket connection manager
- Create stores for different data types (output, progress, ports)
- Implement reconnection logic
- Add message handlers for different event types
- Add keyboard shortcuts for common actions
- Implement dark/light theme support
- Create responsive layout for different screen sizes
- Add notifications for important events
- Connect frontend to backend REST endpoints
- Implement authentication if needed
- Add error handling for API requests
- Create loading states for async operations
- Set up backend testing with pytest
- Implement frontend testing with Jest and Testing Library
- Create mock data for testing visualizations
- Add WebSocket testing utilities
- Create test for complete scan workflow
- Test real-time updates during scan
- Verify visualization accuracy with known scan results
- Test error handling and edge cases
- Configure production build process
- Set up static asset optimization
- Implement backend deployment scripts
- Create Docker container if needed
- Write API documentation with Swagger/OpenAPI
- Create user guide for the interface
- Document architecture and design decisions
- Add inline code documentation
- Integrate with pentest-agent-system if required
- Create transition plan from Streamlit
- Implement data migration if needed
- Configure CI/CD pipeline
- Implement comparison between multiple scans
- Add scan scheduling and automation
- Create scan templates for common scenarios
- Implement reporting and export features
┌────────────────┐ WebSocket ┌────────────────┐
│ │◄───Stream────┐ │ │
│ Svelte UI │ │ │ Python │
│ - Terminal │ REST API │ │ Backend │◄────Subprocess──────┐
│ - Charts │◄───JSON────────►│ (FastAPI) │ │
│ - Viz │ │ │ │ │
└────────────────┘ └──┴────────────────┘ ┌─────▼─────┐
│ nmap │
└───────────┘
- True Real-time Updates: WebSocket connection provides instant updates without page refreshes
- Better Performance: Svelte's efficient DOM updates minimize UI lag during rapid updates
- Enhanced Visualizations: Rich client-side rendering capabilities for complex visualizations
- Improved User Experience: Responsive UI with proper loading states and error handling
- Separation of Concerns: Clear division between frontend and backend for better maintainability
- Use FastAPI for high-performance async API endpoints
- Leverage Python asyncio for non-blocking nmap execution
- Parse nmap output line-by-line for immediate transmission
- Store scan results in SQLite (can be upgraded to PostgreSQL later)
- Utilize Svelte stores for reactive state management
- Implement XTerm.js for terminal emulation with syntax highlighting
- Use D3.js or similar for network and port visualizations
- Maintain WebSocket connection with automatic reconnection