# le4f/pcap-analyzer architecture

> Architecture diagram of the GitHub repository le4f/pcap-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/le4f/pcap-analyzer
- Repository: https://github.com/le4f/pcap-analyzer

## Overview

Pcap Analyzer Online is a Flask web application for uploading and managing capture files, then inspecting and analyzing them. The main workflow runs from the browser through Flask routes: upload and store a capture, select it for analysis, and view packet details and traffic summaries. Analysis includes filtering, packet statistics, IP/port breakdowns, and web, DNS, and mail extraction. The core logic is concentrated in server/func.py. The excerpts show route-to-function calls and file/database operations; unsampled templates and browser code are represented only where the README or route code supports their role.

Main entry points: [`server/views.py`](https://github.com/le4f/pcap-analyzer/blob/master/server/views.py) (Web routes), [`app.py`](https://github.com/le4f/pcap-analyzer/blob/master/app.py) (Flask entry), [`server/__init__.py`](https://github.com/le4f/pcap-analyzer/blob/master/server/__init__.py) (Flask application), [`server/func.py`](https://github.com/le4f/pcap-analyzer/blob/master/server/func.py) (Capture access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_entry["Flask entry<br/>[app.py]"]
  node_application["Flask application<br/>[__init__.py]"]
  node_routes["Web routes<br/>[views.py]"]
  node_templates["Page templates"]
end

subgraph group_storage["Capture storage"]
  node_capture_files[("Capture files")]
  node_capture_db[("Capture metadata<br/>[db.sqlite]")]
  node_capture_helpers["Capture access<br/>[func.py]"]
end

subgraph group_analysis["Capture analysis"]
  node_packet_decode["Packet decoding<br/>[func.py]"]
  node_traffic_stats["Traffic statistics<br/>[func.py]"]
  node_protocol_extract["Protocol extraction<br/>[func.py]"]
end

node_user(("Browser user"))
node_pyshark["PyShark"]
node_scapy["Scapy"]

node_user -.->|"requests pages"| node_entry
node_entry -->|"imports app"| node_application
node_application -->|"imports routes"| node_routes
node_routes -->|"renders pages"| node_templates
node_routes -->|"saves and removes"| node_capture_files
node_routes -->|"queries metadata"| node_capture_db
node_routes -->|"calls helpers"| node_capture_helpers
node_capture_helpers -->|"queries metadata"| node_capture_db
node_routes -->|"requests packet data"| node_packet_decode
node_routes -->|"requests statistics"| node_traffic_stats
node_routes -->|"requests extracts"| node_protocol_extract
node_packet_decode -->|"reads captures"| node_pyshark
node_traffic_stats -->|"reads packets"| node_scapy
node_protocol_extract -->|"reads packets"| node_scapy

click node_entry "https://github.com/le4f/pcap-analyzer/blob/master/app.py"
click node_application "https://github.com/le4f/pcap-analyzer/blob/master/server/__init__.py"
click node_routes "https://github.com/le4f/pcap-analyzer/blob/master/server/views.py"
click node_templates "https://github.com/le4f/pcap-analyzer/tree/master/server/templates"
click node_capture_files "https://github.com/le4f/pcap-analyzer/tree/master/server/pcapfile"
click node_capture_db "https://github.com/le4f/pcap-analyzer/blob/master/server/db/db.sqlite"
click node_capture_helpers "https://github.com/le4f/pcap-analyzer/blob/master/server/func.py"
click node_packet_decode "https://github.com/le4f/pcap-analyzer/blob/master/server/func.py"
click node_traffic_stats "https://github.com/le4f/pcap-analyzer/blob/master/server/func.py"
click node_protocol_extract "https://github.com/le4f/pcap-analyzer/blob/master/server/func.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_application,node_routes,node_templates,node_user toneBlue
class node_capture_files,node_capture_db,node_capture_helpers toneAmber
class node_packet_decode,node_traffic_stats,node_protocol_extract toneMint
class node_pyshark,node_scapy toneIndigo
```

## Components

### Web interface

- [Flask entry](https://github.com/le4f/pcap-analyzer/blob/master/app.py): `app.py`
- [Flask application](https://github.com/le4f/pcap-analyzer/blob/master/server/__init__.py): `server/__init__.py`
- [Web routes](https://github.com/le4f/pcap-analyzer/blob/master/server/views.py): `server/views.py`
- [Page templates](https://github.com/le4f/pcap-analyzer/tree/master/server/templates): `server/templates`

### Capture storage

- [Capture files](https://github.com/le4f/pcap-analyzer/tree/master/server/pcapfile): `server/pcapfile`
- [Capture metadata](https://github.com/le4f/pcap-analyzer/blob/master/server/db/db.sqlite): `server/db/db.sqlite`
- [Capture access](https://github.com/le4f/pcap-analyzer/blob/master/server/func.py): `server/func.py`

### Capture analysis

- [Packet decoding](https://github.com/le4f/pcap-analyzer/blob/master/server/func.py): `server/func.py`
- [Traffic statistics](https://github.com/le4f/pcap-analyzer/blob/master/server/func.py): `server/func.py`
- [Protocol extraction](https://github.com/le4f/pcap-analyzer/blob/master/server/func.py): `server/func.py`

### Other components

- **Browser user**
- **PyShark**
- **Scapy**

## Connections

- Browser user → Flask entry: requests pages (evidence: `readme.md`)
- Flask entry → Flask application: imports app (evidence: `app.py`)
- Flask application → Web routes: imports routes (evidence: `server/__init__.py`)
- Web routes → Page templates: renders pages (evidence: `server/views.py`)
- Web routes → Capture files: saves and removes (evidence: `server/views.py`)
- Web routes → Capture metadata: queries metadata (evidence: `server/views.py`)
- Web routes → Capture access: calls helpers (evidence: `server/views.py`)
- Capture access → Capture metadata: queries metadata (evidence: `server/func.py`)
- Web routes → Packet decoding: requests packet data (evidence: `server/views.py`)
- Web routes → Traffic statistics: requests statistics (evidence: `server/views.py`)
- Web routes → Protocol extraction: requests extracts (evidence: `server/views.py`)
- Packet decoding → PyShark: reads captures (evidence: `server/func.py`)
- Traffic statistics → Scapy: reads packets (evidence: `server/func.py`)
- Protocol extraction → Scapy: reads packets (evidence: `server/func.py`)
