# sakthivel223/malicious-ip-detection architecture

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

- Interactive diagram: https://gitdiagram.com/sakthivel223/malicious-ip-detection
- Repository: https://github.com/sakthivel223/malicious-ip-detection

## Overview

This is an IP/network threat-monitoring system: users can inspect a site or IP in the browser extension, while operators can analyze live traffic and review results in dashboards or a chatbot. The backend exposes analysis endpoints and combines model-based and threat-intelligence assessment; separate scripts capture packets and prepare/train detection models. The excerpts establish several API calls, but not all backend internals or extension wiring, so those relationships are omitted rather than inferred.

Main entry points: [`main/backend/app.py`](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/app.py) (Threat analysis API), [`main/backend/chatbot.py`](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/chatbot.py) (Threat assistant), [`main/extension/background.js`](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/extension/background.js) (Extension service worker), [`main/backend/traffic_analyzer.py`](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/traffic_analyzer.py) (Live flow analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Browser extension"]
  node_popup["Popup analysis<br/>[popup.js]"]
  node_background["Extension service worker<br/>[background.js]"]
  node_inline_alert["Inline threat alerts<br/>[content.js]"]
end

subgraph group_analysis["Threat analysis"]
  node_api["Threat analysis API<br/>[app.py]"]
  node_settings["Detection configuration<br/>[config.py]"]
  node_live_analyzer["Live flow analysis"]
  node_packet_capture["Packet capture"]
end

subgraph group_operations["Monitoring interfaces"]
  node_dashboard["Threat dashboard<br/>[dashboard.py]"]
  node_chatbot["Threat assistant<br/>[chatbot.py]"]
end

subgraph group_ml["Detection modeling"]
  node_model_training["Model training<br/>[train_model.py]"]
  node_dataset_prep["Dataset preprocessing"]
  node_model_artifact["Anomaly model"]
  node_scaler_artifact["Feature scaler<br/>[scaler.pkl]"]
  node_model_metadata["Model metadata"]
end

node_browser_user(("Browser user"))

node_browser_user -->|"requests analysis"| node_popup
node_background -->|"posts IP or domain"| node_api
node_live_analyzer -->|"posts flow features"| node_api
node_dashboard -->|"fetches stats and feed"| node_api
node_chatbot -->|"checks health"| node_api
node_chatbot -.->|"answers questions"| node_browser_user
node_browser_user -.->|"starts capture"| node_packet_capture

click node_popup "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/extension/popup.js"
click node_background "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/extension/background.js"
click node_inline_alert "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/extension/content.js"
click node_api "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/app.py"
click node_settings "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/config.py"
click node_live_analyzer "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/traffic_analyzer.py"
click node_packet_capture "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/capture_live_traffic.py"
click node_dashboard "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/dashboard.py"
click node_chatbot "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/chatbot.py"
click node_model_training "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/train_model.py"
click node_dataset_prep "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/preprocess_cicids2017.py"
click node_model_artifact "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/anomaly_detector.pkl"
click node_scaler_artifact "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/scaler.pkl"
click node_model_metadata "https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/model_metadata.json"

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_popup,node_background,node_inline_alert,node_browser_user toneBlue
class node_api,node_settings,node_live_analyzer,node_packet_capture toneAmber
class node_dashboard,node_chatbot toneMint
class node_model_training,node_dataset_prep,node_model_artifact,node_scaler_artifact,node_model_metadata toneRose
```

## Components

### Browser extension

- [Popup analysis](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/extension/popup.js): `main/extension/popup.js`
- [Extension service worker](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/extension/background.js): `main/extension/background.js`
- [Inline threat alerts](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/extension/content.js): `main/extension/content.js`

### Threat analysis

- [Threat analysis API](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/app.py): `main/backend/app.py`
- [Detection configuration](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/config.py): `main/backend/config.py`
- [Live flow analysis](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/traffic_analyzer.py): `main/backend/traffic_analyzer.py`
- [Packet capture](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/capture_live_traffic.py): `main/backend/capture_live_traffic.py`

### Monitoring interfaces

- [Threat dashboard](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/dashboard.py): `main/backend/dashboard.py`
- [Threat assistant](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/chatbot.py): `main/backend/chatbot.py`

### Detection modeling

- [Model training](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/train_model.py): `main/backend/train_model.py`
- [Dataset preprocessing](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/preprocess_cicids2017.py): `main/backend/preprocess_cicids2017.py`
- [Anomaly model](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/anomaly_detector.pkl): `main/backend/anomaly_detector.pkl`
- [Feature scaler](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/scaler.pkl): `main/backend/scaler.pkl`
- [Model metadata](https://github.com/sakthivel223/malicious-ip-detection/blob/main/main/backend/model_metadata.json): `main/backend/model_metadata.json`

### Other components

- **Browser user**

## Connections

- Browser user → Popup analysis: requests analysis (evidence: `main/extension/popup.js`)
- Extension service worker → Threat analysis API: posts IP or domain (evidence: `main/extension/background.js`)
- Live flow analysis → Threat analysis API: posts flow features (evidence: `main/backend/traffic_analyzer.py`)
- Threat dashboard → Threat analysis API: fetches stats and feed (evidence: `main/backend/dashboard.py`)
- Threat assistant → Threat analysis API: checks health (evidence: `main/backend/chatbot.py`)
- Threat assistant → Browser user: answers questions
- Browser user → Packet capture: starts capture
