# rektifyai/adv-attack-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/rektifyai/adv-attack-analysis
- Repository: https://github.com/rektifyai/adv-attack-analysis

## Overview

##### Project Type and Purpose
- This is an AI/ML-driven data-analysis and prescriptive-analytics platform for Web3 attack-vulnerability detection.
- It uses data ingestion (scraping, APIs), storage (datasets, Beneath API), processing (EDA, feature engineering), modeling (ANNs), serving (prediction scripts, microservices), and a minimal React front-end.

##### Main Architectural Components
A. Data Sources (External)
– Blockchain nodes / on-chain data
– Twitter API / social feeds
– Web-scraper targets (relevant Web3 news sites)
– CSV/Excel files (historic datasets in `dataset/`)
B. Ingestion & ETL Layer
– web-scraper module (`web-scraper/`)
– Twitter-API notebooks and scripts (`Twitter-API/`)
– CSV-to-DB conversion notebooks (`dataset/CSV-to-HTML-DB.ipynb`)
– Beneath API connector (`Beneath-API/beneath-react.js`, notebooks)
C. Data Storage
– Local files (CSV, JSON in `dataset/`, `Beneath-API/SEAL-dataset-keyed.json`)
– Beneath Data Warehouse (REAL API dataset)
D. Processing & Analysis
– Exploratory Data Analysis notebooks (`*.ipynb` under root & subfolders)
– Vulnerability detection research docs (`sentiment-analysis/`, `ANN-application/`)
E. ML Model Training & Serving
– Training pipeline (`Beneath-API/train_model.ipynb`, `make_predictions.py`)
– ANN application notebooks (`ANN-application/GNN-app-revised.ipynb`)
F. API & Microservices
– Ethereum-blocks microservice (`Beneath-API/ethereum-blocks/` with Dockerfile, kube.yaml, main.py)
– Beneath-API wrapper (serving processed data/predictions)
G. Presentation / Alerting
– Minimal React front-end (`beneath-react.js`)
– Dashboards/visualizations on Rektify AI application (not in this repo)

##### Relationships & Data Flows
- ETL outputs → Data Storage (local files & Beneath warehouse)
- Data Storage → Processing & Analysis notebooks → Feature store
- Feature store → ML Model Training → Trained ANN Models
- Trained Models → Prediction Service (`make_predictions.py`)
- Prediction Service → API & Microservices → Front-end alerts
- Kubernetes/Docker layer encompasses Ethereum-blocks microservice

##### Architectural Patterns & Design Principles
- Modular monorepo separated by function (ingestion, storage, ML, service)
- ETL pipeline feeding a supervised learning loop
- Microservice for on-chain data extraction (dockerized & K8s deployed)
- Notebooks for research/EDA → production scripts for training & inference
- Clear separation of concerns: Data Ingestion vs. Data Storage vs. Model Serving

##### Essentials
– Clear component names (Ingestion, Storage, Processing, ML, API, UI)
– Tech stack callouts (Python, Jupyter, Docker, Kubernetes, React)
– External dependencies (Twitter API, Beneath API, SWC Registry)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Data Sources
    subgraph "External Data Sources"
        BN["Blockchain nodes / on-chain data"]:::external
        TW["Twitter API / social feeds"]:::external
        WS_SITE["Web-scraper targets (news sites)"]:::external
        CSV_RAW["CSV/Excel historical files"]:::external
    end

    %% Ingestion & ETL Layer
    subgraph "Ingestion & ETL Layer"
        WS["web-scraper: Python + notebooks"]:::ingestion
        TWAPI["Twitter-API scripts & notebooks"]:::ingestion
        CSV2DB["CSV-to-DB conversion notebook"]:::ingestion
        BAPI_CONN["Beneath API connector notebooks"]:::ingestion
        BAPI_WR["Beneath React wrapper (front-end & API client)"]:::ingestion
    end

    %% Data Storage
    subgraph "Data Storage"
        RAW_DS["Local raw & processed datasets"]:::storage
        SEAL["Keyed SEAL Dataset JSON"]:::storage
        BENEATH_DS["Beneath Data Warehouse"]:::storage
    end

    %% Research & EDA
    subgraph "Research & EDA"
        EDA_ROOT["EDA Starter Notebook"]:::research
        SENTIMENT["Sentiment Analysis docs"]:::research
        ANN_RESEARCH["ANN application research"]:::research
    end

    %% ML Model Training & Serving
    subgraph "ML Pipeline"
        TRAIN["Training pipeline notebook"]:::ml
        GNN_APP["GNN revised app notebook"]:::ml
        PRED["Prediction script"]:::ml
    end

    %% API & Microservices
    subgraph "Services"
        ETH_SVC["Ethereum-blocks microservice\n(Docker + K8s)"]:::services
        BAPI_WRAPPER["Beneath-API wrapper service"]:::services
    end

    %% Presentation / UI
    UI["React front-end & alerts"]:::ui

    %% Connections
    BN --> WS
    TW --> TWAPI
    WS_SITE --> WS
    CSV_RAW --> CSV2DB

    WS --> RAW_DS
    TWAPI --> RAW_DS
    CSV2DB --> RAW_DS
    BAPI_CONN --> RAW_DS

    RAW_DS --> EDA_ROOT
    RAW_DS --> SENTIMENT
    RAW_DS --> ANN_RESEARCH

    EDA_ROOT --> TRAIN
    ANN_RESEARCH --> TRAIN
    TRAIN --> PRED
    PRED --> BAPI_WRAPPER

    ETH_SVC --> BAPI_WRAPPER
    BAPI_WRAPPER --> UI
    BAPI_WR --> UI

    %% Click Events
    click WS "https://github.com/rektifyai/adv-attack-analysis/tree/main/web-scraper/"
    click TWAPI "https://github.com/rektifyai/adv-attack-analysis/tree/main/Twitter-API/"
    click CSV2DB "https://github.com/rektifyai/adv-attack-analysis/blob/main/dataset/CSV-to-HTML-DB.ipynb"
    click BAPI_CONN "https://github.com/rektifyai/adv-attack-analysis/blob/main/Beneath-API/Beneath-API-starter-2.ipynb"
    click BAPI_WR "https://github.com/rektifyai/adv-attack-analysis/blob/main/Beneath-API/beneath-react.js"
    click RAW_DS "https://github.com/rektifyai/adv-attack-analysis/tree/main/dataset/"
    click SEAL "https://github.com/rektifyai/adv-attack-analysis/blob/main/Beneath-API/SEAL-dataset-keyed.json"
    click EDA_ROOT "https://github.com/rektifyai/adv-attack-analysis/blob/main/Beneath-API-starter.ipynb"
    click SENTIMENT "https://github.com/rektifyai/adv-attack-analysis/tree/main/sentiment-analysis/"
    click ANN_RESEARCH "https://github.com/rektifyai/adv-attack-analysis/tree/main/ANN-application/"
    click TRAIN "https://github.com/rektifyai/adv-attack-analysis/blob/main/Beneath-API/train_model.ipynb"
    click PRED "https://github.com/rektifyai/adv-attack-analysis/blob/main/Beneath-API/make_predictions.py"
    click GNN_APP "https://github.com/rektifyai/adv-attack-analysis/blob/main/ANN-application/GNN-app-revised.ipynb"
    click ETH_SVC "https://github.com/rektifyai/adv-attack-analysis/tree/main/Beneath-API/ethereum-blocks/"

    %% Styles
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef ingestion fill:#add8e6,stroke:#000,stroke-width:1px
    classDef storage fill:#90ee90,stroke:#000,stroke-width:1px
    classDef research fill:#fffacd,stroke:#000,stroke-width:1px
    classDef ml fill:#ffa500,stroke:#000,stroke-width:1px
    classDef services fill:#dda0dd,stroke:#000,stroke-width:1px
    classDef ui fill:#ffb6c1,stroke:#000,stroke-width:1px
```
