# kanatti/locust-shadow architecture

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

- Interactive diagram: https://gitdiagram.com/kanatti/locust-shadow
- Repository: https://github.com/kanatti/locust-shadow

## Overview

##### Main Components

A. Source Components:
- Production Log Sources
- Log Processing Pipeline
- Minute-Batch Storage (File/S3-based, as seen in the request_provider directory)

B. Core Components:
- Locust Master Node
- Locust Worker Nodes
- Request Providers (File and S3 implementations)
- Shadow Configuration System

C. Target Components:
- Target System (Production Shadow)
- Echo Server (for testing/development)

**[Input Layer]**
- Production Logs
- Minute Batch Storage (S3/File)
- Configuration Files (yaml)

**[Processing Layer]**
- Locust Master
- Shadow Configuration
- Request Provider System
- File Provider
- S3 Provider
- Locust Workers
- Strict RPS Control
- Warmup Functionality

**[Output Layer]**
- Target System
- Monitoring/Metrics

##### Key Relationships to Highlight

- Data flow from production logs through the minute batch processing
- Relationship between Locust Master and Workers
- Demonstrate how request providers interact with storage systems
- Synchronization mechanism between components

##### Implementation Details

- Separation between the core locust-shadow package and supporting components
- Warmup functionality as a distinct feature
- Shadow configuration flow
- Demonstrate the minute batch processing pipeline

##### Technical Notes

- Python-based implementation
- Locust as the core load testing framework
- Support for both file and S3-based request sources
- Distributed architecture with master/worker pattern
- Configuration-driven behavior

##### Additional Elements

Annotations for:
- Package versions and dependencies
- Configuration file formats
- API endpoints and protocols
- Monitoring points
- Scaling capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        ProdLogs[Production Logs]
        MinuteBatch["Minute Batch Storage"]:::storage
        ConfigFiles["Configuration Files"]:::config
    end

    subgraph Processing
        subgraph MasterNode["Locust Master Node"]
            ShadowConfig["Shadow Configuration"]:::config
            RequestProviderSystem["Request Provider System"]:::core
            
            subgraph Providers["Provider Implementations"]
                FileProvider["File Provider"]:::provider
                S3Provider["S3 Provider"]:::provider
                BaseProvider["Base Provider"]:::provider
            end
            
            ShadowCore["Core Shadow System"]:::core
            Runner["Runner System"]:::core
        end

        subgraph Workers["Locust Workers"]
            StrictRPS["Strict RPS Control"]:::core
            WarmupSystem["Warmup System"]:::core
        end
    end

    subgraph Output
        TargetSystem["Target System"]
        EchoServer["Echo Server"]:::testing
        Monitoring["Monitoring/Metrics"]
    end

    %% Relationships
    ProdLogs --> MinuteBatch
    MinuteBatch --> RequestProviderSystem
    ConfigFiles --> ShadowConfig
    
    RequestProviderSystem --> Providers
    BaseProvider --> FileProvider
    BaseProvider --> S3Provider
    
    ShadowConfig --> ShadowCore
    ShadowCore --> Runner
    Runner --> Workers
    
    Workers --> TargetSystem
    Workers --> EchoServer
    Workers --> Monitoring

    %% Styling
    classDef storage fill:#3498db
    classDef config fill:#f1c40f
    classDef core fill:#2ecc71
    classDef provider fill:#9b59b6
    classDef testing fill:#e74c3c

    %% Click Events
    click RequestProviderSystem "https://github.com/kanatti/locust-shadow/tree/main/packages/locust-shadow/src/locust_shadow/request_provider/"
    click BaseProvider "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/request_provider/base.py"
    click FileProvider "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/request_provider/file.py"
    click S3Provider "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/request_provider/s3.py"
    click ShadowConfig "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/config.py"
    click ShadowCore "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/shadow.py"
    click StrictRPS "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/strict_rps.py"
    click WarmupSystem "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/warmup.py"
    click EchoServer "https://github.com/kanatti/locust-shadow/blob/main/packages/echo-server/src/echo_server/main.py"
    click MinuteBatch "https://github.com/kanatti/locust-shadow/blob/main/docs/minute_batch.md"
    click Runner "https://github.com/kanatti/locust-shadow/blob/main/packages/locust-shadow/src/locust_shadow/runner.py"
```
