# felipeneuwald/stressy architecture

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

- Interactive diagram: https://gitdiagram.com/felipeneuwald/stressy
- Repository: https://github.com/felipeneuwald/stressy

## Overview

##### Project type and purpose
- This is an open-source, command-line CPU stress-test tool written in Go.
- Its sole purpose is to spawn cryptographic computations on one or more CPU cores to simulate load.
- It ships as a standalone binary and as a Docker container, with cross-platform and multi-arch support.

##### File structure
- Top-level files:
- Dockerfile – builds container image
- .goreleaser.yaml – config for multi-arch binary/Docker releases
- GitHub workflows – CI/CD for releases and vulnerability scans
- cmd/main.go – CLI entrypoint
- internal/flag – flag parsing, environment binding, validation
- internal/stressy – core stress logic (worker creation, crypto loops)
- There are no external services or databases. It’s a single process with a worker pool.

##### README for additional insights
- CLI flags (workers, timeout, help, version) and corresponding environment variables
- Usage patterns for both direct binary invocation and Docker
- Build instructions for Go and Docker
- Emphasizes configurability, cross-platform, and CI-driven releases

a. Main components
- CLI Entrypoint (cmd/main.go)
- Configuration Layer (internal/flag):
– Flag definitions
– Environment variable loader
– Validation logic
- Core Stress Engine (internal/stressy):
– Worker pool manager
– Cryptographic CPU workload
– Timeout controller
- OS/Runtime & CPU cores
- Delivery Pipeline:
– GitHub Actions (vuln-scan, goreleaser)
– goreleaser (builds binaries, Docker images)
- Distribution outputs:
– Platform binaries
– Docker images
b. Relationships and interactions
- User invokes CLI or runs Docker → CLI Entrypoint
- CLI Entrypoint calls Configuration Layer → produces runtime settings
- Configuration Layer passes settings to Core Stress Engine
- Stress Engine spawns N workers → each binds to an OS thread/core → runs crypto loop
- Timeout controller signals workers to stop when the timer expires or runs indefinitely
- CI/CD pipeline triggers on tag → runs Go build and Docker build → publishes artifacts
c. Architectural patterns and design principles
- Clear separation of concerns:
– CLI vs. config vs. core logic
- Single-process, multi-threaded worker pool
- Internal packages to prevent API leakage
- Infrastructure as code for builds and releases
d. Relevant technologies and frameworks
- Go modules
- Go’s standard library flag package (wrapped by internal/flag)
- Docker for containerization
- GitHub Actions for CI/CD
- goreleaser for cross-arch builds and publishing

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::external

    subgraph "Execution Paths"
        CLI["CLI Entrypoint"]:::code
        Config["Config Loader<br/>(internal/flag)"]:::code
        Stress["Stress Engine<br/>(internal/stressy)"]:::code
        OS["OS/Runtime & CPU cores"]:::runtime
        DockerContainer["Docker Container"]:::runtime
    end

    User -->|"binary"| CLI
    User -->|"docker run"| DockerContainer
    DockerContainer --> CLI
    CLI -->|"reads flags"| Config
    Config -->|"provides settings"| Stress
    Stress -->|"spawns workers"| OS

    subgraph "CI/CD Pipeline"
        PipelineTrigger["GitHub Actions<br/>Trigger on tag"]:::pipeline
        VulnScan["Vulnerability Scan"]:::pipeline
        ReleaseWorkflow["Release Workflow"]:::pipeline
        GoreleaserTool["goreleaser<br/>(.goreleaser.yaml)"]:::pipeline
        BuildDockerfile["Dockerfile"]:::pipeline
        Artifacts["Artifacts<br/>Binaries & Docker Images"]:::pipeline
    end

    PipelineTrigger --> VulnScan
    PipelineTrigger --> ReleaseWorkflow
    ReleaseWorkflow --> GoreleaserTool
    ReleaseWorkflow --> BuildDockerfile
    GoreleaserTool --> Artifacts
    BuildDockerfile --> Artifacts

    click CLI "https://github.com/felipeneuwald/stressy/blob/main/cmd/main.go"
    click Config "https://github.com/felipeneuwald/stressy/tree/main/internal/flag"
    click Stress "https://github.com/felipeneuwald/stressy/blob/main/internal/stressy/stressy.go"
    click BuildDockerfile "https://github.com/felipeneuwald/stressy/tree/main/Dockerfile"
    click GoreleaserTool "https://github.com/felipeneuwald/stressy/blob/main/.goreleaser.yaml"
    click ReleaseWorkflow "https://github.com/felipeneuwald/stressy/blob/main/.github/workflows/goreleaser.yml"
    click VulnScan "https://github.com/felipeneuwald/stressy/blob/main/.github/workflows/vuln-scan.yml"

    classDef code fill:#cce5ff,stroke:#004085,color:#004085;
    classDef pipeline fill:#d4edda,stroke:#155724,color:#155724;
    classDef runtime fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef external fill:#fefefe,stroke:#333,color:#333;
```
