# ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project architecture

> Architecture diagram of the GitHub repository ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project
- Repository: https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project

## Overview

##### Project Type and Purpose
- This is a Python-based “full-stack” machine-learning web application built with Streamlit.
- Purpose: Allow users to convert executables to images, classify malware into 25 categories, and detect benign vs. malicious files using pre-trained DenseNet models.

##### File Structure
Top-level files & folders:
- Homepage.py – Streamlit entry point and navigation hub
- README.md – project overview, data sources, setup instructions
- code to train model in here/ – Jupyter notebooks for training and experimenting with DenseNet on malware datasets
- example_malware_images/ – sample image data for visualization or testing
- exe_to_bytes/ – raw .bytes representations of executables (Big2015 dataset)
- model_in_here/ – pre-trained Keras .h5 models for classification/detection
- pages/ – modular Streamlit pages that implement:
– Classification_25.py (25-class malware classification)
– Classification_DenseNet_Ver.py (alternate architecture/classifier)
– Detect_25.py, Detect_DenseNet_Ver.py (binary detection)
– ExetoByte.py (convert .exe → .bytes)
– bytetoimg.py (convert .bytes → image)
- tmp/ – temporary storage of uploaded .exe files for demo/testing

##### README for Technical Stack
- Python 3.x, Streamlit for UI
- TensorFlow/Keras DenseNet architecture saved in .h5
- Data processing: converting .exe → byte arrays → grayscale images
- External storage: Google Drive for hosting datasets and model files

a. Data Sources
– MalImg dataset (downloaded images)
– Big2015 dataset (.exe → .bytes)
– Benign dataset (Dike)
– External Google Drive for both datasets & model storage
b. Preprocessing Layer
– exe_to_bytes module (raw .exe → .bytes files)
– bytetoimg module (byte files → grayscale images)
c. Model Training & Storage
– Jupyter Notebooks in “code to train model in here/”
– Training pipelines: load images → DenseNet training → save .h5
– model_in_here/detect.h5 as the deployed artifact
d. Streamlit Web Application
– Homepage.py orchestrates navigation
– Pages sub-modules implement each feature: classification, detection, converters
e. External Services
– Google Drive (for downloading models & datasets)
– Optional: Git/GitHub for code versioning

##### Relationships & Data Flow
1. User uploads .exe via Streamlit → tmp/
2. ExetoByte page: reads tmp/.exe → generates .bytes in exe_to_bytes/
3. bytetoimg page: converts .bytes → image, passes it to classification/detection pages
4. Classification/Detection pages: load image → feed into pre-trained .h5 model → output class or binary label
5. All pages served by Homepage.py in Streamlit

##### Architectural Patterns & Design Principles
– Modular UI: Each functionality in its own Streamlit page (separation of concerns)
– Layered design: Data ingestion → preprocessing → inference → presentation
– Reuse of common artifacts: exe_to_bytes and bytetoimg modules used by both classification & detection

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources (Blue)
    subgraph "Data Sources"
        direction TB
        MalImg[(MalImg Dataset)]:::data
        Big2015[(Big2015 .exe Files)]:::data
        Benign[(Benign Dataset)]:::data
        ExampleImages[(Sample Images Folder)]:::data
    end

    %% External Services (Gray)
    GoogleDrive[/"Google Drive"/]:::external
    GitHub[/"Git/GitHub"/]:::external

    %% Preprocessing Modules (Green)
    subgraph "Preprocessing Layer"
        direction TB
        ExeToBytes["EXE to Bytes Module"]:::process
        BytesToImg["Bytes to Image Module"]:::process
    end

    %% Model Training & Storage (Green & Blue)
    subgraph "Model Training"
        direction TB
        Notebooks["Training Notebooks (.ipynb)"]:::process
        DetectModel[(detect.h5 Model Artifact)]:::data
    end

    %% Streamlit Application (Orange)
    subgraph "Streamlit Web Application"
        direction TB
        Homepage["Homepage.py"]:::app
        subgraph "Pages"
            direction TB
            Classification25["Classification_25.py"]:::app
            ClassificationDense["Classification_DenseNet_Ver.py"]:::app
            Detect25["Detect_25.py"]:::app
            DetectDense["Detect_DenseNet_Ver.py"]:::app
            ExetoBytePage["ExetoByte.py"]:::app
            BytetoImgPage["bytetoimg.py"]:::app
        end
        Icons["icons/"]:::app
        Tmp["tmp/"]:::app
    end

    %% README
    README["README.md"]:::data

    %% Data Flow
    User-->|".exe upload"|Tmp
    Tmp-->|".exe file"|ExetoBytePage
    ExetoBytePage-->|".bytes file"|ExeToBytes
    ExeToBytes-->|".bytes file"|BytesToImg
    BytesToImg-->|"grayscale image"|Classification25
    BytesToImg-->|"grayscale image"|ClassificationDense
    BytesToImg-->|"grayscale image"|Detect25
    BytesToImg-->|"grayscale image"|DetectDense

    Classification25-->|"load .h5 model"|DetectModel
    ClassificationDense-->|"load .h5 model"|DetectModel
    Detect25-->|"load .h5 model"|DetectModel
    DetectDense-->|"load .h5 model"|DetectModel

    %% Training flow (offline)
    ExampleImages-->Notebooks
    Big2015-->Notebooks
    Benign-->Notebooks
    Notebooks-->|"save .h5"|DetectModel

    %% External downloads
    Homepage-->|"download models/datasets"|GoogleDrive

    %% Project files
    README-->Homepage

    %% Click Events
    click Homepage "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/Homepage.py"
    click README "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/README.md"
    click ExampleImages "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/tree/master/example_malware_images/"
    click ExeToBytes "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/tree/master/exe_to_bytes/"
    click Tmp "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/tree/master/tmp/"
    click Icons "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/tree/master/icons/"
    click ExetoBytePage "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/pages/ExetoByte.py"
    click BytetoImgPage "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/pages/bytetoimg.py"
    click Classification25 "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/pages/Classification_25.py"
    click ClassificationDense "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/pages/Classification_DenseNet_Ver.py"
    click Detect25 "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/pages/Detect_25.py"
    click DetectDense "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/pages/Detect_DenseNet_Ver.py"
    click DetectModel "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/blob/master/model_in_here/detect.h5"
    click Notebooks "https://github.com/ngobao2002/classifying-and-detecting-malware-by-using-densenet-graduation-project/tree/master/code to train model in here/"

    %% Styles
    classDef data fill:#cce5ff,stroke:#004085,color:#004085
    classDef process fill:#d4edda,stroke:#155724,color:#155724
    classDef app fill:#ffe5b4,stroke:#cc7000,color:#cc7000
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
