# aixisstudio/snitch architecture

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

- Interactive diagram: https://gitdiagram.com/aixisstudio/snitch
- Repository: https://github.com/aixisstudio/snitch

## Overview

Snitch is a local, real-time network-traffic visualizer. Its main workflow captures and parses packets, enriches connections with process, classification and offline-geolocation data, detects anomalies, persists local history, and streams updates to the UI. The UI presents live graph and map views alongside alerts, per-app activity, bandwidth, timeline, privacy scoring and settings. The graph preserves documented capabilities, but some implementation links rely on README or SOURCE INDEX references because the corresponding source was not excerpted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/aixisstudio/snitch/blob/main/frontend/src/App.jsx) (Application shell), [`backend/api/main.py`](https://github.com/aixisstudio/snitch/blob/main/backend/api/main.py) (Backend API), [`backend/capture/sniffer.py`](https://github.com/aixisstudio/snitch/blob/main/backend/capture/sniffer.py) (Packet capture), [`frontend/src/hooks/useWebSocket.js`](https://github.com/aixisstudio/snitch/blob/main/frontend/src/hooks/useWebSocket.js) (Realtime state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Capture and analysis"]
  node_capture["Packet capture<br/>[sniffer.py]"]
  node_parser["Packet parser<br/>[parser.py]"]
  node_pcap["libpcap binding<br/>[pcap.py]"]
  node_process["Process attribution<br/>[sniffer.py]"]
  node_classifier["Traffic classifier<br/>[traffic.py]"]
  node_geo["Offline geolocation<br/>[dns_geo.py]"]
  node_lan["LAN discovery<br/>[arp_scanner.py]"]
  node_anomaly["Anomaly detection<br/>[anomaly.py]"]
  node_media["Media monitor<br/>[media_monitor.py]"]
end

subgraph group_services["API and local services"]
  node_api["Backend API<br/>[main.py]"]
  node_security["API security<br/>[security.py]"]
  node_database[("SQLite history<br/>[db.py]")]
  node_paths["Data paths<br/>[paths.py]"]
end

subgraph group_frontend["Desktop and web UI"]
  node_clientapi["Frontend API helpers<br/>[api.js]"]
  node_socket["Realtime state<br/>[useWebSocket.js]"]
  node_app["Application shell<br/>[App.jsx]"]
  node_i18n["Bilingual interface<br/>[i18n.jsx]"]
  node_electron["Electron desktop<br/>[main.js]"]
end

subgraph group_views["Traffic views"]
  node_graph["Force graph<br/>[ForceGraph.jsx]"]
  node_map["World map<br/>[MapView.jsx]"]
  node_sidebar["Sidebar and metrics<br/>[Sidebar.jsx]"]
  node_alerts["Alert panel<br/>[AlertPanel.jsx]"]
  node_apps["Per-app view<br/>[AppsView.jsx]"]
  node_timeline["Traffic timeline<br/>[Timeline.jsx]"]
  node_settings["Settings<br/>[Settings.jsx]"]
  node_privacy["Privacy scoring<br/>[privacy.js]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_capture -->|"captures via"| node_pcap
node_capture -->|"decodes with"| node_parser
node_api -->|"starts and receives"| node_capture
node_capture -->|"attributes process"| node_process
node_api -->|"classifies traffic"| node_classifier
node_api -->|"enriches connections"| node_geo
node_api -->|"discovers devices"| node_lan
node_api -->|"checks anomalies"| node_anomaly
node_api -->|"reads media state"| node_media
node_api -->|"persists and reads"| node_database
node_api -->|"enforces tokens"| node_security
node_database -->|"resolves storage"| node_paths
node_security -->|"resolves token path"| node_paths
node_api -->|"streams updates"| node_socket
node_clientapi -->|"calls endpoints"| node_api
node_socket -->|"gets connection details"| node_clientapi
node_app -->|"uses realtime state"| node_socket
node_app -->|"renders traffic graph"| node_graph
node_app -->|"renders geo map"| node_map
node_app -->|"renders metrics"| node_sidebar
node_app -->|"renders alerts"| node_alerts
node_app -->|"renders app view"| node_apps
node_app -->|"renders timeline"| node_timeline
node_app -->|"renders settings"| node_settings
node_app -->|"calculates score"| node_privacy
node_app -->|"uses translations"| node_i18n
node_electron -.->|"launches backend"| node_api
node_electron -->|"hosts interface"| node_app

click node_capture "https://github.com/aixisstudio/snitch/blob/main/backend/capture/sniffer.py"
click node_parser "https://github.com/aixisstudio/snitch/blob/main/backend/capture/parser.py"
click node_pcap "https://github.com/aixisstudio/snitch/blob/main/backend/capture/pcap.py"
click node_process "https://github.com/aixisstudio/snitch/blob/main/backend/capture/sniffer.py"
click node_classifier "https://github.com/aixisstudio/snitch/blob/main/backend/classifier/traffic.py"
click node_geo "https://github.com/aixisstudio/snitch/blob/main/backend/resolver/dns_geo.py"
click node_lan "https://github.com/aixisstudio/snitch/blob/main/backend/scanner/arp_scanner.py"
click node_anomaly "https://github.com/aixisstudio/snitch/blob/main/backend/detection/anomaly.py"
click node_media "https://github.com/aixisstudio/snitch/blob/main/backend/capture/media_monitor.py"
click node_api "https://github.com/aixisstudio/snitch/blob/main/backend/api/main.py"
click node_security "https://github.com/aixisstudio/snitch/blob/main/backend/api/security.py"
click node_database "https://github.com/aixisstudio/snitch/blob/main/backend/storage/db.py"
click node_paths "https://github.com/aixisstudio/snitch/blob/main/backend/paths.py"
click node_clientapi "https://github.com/aixisstudio/snitch/blob/main/frontend/src/api.js"
click node_socket "https://github.com/aixisstudio/snitch/blob/main/frontend/src/hooks/useWebSocket.js"
click node_app "https://github.com/aixisstudio/snitch/blob/main/frontend/src/App.jsx"
click node_i18n "https://github.com/aixisstudio/snitch/blob/main/frontend/src/i18n.jsx"
click node_graph "https://github.com/aixisstudio/snitch/blob/main/frontend/src/graph/ForceGraph.jsx"
click node_map "https://github.com/aixisstudio/snitch/blob/main/frontend/src/map/MapView.jsx"
click node_sidebar "https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/Sidebar.jsx"
click node_alerts "https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/AlertPanel.jsx"
click node_apps "https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/AppsView.jsx"
click node_timeline "https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/Timeline.jsx"
click node_settings "https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/Settings.jsx"
click node_privacy "https://github.com/aixisstudio/snitch/blob/main/frontend/src/scoring/privacy.js"
click node_electron "https://github.com/aixisstudio/snitch/blob/main/electron/main.js"

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_capture,node_parser,node_pcap,node_process,node_classifier,node_geo,node_lan,node_anomaly,node_media,node_user toneBlue
class node_api,node_security,node_database,node_paths toneAmber
class node_clientapi,node_socket,node_app,node_i18n,node_electron toneMint
class node_graph,node_map,node_sidebar,node_alerts,node_apps,node_timeline,node_settings,node_privacy toneRose
```

## Components

### Capture and analysis

- [Packet capture](https://github.com/aixisstudio/snitch/blob/main/backend/capture/sniffer.py): `backend/capture/sniffer.py`
- [Packet parser](https://github.com/aixisstudio/snitch/blob/main/backend/capture/parser.py): `backend/capture/parser.py`
- [libpcap binding](https://github.com/aixisstudio/snitch/blob/main/backend/capture/pcap.py): `backend/capture/pcap.py`
- [Process attribution](https://github.com/aixisstudio/snitch/blob/main/backend/capture/sniffer.py): `backend/capture/sniffer.py`
- [Traffic classifier](https://github.com/aixisstudio/snitch/blob/main/backend/classifier/traffic.py): `backend/classifier/traffic.py`
- [Offline geolocation](https://github.com/aixisstudio/snitch/blob/main/backend/resolver/dns_geo.py): `backend/resolver/dns_geo.py`
- [LAN discovery](https://github.com/aixisstudio/snitch/blob/main/backend/scanner/arp_scanner.py): `backend/scanner/arp_scanner.py`
- [Anomaly detection](https://github.com/aixisstudio/snitch/blob/main/backend/detection/anomaly.py): `backend/detection/anomaly.py`
- [Media monitor](https://github.com/aixisstudio/snitch/blob/main/backend/capture/media_monitor.py): `backend/capture/media_monitor.py`

### API and local services

- [Backend API](https://github.com/aixisstudio/snitch/blob/main/backend/api/main.py): `backend/api/main.py`
- [API security](https://github.com/aixisstudio/snitch/blob/main/backend/api/security.py): `backend/api/security.py`
- [SQLite history](https://github.com/aixisstudio/snitch/blob/main/backend/storage/db.py): `backend/storage/db.py`
- [Data paths](https://github.com/aixisstudio/snitch/blob/main/backend/paths.py): `backend/paths.py`

### Desktop and web UI

- [Frontend API helpers](https://github.com/aixisstudio/snitch/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Realtime state](https://github.com/aixisstudio/snitch/blob/main/frontend/src/hooks/useWebSocket.js): `frontend/src/hooks/useWebSocket.js`
- [Application shell](https://github.com/aixisstudio/snitch/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Bilingual interface](https://github.com/aixisstudio/snitch/blob/main/frontend/src/i18n.jsx): `frontend/src/i18n.jsx`
- [Electron desktop](https://github.com/aixisstudio/snitch/blob/main/electron/main.js): `electron/main.js`

### Traffic views

- [Force graph](https://github.com/aixisstudio/snitch/blob/main/frontend/src/graph/ForceGraph.jsx): `frontend/src/graph/ForceGraph.jsx`
- [World map](https://github.com/aixisstudio/snitch/blob/main/frontend/src/map/MapView.jsx): `frontend/src/map/MapView.jsx`
- [Sidebar and metrics](https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Alert panel](https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/AlertPanel.jsx): `frontend/src/components/AlertPanel.jsx`
- [Per-app view](https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/AppsView.jsx): `frontend/src/components/AppsView.jsx`
- [Traffic timeline](https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/Timeline.jsx): `frontend/src/components/Timeline.jsx`
- [Settings](https://github.com/aixisstudio/snitch/blob/main/frontend/src/components/Settings.jsx): `frontend/src/components/Settings.jsx`
- [Privacy scoring](https://github.com/aixisstudio/snitch/blob/main/frontend/src/scoring/privacy.js): `frontend/src/scoring/privacy.js`

### Other components

- **User**

## Connections

- User → Application shell: uses
- Packet capture → libpcap binding: captures via (evidence: `backend/capture/sniffer.py`)
- Packet capture → Packet parser: decodes with (evidence: `backend/capture/sniffer.py`)
- Backend API → Packet capture: starts and receives (evidence: `backend/api/main.py`)
- Packet capture → Process attribution: attributes process (evidence: `backend/capture/sniffer.py`)
- Backend API → Traffic classifier: classifies traffic (evidence: `backend/api/main.py`)
- Backend API → Offline geolocation: enriches connections (evidence: `backend/api/main.py`)
- Backend API → LAN discovery: discovers devices (evidence: `backend/api/main.py`)
- Backend API → Anomaly detection: checks anomalies (evidence: `backend/api/main.py`)
- Backend API → Media monitor: reads media state (evidence: `backend/api/main.py`)
- Backend API → SQLite history: persists and reads (evidence: `backend/api/main.py`)
- Backend API → API security: enforces tokens (evidence: `backend/api/main.py`)
- SQLite history → Data paths: resolves storage (evidence: `backend/storage/db.py`)
- API security → Data paths: resolves token path (evidence: `backend/api/security.py`)
- Backend API → Realtime state: streams updates (evidence: `backend/api/main.py`)
- Frontend API helpers → Backend API: calls endpoints
- Realtime state → Frontend API helpers: gets connection details (evidence: `frontend/src/hooks/useWebSocket.js`)
- Application shell → Realtime state: uses realtime state (evidence: `frontend/src/App.jsx`)
- Application shell → Force graph: renders traffic graph (evidence: `frontend/src/App.jsx`)
- Application shell → World map: renders geo map (evidence: `frontend/src/App.jsx`)
- Application shell → Sidebar and metrics: renders metrics (evidence: `frontend/src/App.jsx`)
- Application shell → Alert panel: renders alerts (evidence: `frontend/src/App.jsx`)
- Application shell → Per-app view: renders app view (evidence: `frontend/src/App.jsx`)
- Application shell → Traffic timeline: renders timeline (evidence: `frontend/src/App.jsx`)
- Application shell → Settings: renders settings (evidence: `frontend/src/App.jsx`)
- Application shell → Privacy scoring: calculates score (evidence: `frontend/src/App.jsx`)
- Application shell → Bilingual interface: uses translations (evidence: `frontend/src/App.jsx`)
- Electron desktop → Backend API: launches backend
- Electron desktop → Application shell: hosts interface
