# altafhussain1304/ransomware-detection architecture

> Architecture diagram of the GitHub repository altafhussain1304/ransomware-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/altafhussain1304/ransomware-detection
- Repository: https://github.com/altafhussain1304/ransomware-detection

## Overview

##### Project type and purpose
- From the file tree and file names, this is a standalone monitoring/analysis tool (no “frontend” directory), written in Python. It runs a set of monitors (file, network, system) under a single orchestration layer (main.py), applies YARA rules (rules.yara) to file events, and writes structured event logs to disk (data/logs).
- Its purpose is to capture and log various system events for further analysis or alerting.

##### File structure
- Top‐level:
- README.md  – (currently empty; would normally describe usage & architecture)
- requirements.txt – declares Python dependencies (e.g., yara-python, psutil, scapy, etc.)
- backend/    – houses all monitoring modules and the orchestrator.
- data/logs/   – where modules emit JSON log files.
- backend/ directory:
- main.py    – the entry point; likely spawns each monitor as a thread or process.
- file_monitor.py – watches filesystem events, applies YARA scans using rules.yara.
- network_monitor.py – inspects network traffic (packet capture or socket hooks).
- system_monitor.py – collects OS-level metrics (CPU, memory, process list).
- rules.yara   – YARA rules definitions for file content scanning.
- No GUI/UI or external web services. This is a command‐line/daemon‐style tool.

##### README for additional insights
- README is empty, so infer architecture from code and logs.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Backend Modules"
        O["Orchestrator<br/>(main.py)"]:::internal
        FM["File Monitor<br/>(file_monitor.py)"]:::internal
        NM["Network Monitor<br/>(network_monitor.py)"]:::internal
        SM["System Monitor<br/>(system_monitor.py)"]:::internal
    end

    Y["YARA Rules<br/>(rules.yara)"]:::rules

    Storage["JSON Log Storage<br/>(data/logs)"]:::storage
    subgraph "Stored Event Logs"
        FE["file_events_log.json"]:::log
        NE["network_monitor_log.json"]:::log
        SE["system_monitor_log.json"]:::log
        PL1["process_log.json"]:::log
        PL2["fixed_process_log.json"]:::log
    end

    subgraph "External Dependencies"
        OS["OS APIs"]:::external
        YEngine["YARA Engine"]:::external
        PCAP["Packet Capture Lib<br/>(scapy/pcap)"]:::external
    end

    %% Control Flow
    O -->|"spawn"| FM
    O -->|"spawn"| NM
    O -->|"spawn"| SM

    %% File Monitor Flow
    FM -->|"scan using rules"| Y
    FM -->|"write JSON"| Storage
    FM -->|"invoke"| YEngine
    FM -->|"use OS hooks"| OS

    %% Network Monitor Flow
    NM -->|"write JSON"| Storage
    NM -->|"packet capture"| PCAP

    %% System Monitor Flow
    SM -->|"write JSON"| Storage
    SM -->|"collect stats"| OS

    %% Storage Breakdown
    Storage --> FE
    Storage --> NE
    Storage --> SE
    Storage --> PL1
    Storage --> PL2

    %% Click Events
    click O "https://github.com/altafhussain1304/ransomware-detection/blob/main/backend/main.py"
    click FM "https://github.com/altafhussain1304/ransomware-detection/blob/main/backend/file_monitor.py"
    click Y "https://github.com/altafhussain1304/ransomware-detection/blob/main/backend/rules.yara"
    click NM "https://github.com/altafhussain1304/ransomware-detection/blob/main/backend/network_monitor.py"
    click SM "https://github.com/altafhussain1304/ransomware-detection/blob/main/backend/system_monitor.py"
    click Storage "https://github.com/altafhussain1304/ransomware-detection/tree/main/data/logs/"
    click FE "https://github.com/altafhussain1304/ransomware-detection/blob/main/data/logs/file_events_log.json"
    click NE "https://github.com/altafhussain1304/ransomware-detection/blob/main/data/logs/network_monitor_log.json"
    click SE "https://github.com/altafhussain1304/ransomware-detection/blob/main/data/logs/system_monitor_log.json"
    click PL1 "https://github.com/altafhussain1304/ransomware-detection/blob/main/data/logs/process_log.json"
    click PL2 "https://github.com/altafhussain1304/ransomware-detection/blob/main/data/logs/fixed_process_log.json"

    %% Styles
    classDef internal fill:#cce5ff,stroke:#0366d6,color:#000;
    classDef storage fill:#d4edda,stroke:#155724,color:#000,shape:cylinder;
    classDef rules fill:#fff3cd,stroke:#856404,color:#000;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef log fill:#f8f9fa,stroke:#adb5bd,color:#000;
```
