# el-rougui/simplevirusdetector-rl architecture

> Architecture diagram of the GitHub repository el-rougui/simplevirusdetector-rl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/el-rougui/simplevirusdetector-rl
- Repository: https://github.com/el-rougui/simplevirusdetector-rl

## Overview

##### Project type and purpose
- This is an open-source, standalone Java command-line tool (“SimpleVirusDetector-RL”) for scanning files or directories for malicious content.
- It loads a list of MD5 hashes (“virusDef.txt”) and employs a simple reinforcement-learning (ε-greedy) mode to adapt detection over time.

##### File structure
- Top-level build files: build.xml (Ant), nbproject/ (NetBeans).
- dist/ contains the packaged JAR and a copy of virusDef.txt.
- src/virusanalyzer/ holds all Java source:
- VirusAnalyzer.java – the main entry (CLI UI)
- FileHandler.java – file I/O and MD5‐hash computation
- AnalyzingLogic.java – compares hashes against definitions and applies RL policy
- RLBatchScanner.java – orchestrates batch scans and updates RL state
- virusDef.txt – initial definitions loaded at runtime
- testvirus/ contains sample malicious archive for testing.

##### Detail
- Every Java class as its own component.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["VirusAnalyzer.java\n(CLI UI)"]:::code
    end

    %% Processing Layer
    subgraph "Processing Layer"
        FileHandler["FileHandler.java\n(MD5 Hashing)"]:::code
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        AL["AnalyzingLogic.java\n(Hash Comparison, ε-greedy)"]:::code
        RLB["RLBatchScanner.java\n(Policy Orchestrator)"]:::rl
    end

    %% Data Layer
    subgraph "Data Layer"
        VD["virusDef.txt\n(MD5 Definitions)"]:::db
        LSD["learningState.dat\n(RL State)"]:::db
    end

    %% External Resources
    TestResources(["Test Resources (sample malware archive)"]):::external

    %% Build & Artifacts
    BuildConfig(["build.xml\n(Ant Build Config)"]):::config
    JAR(["VirusAnalyzer.jar\n(Packaged Application)"]):::artifact

    %% Data Flow
    TestResources -->|"input files"| CLI
    CLI -->|"invokes"| FileHandler
    CLI -->|"starts batch scan"| RLB
    FileHandler -->|"MD5 hash"| AL
    VD -->|"definitions"| AL
    AL -->|"scan result"| CLI
    RLB -->|"invoke hashing & detection"| FileHandler
    RLB -->|"policy update"| LSD

    %% Side Artifacts
    BuildConfig --> CLI
    RLB --> JAR

    %% Click Events
    click CLI "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/src/virusanalyzer/VirusAnalyzer.java"
    click FileHandler "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/src/virusanalyzer/FileHandler.java"
    click AL "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/src/virusanalyzer/AnalyzingLogic.java"
    click RLB "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/src/virusanalyzer/RLBatchScanner.java"
    click VD "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/src/virusanalyzer/virusDef.txt"
    click VD "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/dist/virusDef.txt"
    click TestResources "https://github.com/el-rougui/simplevirusdetector-rl/tree/main/testvirus/"
    click BuildConfig "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/build.xml"
    click JAR "https://github.com/el-rougui/simplevirusdetector-rl/blob/main/dist/VirusAnalyzer.jar"

    %% Styles
    classDef code fill:#D0E8F2,stroke:#0674A6;
    classDef rl fill:#E2F7E2,stroke:#29A329,stroke-dasharray:5,5;
    classDef db fill:#FFE8A1,stroke:#CC8400;
    classDef external fill:#E8E8E8,stroke:#A0A0A0;
    classDef config fill:#E8D0F2,stroke:#804C99;
    classDef artifact fill:#E8D0F2,stroke:#804C99;
```
