# ernw/dizzy-legacy architecture

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

- Interactive diagram: https://gitdiagram.com/ernw/dizzy-legacy
- Repository: https://github.com/ernw/dizzy-legacy

## Overview

##### Main Components

a) Core Components:
- Packet Generation Engine (dizzy.py as the main entry point)
- Packet Description Parser (for .dizz files)
- Action Sequence Handler (for .act files)
- USB Device Simulation Layer (usb directory)

b) Supporting Components:
- Utility Functions (tools.py)
- Standard Libraries (lib directory)
- USB Device Types (various USB*.py files)

##### Key Relationships to Highlight

- Data flow from .dizz files through the packet generation system
- Control flow from .act files through the interaction engine
- Inheritance relationships in the USB device hierarchy
- Component dependencies

##### Specific Implementation Details

a) Packet Generation:
- Field generation functions (field(), list(), rand(), link())
- Function processors (length(), csum(), etc.)

b) USB Device Simulation:
- Relationship between USBDevice.py and its specialized implementations
- Connection to physical USB interfaces through Facedancer.py

##### Component Interactions

- Packet parser and function executor
- USB device simulators and the core engine
- Action sequence handler and packet generator

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        EP["dizzy.py (Entry Point)"]:::core
        CDT["createdizz.pl"]:::tool
        DizzFiles[".dizz Files"]:::file
        ActFiles[".act Files"]:::file
    end

    subgraph "Packet Processing Layer"
        PDP["Packet Description Parser"]:::core
        FGS["Field Generation System"]:::core
        FEE["Function Execution Engine"]:::core
        Tools["tools.py"]:::util
        StdLib["Standard Libraries"]:::lib
    end

    subgraph "USB Device Simulation Layer"
        FD["Facedancer.py"]:::usb
        USB["USB.py"]:::usb
        USBD["USBDevice.py"]:::usb
        
        subgraph "USB Device Types"
            UKB["USBKeyboard.py"]:::usbdev
            UMS["USBMassStorage.py"]:::usbdev
            USS["USBSerial.py"]:::usbdev
            UVD["USBVendor.py"]:::usbdev
        end

        subgraph "USB Core Components"
            USBC["USBConfiguration.py"]:::usbcore
            USBE["USBEndpoint.py"]:::usbcore
            USBI["USBInterface.py"]:::usbcore
            USBCL["USBClass.py"]:::usbcore
        end

        USBUtil["util.py"]:::util
    end

    %% Relationships
    EP --> PDP
    EP --> FGS
    CDT --> DizzFiles
    DizzFiles --> PDP
    ActFiles --> FEE
    PDP <--> FEE
    FGS <--> FEE
    Tools --> FGS
    Tools --> FEE
    StdLib --> FGS

    FEE --> FD
    FD --> USB
    USB --> USBD
    USBD --> UKB
    USBD --> UMS
    USBD --> USS
    USBD --> UVD
    
    USBD --> USBC
    USBD --> USBE
    USBD --> USBI
    USBD --> USBCL
    
    USBUtil --> USBD
    USBUtil --> USB

    %% Click Events
    click EP "https://github.com/ernw/dizzy-legacy/blob/master/dizzy.py"
    click Tools "https://github.com/ernw/dizzy-legacy/blob/master/tools.py"
    click StdLib "https://github.com/ernw/dizzy-legacy/blob/master/lib/std_string_lib.txt"
    click FD "https://github.com/ernw/dizzy-legacy/blob/master/usb/Facedancer.py"
    click USB "https://github.com/ernw/dizzy-legacy/blob/master/usb/USB.py"
    click USBD "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBDevice.py"
    click UKB "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBKeyboard.py"
    click UMS "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBMassStorage.py"
    click USS "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBSerial.py"
    click UVD "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBVendor.py"
    click USBC "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBConfiguration.py"
    click USBE "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBEndpoint.py"
    click USBI "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBInterface.py"
    click USBCL "https://github.com/ernw/dizzy-legacy/blob/master/usb/USBClass.py"
    click USBUtil "https://github.com/ernw/dizzy-legacy/blob/master/usb/util.py"
    click CDT "https://github.com/ernw/dizzy-legacy/blob/master/createdizz.pl"

    %% Styles
    classDef core fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef tool fill:#87CF3E,stroke:#000,stroke-width:2px,color:#000
    classDef file fill:#B4A7D6,stroke:#000,stroke-width:2px,color:#000
    classDef util fill:#808080,stroke:#000,stroke-width:2px,color:#fff
    classDef lib fill:#4A86E8,stroke:#000,stroke-width:2px,color:#fff
    classDef usb fill:#FF9900,stroke:#000,stroke-width:2px,color:#000
    classDef usbdev fill:#FFB366,stroke:#000,stroke-width:2px,color:#000
    classDef usbcore fill:#FFCC99,stroke:#000,stroke-width:2px,color:#000
```
