# alipsgh/tornado architecture

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

- Interactive diagram: https://gitdiagram.com/alipsgh/tornado
- Repository: https://github.com/alipsgh/tornado

## Overview

##### Project type and purpose
- This is a Python-based data stream mining framework (“Tornado”).
- It provides:
- Stream generators/readers (ARFF)
- Incremental classifiers (e.g., Naive Bayes, KNN, Hoeffding Tree, Perceptron)
- Concept-drift detectors (e.g., ADWIN, DDM, EDDM, FHDDM)
- Evaluators (prequential/classifier/detector)
- Plotting and archiving utilities
- Sample CLI scripts that tie everything together

##### File structure
- Top-level scripts:
- github_prequential_test.py
- github_prequential_multi_test.py
- github_generate_stream.py
- Core packages (each a subsystem):
- streams/ (generators, readers)
- classifier/ (online learners)
- drift_detection/ (detectors)
- evaluators/ (performance & drift evaluation)
- plotter/ & graphic/ (visualization)
- archiver/ (log and data archiving)
- filters/ (pre- and post-processing)
- data_structures/ & dictionary/ (internal representations)
- tasks/ (pre-built experiment workflows)
- Data directories:
- data_streams/ (sample ARFF data)
- tutorial_img/ & img/ (assets for docs)

##### Key insights from README
- Dependencies: numpy, scipy, matplotlib, pympler
- Three reference flows (single prequential test, multi-algorithm prequential, stream generator)
- Emphasis on incremental/online operation and drift adaptation

A. Stream Input Layer
- Generators (synthetic streams)
- Readers (ARFF files)
B. Pre-processing Layer (filters)
- Attribute handlers, project creation, score processors
C. Core Mining Engine
1. Classifier module
2. Drift Detector module
– These pair up in adaptive “learner+detector” units
D. Evaluation Layer
- Classifier Evaluator (accuracy, error rates)
- Detector Evaluator (detection delay, false alarms)
- Score Calculator
E. Archiving & Logging
- archiver: persist results, stream snapshots
F. Visualization & Reporting
- plotter (performance plots, optimal plots)
G. CLI/Orchestration Scripts
- Predefined tasks (in tasks/) wrap all the above into runnable experiments

##### Architectural patterns & design principles
- Modular plugin-style design: each classifier or detector implements a common interface and can be swapped.
- Pipeline pattern: data flows through a sequence of processing stages.
- Separation of concerns: reading, processing, learning, detection, evaluation, archiving, and plotting are distinct modules.
- Extensibility points:
- New stream generators in streams/generators/
- New classifiers in classifier/
- New detectors in drift_detection/
- New filters in filters/

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Stream Input Layer
    subgraph "Stream Input Layer"
        SG["Stream Generators"]:::io
        ARFF["ARFF Data Store"]:::io
        SR["ARFF Reader"]:::io
    end

    %% Pre-processing Layer
    subgraph "Pre-processing Layer"
        FL["Filters"]:::process
    end

    %% Core Mining Engine
    subgraph "Core Mining Engine"
        CLIF["Classifier Module"]:::process
        DETF["Drift Detector Module"]:::process
    end

    %% Evaluation Layer
    subgraph "Evaluation Layer"
        CE["Classifier Evaluator"]:::eval
        DE["Detector Evaluator"]:::eval
        SC["Score Calculator"]:::eval
    end

    %% Archiving & Logging
    subgraph "Archiving & Logging"
        ARC["Archiver"]:::io
    end

    %% Visualization & Reporting
    subgraph "Visualization & Reporting"
        PP["Performance Plotter"]:::eval
        OP["Optimal Plotter"]:::eval
        GC["Graphic Color Schemes"]:::eval
    end

    %% Orchestration
    subgraph "Orchestration"
        S1["github_prequential_test.py"]:::orch
        S2["github_prequential_multi_test.py"]:::orch
        S3["github_generate_stream.py"]:::orch
        TSK["Tasks"]:::orch
    end

    %% Dependencies
    subgraph "Dependencies"
        NP["numpy"]:::dep
        SP["scipy"]:::dep
        MP["matplotlib"]:::dep
        PY["pympler"]:::dep
    end

    %% Data Flow
    SG -->|"synthetic instances"| FL
    ARFF -->|"data file"| SR
    SR -->|"stream instances"| FL
    FL -->|"filtered instances"| CLIF
    FL -->|"filtered instances"| DETF
    CLIF -->|"predictions"| CE
    DETF -->|"drift signals"| DE
    CE -->|"accuracy metrics"| SC
    DE -->|"detection metrics"| SC
    SC -->|"scores"| ARC
    ARC -->|"archived logs"| PP
    ARC -->|"archived logs"| OP

    %% Orchestration connections
    S1 --> SG
    S1 --> SR
    S1 --> FL
    S1 --> CLIF
    S1 --> DETF
    S1 --> CE
    S1 --> DE
    S1 --> ARC
    S1 --> PP

    S2 --> SG
    S2 --> SR
    S2 --> FL
    S2 --> CLIF
    S2 --> DETF
    S2 --> CE
    S2 --> DE
    S2 --> ARC
    S2 --> PP

    S3 --> SG

    TSK --> SG
    TSK --> SR
    TSK --> FL
    TSK --> CLIF
    TSK --> DETF
    TSK --> CE
    TSK --> DE
    TSK --> ARC
    TSK --> PP

    %% Dependencies links
    NP -.-> SG
    SP -.-> CLIF
    MP -.-> PP
    PY -.-> ARC

    %% Click Events
    click SG "https://github.com/alipsgh/tornado/tree/master/streams/generators/"
    click SR "https://github.com/alipsgh/tornado/blob/master/streams/readers/arff_reader.py"
    click FL "https://github.com/alipsgh/tornado/tree/master/filters/"
    click CLIF "https://github.com/alipsgh/tornado/tree/master/classifier/"
    click DETF "https://github.com/alipsgh/tornado/tree/master/drift_detection/"
    click CE "https://github.com/alipsgh/tornado/blob/master/evaluators/classifier_evaluator.py"
    click DE "https://github.com/alipsgh/tornado/blob/master/evaluators/detector_evaluator.py"
    click SC "https://github.com/alipsgh/tornado/blob/master/evaluators/score_calculator.py"
    click ARC "https://github.com/alipsgh/tornado/blob/master/archiver/archiver.py"
    click PP "https://github.com/alipsgh/tornado/blob/master/plotter/performance_plotter.py"
    click OP "https://github.com/alipsgh/tornado/blob/master/plotter/optimal_plotter.py"
    click GC "https://github.com/alipsgh/tornado/blob/master/graphic/hex_colors.py"
    click S1 "https://github.com/alipsgh/tornado/blob/master/github_prequential_test.py"
    click S2 "https://github.com/alipsgh/tornado/blob/master/github_prequential_multi_test.py"
    click S3 "https://github.com/alipsgh/tornado/blob/master/github_generate_stream.py"
    click TSK "https://github.com/alipsgh/tornado/tree/master/tasks/"

    %% Styles
    classDef io fill:#DAE8FC,stroke:#6C8EBF
    classDef process fill:#D5E8D4,stroke:#82B366
    classDef eval fill:#FFF2CC,stroke:#D6B656
    classDef orch fill:#F2F2F2,stroke:#BFBFBF
    classDef dep fill:#E1E1E1,stroke:#A8A8A8,stroke-dasharray: 2 2
```
