How al-shwaib/network-traffic-visualizer works
Project Type and Purpose
• NetViz is a full-stack web application for real-time network traffic capture and 3D visualization.
• Backend: Python/Flask + Scapy for packet sniffing and stats.
• Frontend: HTML/CSS + Three.js (via network_visualizer.js) served by Flask.
File Structure
• src/main.py: Flask app entry point, orchestrates capture and serves endpoints.
• src/static:
• css/style.css – UI styling
• js/network_visualizer.js – client logic + Three.js visualization
• src/templates/index.html: single-page UI shell
• requirements.txt: Flask, Scapy, etc.
• No persistent database – state is in-memory/statistics computed on the fly.
Extract Key Architectural Insights from README
• Real-time packet capture (Scapy).
• Three visualization modes (Basic, Detailed, Summary).
• Live statistics dashboard (active nodes, data volume, rate).
• Interactive controls (rotate, filter).
• Full Arabic + English UI.
Main Components & Their Interactions
a. Packet Capture Service
• Component: Scapy Sniffer (embedded in main.py)
• Role: Captures live packets, extracts metadata (src/dest, size, protocol, timestamp, device type).
b. Business Logic & API Layer
• Component: Flask HTTP server
• Responsibilities:
• Expose REST/WebSocket endpoints for front-end data feed
• Aggregate stats (node count, data volume, rate)
• Serve static assets and index.html
c. Client-Side Visualization
• Component: network_visualizer.js + Three.js
• Responsibilities:
• To Flask endpoints (polling or WebSocket)
• Render 3D graph of network nodes & edges
• Switch between view modes, update stats dashboard
• Provide UI controls (rotate, filter, reset)
d. User’s Web Browser
• Entry point: http://localhost:5000
• Renders index.html, pulls in CSS & JS
e. External Dependencies
• Python libs: Flask, Scapy
• Three.js (bundled)
Architectural Patterns & Principles
• Single-Page Application pattern for front-end (static assets + client logic).
• Lightweight micro-service style: one Flask container handling both API and static content.
• Separation of concerns: capture → process → serve → render.