# hatoo/oha architecture

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

- Interactive diagram: https://gitdiagram.com/hatoo/oha
- Repository: https://github.com/hatoo/oha

## Overview

##### Main Components Identification

The system can be broken down into these primary components:

a) Core Components:
- Load Generator Engine
- HTTP Client System
- Results Processing
- TUI (Terminal User Interface)
- Database Integration

b) Supporting Components:
- URL Generation System
- Monitoring System
- Statistics Collection
- Configuration Handler

**Top Level (User Interface):**
- TUI Layer (printer.rs)
- CLI Interface (main.rs)

**Middle Level (Core Processing):**
- Load Generator Controller
- HTTP Client Manager (client.rs)
- URL Generator (url_generator.rs)
- Monitor System (monitor.rs)

**Bottom Level (Data & Storage):**
- Results Processor (result_data.rs)
- Database Handler (db.rs)
- Histogram Generator (histogram.rs)

##### Component Relationships

- User input → CLI Interface
- CLI Interface → Load Generator Controller
- Load Generator Controller → HTTP Client Manager
- HTTP Client Manager → URL Generator
- HTTP Client Manager → Monitor System
- Monitor System → Results Processor
- Results Processor → TUI Layer
- Results Processor → Database Handler

##### Technical Details

Annotations for:
- Tokio async runtime usage
- Ratatui for TUI rendering
- SQLite database integration
- Multiple protocol support (HTTP/HTTPS)
- Connection pooling

##### Additional Notes

- Concurrent connection handling
- Query rate limiting
- Burst mode operation
- Data collection mechanisms
- Performance monitoring points

##### The extensible nature of the load testing capabilities

Remember to include key configuration points:
- Connection pools
- Worker threads
- Rate limiting parameters
- Protocol selection
- Authentication handling

This system design should reflect the tool's primary purpose as a high-performance HTTP load testing tool while showing its modular and extensible architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef optional stroke-dasharray: 5 5

    %% User Interface Layer
    subgraph UI
        CLI["CLI Interface"]
        TUI["TUI Layer"]
    end

    %% Core Processing Layer
    subgraph Core
        LGC["Load Generator Controller"]
        HC["HTTP Client System"]
        UG["URL Generator"]
        MS["Monitor System"]
        TM["Time Management"]
        RNG["Random Number Generator"]
    end

    %% Data Layer
    subgraph Data
        RP["Results Processor"]
        DB["Database Handler"]
        HG["Histogram Generator"]
    end

    %% External Components
    subgraph External
        PGO["PGO Server"]
        Tests["Integration Tests"]
    end

    %% Relationships
    CLI --> LGC
    LGC --> HC
    HC --> UG
    HC --> MS
    MS --> RP
    RP --> TUI
    RP --> DB
    RP --> HG
    TM --> HC
    RNG --> UG
    Tests -.-> HC
    HC -.-> PGO

    %% Click Events
    click CLI "https://github.com/hatoo/oha/blob/master/src/main.rs"
    click TUI "https://github.com/hatoo/oha/blob/master/src/printer.rs"
    click HC "https://github.com/hatoo/oha/blob/master/src/client.rs"
    click UG "https://github.com/hatoo/oha/blob/master/src/url_generator.rs"
    click MS "https://github.com/hatoo/oha/blob/master/src/monitor.rs"
    click RP "https://github.com/hatoo/oha/blob/master/src/result_data.rs"
    click DB "https://github.com/hatoo/oha/blob/master/src/db.rs"
    click HG "https://github.com/hatoo/oha/blob/master/src/histogram.rs"
    click TM "https://github.com/hatoo/oha/blob/master/src/timescale.rs"
    click RNG "https://github.com/hatoo/oha/blob/master/src/pcg64si.rs"
    click Tests "https://github.com/hatoo/oha/blob/master/tests/tests.rs"
    click PGO "https://github.com/hatoo/oha/blob/master/pgo/server/src/main.rs"

    %% Style Applications
    class CLI,TUI ui
    class LGC,HC,UG,MS,TM,RNG processing
    class RP,DB,HG data
    class PGO,Tests external
    class Tests,PGO optional

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        PROC_L["Processing"]:::processing
        DATA_L["Data Storage"]:::data
        EXT_L["External Systems"]:::external
        OPT_L["Optional Components"]:::optional
    end
```
