# raunak-bagaria/netvision architecture

> Architecture diagram of the GitHub repository raunak-bagaria/netvision, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raunak-bagaria/netvision
- Repository: https://github.com/raunak-bagaria/netvision

## Overview

##### Main Components
- Backend Modules (Python scripts under src):
- app.py – Acts as the central web server and likely orchestrates data flow.
- packet_capture.py – Handles capturing network packets (requires admin/root privileges).
- traffic_analyzer.py – Processes captured data to analyze traffic patterns and protocol distributions.
- network_scanner.py – Scans the network and identifies devices (leverages Nmap).
- Data Persistence:
- The data directory (e.g., network_traffic.csv) is used to store captured network traffic logs.
- Frontend:
- The dashboard is rendered using the templates (dashboard.html) and styled via static assets (CSS in static/css/styles.css).

##### Relationships and Data Flow
- Packet Capture, Network Scanner, and Traffic Analyzer are independent modules that gather and process network data.
- The processed data likely gets stored in CSV files (or in-memory) and is subsequently served to the dashboard via app.py.
- app.py acts as the API layer / controller, managing requests from the web interface and interacting with the data/analysis modules.
- The web-based dashboard (HTML/CSS) consumes the processed network data and displays protocol distributions, active devices, and top talkers.

##### Architectural Patterns and Principles
- Modular Design: Separation of duties among packet capture, traffic analysis, and network scanning.
- MVC-like Pattern: app.py acts as the controller interfacing between the data model (captured traffic data) and the view (dashboard UI).
- Real-time Data Flow: Emphasis on real-time updates between back-end processing and front-end visualization.
- Use of external tools: Integration with Nmap for network scanning, and the requirement for elevated privileges for packet capturing.

##### Relevant Technologies and Frameworks
- Python (for the backend logic).
- Flask or a similar light web framework (implied by app.py, the “/templates” directory, and static assets).
- Nmap as an external dependency.
- Data handling libraries (listed in requirements.txt) to manage CSV and possibly real-time processing.
- HTML/CSS for dashboard visualization.

##### Conceptual Layering and Detail
- At the highest level, show the external network feeding into the capture/scanner components.
- The next layer should consist of the processing modules that analyze this input.
- Annotations for key dependencies (e.g., “Requires Admin/Root”, “Uses Nmap for scanning”) to emphasize operational constraints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Source
    ext["External Network"]:::external

    %% Backend Modules Subgraph
    subgraph "Backend Modules"
        PC["Packet Capture Module"]:::backend
        TA["Traffic Analyzer"]:::backend
        NS["Network Scanner"]:::backend
        WS["Web Server (app.py)"]:::backend
        DS["Data Storage (CSV)"]:::storage
    end

    %% Frontend Subgraph
    subgraph "Frontend"
        DASH["Dashboard (HTML Template)"]:::frontend
        CSS["Dashboard Styling (CSS)"]:::frontend
    end

    %% Data Flow Connections
    ext -->|"packets"| PC
    ext -->|"deviceInfo"| NS
    PC -->|"capturedData"| TA
    PC -->|"storesData"| DS
    TA -->|"analyzedData"| DS
    NS -->|"scanResults"| DS
    NS -->|"deviceList"| WS
    DS -->|"providesData"| WS
    WS -->|"servesUI"| DASH
    DASH -->|"loadsStyles"| CSS

    %% Click Events
    click WS "https://github.com/raunak-bagaria/netvision/blob/main/src/app.py"
    click PC "https://github.com/raunak-bagaria/netvision/blob/main/src/packet_capture.py"
    click TA "https://github.com/raunak-bagaria/netvision/blob/main/src/traffic_analyzer.py"
    click NS "https://github.com/raunak-bagaria/netvision/blob/main/src/network_scanner.py"
    click DS "https://github.com/raunak-bagaria/netvision/blob/main/data/network_traffic.csv"
    click DASH "https://github.com/raunak-bagaria/netvision/blob/main/templates/dashboard.html"
    click CSS "https://github.com/raunak-bagaria/netvision/blob/main/static/css/styles.css"

    %% Styles
    classDef external fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef backend fill:#4d79ff,stroke:#333,stroke-width:2px;
    classDef frontend fill:#74c69d,stroke:#333,stroke-width:2px;
    classDef storage fill:#ffcccb,stroke:#333,stroke-width:2px;
```
