# lwagner94/wasmut architecture

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

- Interactive diagram: https://gitdiagram.com/lwagner94/wasmut
- Repository: https://github.com/lwagner94/wasmut

## Overview

##### Main Components

a) Core Components:
- Input Processing Layer
- WASM Module Reader
- Configuration Parser
- CLI Arguments Handler

b) Mutation Engine:
- Mutation Operator System
- Meta-mutant Generator
- Coverage Analyzer

c) Execution Engine:
- WASI Runtime (Wasmer)
- Execution Controller
- Timeout Manager

d) Reporting System:
- Multiple Reporter Types (CLI, HTML, JSON)
- Source Code Rewriter
- Template Engine

##### Specific Implementation Details

**┌─ Input Layer ─────────────────────┐**
- WASM Module (.wasm)             │
- Configuration (wasmut.toml)     │
- CLI Arguments                   │
- ┬───────────────────┘
- ↓
**┌─ Mutation Engine ─────────────────┐**
- ┌─ Operator System ─────────────┐ │
- Binary Operators           │ │
- Unary Operators           │ │
- Relational Operators      │ │
- Constant Operators        │ │
- ┘ │
- ┌─ Meta-mutant System ──────────┐ │
- Mutation Aggregator        │ │
- Flag Controller           │ │
- ┘ │
- ┬───────────────────┘
- ↓
**┌─ Execution Engine ────────────────┐**
- ┌─ Wasmer Runtime ─────────────┐ │
- WASI Implementation       │ │
- Cycle Counter            │ │
- ┘ │
- ┌─ Execution Controller ────────┐ │
- Timeout Management        │ │
- Coverage Tracking        │ │
- ┘ │
- ┬───────────────────┘
- ↓
**┌─ Reporting System ────────────────┐**
- ┌─ Reporters ──────────────────┐ │
- CLI Reporter             │ │
- HTML Reporter           │ │
- JSON Reporter          │ │
- ┘ │
- ┌─ Source Analysis ────────────┐ │
- DWARF Debug Info         │ │
- Path Rewriting          │ │
- ┘ │
- ┘

##### Technical Details to Emphasize

- WASI compatibility
- DWARF debug information usage
- Multi-threaded execution support
- Template-based reporting system
- File system mapping capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        WM["WASM Module Reader"]:::input
        CP["Configuration Parser"]:::input
        CH["CLI Arguments Handler"]:::input
    end

    subgraph "Mutation Engine"
        subgraph "Operator System"
            MO["Mutation Operator System"]:::mutation
            MC["Mutation Engine Core"]:::mutation
        end
        
        subgraph "Meta-mutant System"
            MA["Mutation Aggregator"]:::mutation
            FC["Flag Controller"]:::mutation
        end
    end

    subgraph "Execution Engine"
        subgraph "Runtime"
            WR["WASI Runtime"]:::execution
            CC["Cycle Counter"]:::execution
        end
        
        subgraph "Controller"
            EC["Execution Controller"]:::execution
            EP["Execution Policy"]:::execution
            OH["Output Handler"]:::execution
        end
    end

    subgraph "Reporting System"
        subgraph "Reporters"
            CR["CLI Reporter"]:::reporting
            HR["HTML Reporter"]:::reporting
            JR["JSON Reporter"]:::reporting
        end
        
        subgraph "Source Analysis"
            AR["Address Resolution"]:::reporting
            SR["Source Code Rewriter"]:::reporting
            TE["Template Engine"]:::reporting
        end
    end

    %% Connections
    WM --> MO
    CP --> MO
    CH --> MO
    
    MO --> MC
    MC --> MA
    MA --> FC
    
    FC --> WR
    WR --> CC
    CC --> EC
    
    EC --> EP
    EP --> OH
    
    OH --> CR
    OH --> HR
    OH --> JR
    
    CR --> AR
    HR --> AR
    JR --> AR
    
    AR --> SR
    SR --> TE

    %% Click Events
    click WM "https://github.com/lwagner94/wasmut/blob/main/src/wasmmodule.rs"
    click CP "https://github.com/lwagner94/wasmut/blob/main/src/config.rs"
    click CH "https://github.com/lwagner94/wasmut/blob/main/src/cliarguments.rs"
    click MO "https://github.com/lwagner94/wasmut/blob/main/src/operator/ops.rs"
    click MC "https://github.com/lwagner94/wasmut/blob/main/src/mutation.rs"
    click WR "https://github.com/lwagner94/wasmut/blob/main/src/runtime/wasmer.rs"
    click EC "https://github.com/lwagner94/wasmut/blob/main/src/executor.rs"
    click CR "https://github.com/lwagner94/wasmut/blob/main/src/reporter/cli.rs"
    click HR "https://github.com/lwagner94/wasmut/blob/main/src/reporter/html.rs"
    click JR "https://github.com/lwagner94/wasmut/blob/main/src/reporter/json.rs"
    click SR "https://github.com/lwagner94/wasmut/blob/main/src/reporter/rewriter.rs"
    click TE "https://github.com/lwagner94/wasmut/blob/main/src/templates/mod.rs"
    click AR "https://github.com/lwagner94/wasmut/blob/main/src/addressresolver.rs"
    click EP "https://github.com/lwagner94/wasmut/blob/main/src/policy.rs"
    click OH "https://github.com/lwagner94/wasmut/blob/main/src/output.rs"

    %% Styles
    classDef input fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef mutation fill:#90EE90,stroke:#333,stroke-width:2px
    classDef execution fill:#FFB347,stroke:#333,stroke-width:2px
    classDef reporting fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        I["Input Processing"]:::input
        M["Mutation Components"]:::mutation
        E["Execution Components"]:::execution
        R["Reporting Components"]:::reporting
    end
```
