# andrewrk/poop architecture

> Architecture diagram of the GitHub repository andrewrk/poop, 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/andrewrk/poop
- Repository: https://github.com/andrewrk/poop

## Overview

##### Project Type Identification
This is a specialized command-line tool focused on performance monitoring, specifically using Linux's `perf_event_open` functionality. It's a standalone executable written in Zig.

##### Main Components

a. Core Components:
- Command Input Handler
- Perf Event Monitor (using perf_event_open)
- Performance Data Collector
- Terminal UI Renderer
- Command Execution Engine

b. Data Flow Components:
- Hardware Counter Collectors (6 different metrics)
- Memory Usage Monitor
- Performance Data Aggregator
- Results Comparator

**┌─ User Input ─────────────────────────────────┐**

- Command Arguments + Duration Setting      │

- ┬───────────────────────────┘
- ▼
**┌─ Core Engine ────────────────────────────────┐**
- ┌─────────────┐        ┌────────────────┐   │
- Command   │◄─────► │  Perf Event    │   │
- Executor   │        │    Monitor     │   │
- ┘        └────────────────┘   │
- ▲                      │            │
- ▼            │
- ┌─────────────┐        ┌────────────────┐   │
- Results   │◄─────  │  Performance   │   │
- Comparator  │        │ Data Collector │   │
- ┘        └────────────────┘   │
- ┬───────────────────────────┘
- ▼
**┌─ Output ───────────────────────────────────┐**

- Colorful Terminal UI Display        │

- ┘

##### Important Elements to Highlight
- Linux-specific components (perf_event_open integration)
- Hardware counter collection points
- Command execution isolation (no shell involvement)
- Reference command comparison flow

**┌─ Hardware Counters ─┐**
- Counter 1         │
- Counter 2         │──┐
- Counter 3         │  │
- Counter 4         │  │
- Counter 5         │  │
- ┘   │
- ▼
**┌─ Memory Monitor ┐   ┌─ Data Aggregator ─┐**
- Peak Usage      │──►│                   │
- ┘    │  Metrics Merger   │

**┌─ Time Monitor ─┐    └─────────┬────────┘**
- Duration       │──────────────┘
- ┘

##### Implementation Details to Note
- Separation between the reference command and comparison commands
- Default 5000ms duration parameter
- Colorful TUI output component
- Linux-specific dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        UserInput["Command Arguments + Duration Setting"]
    end

    subgraph CoreEngine["Core Engine"]
        direction TB
        CmdExec["Command Executor"]:::exec
        PerfMon["Perf Event Monitor"]:::perf
        DataCol["Performance Data Collector"]:::collector
        ResCmp["Results Comparator"]:::comparator

        CmdExec <--> PerfMon
        PerfMon --> DataCol
        DataCol --> ResCmp
    end

    subgraph HWMonitoring["Hardware Monitoring"]
        direction TB
        Counter1["Counter 1"]:::counter
        Counter2["Counter 2"]:::counter
        Counter3["Counter 3"]:::counter
        Counter4["Counter 4"]:::counter
        Counter5["Counter 5"]:::counter
        MemMon["Memory Monitor"]:::memory
        TimeMon["Time Monitor"]:::time

        Counter1 & Counter2 & Counter3 & Counter4 & Counter5 --> DataAgg
        MemMon --> DataAgg
        TimeMon --> DataAgg
        DataAgg["Data Aggregator"]:::aggregator
    end

    subgraph Output
        TUI["Colorful Terminal UI Display"]:::ui
    end

    UserInput --> CmdExec
    DataAgg --> DataCol
    ResCmp --> TUI

    %% Styling
    classDef exec fill:#90EE90
    classDef perf fill:#FFB347
    classDef collector fill:#98FB98
    classDef comparator fill:#87CEEB
    classDef counter fill:#FFA07A
    classDef memory fill:#DDA0DD
    classDef time fill:#F0E68C
    classDef aggregator fill:#B0C4DE
    classDef ui fill:#98FB98

    %% Click events
    click CmdExec "https://github.com/andrewrk/poop/blob/main/src/main.zig"
    click PerfMon "https://github.com/andrewrk/poop/blob/main/src/main.zig"
    click DataCol "https://github.com/andrewrk/poop/blob/main/src/main.zig"
    click TUI "https://github.com/andrewrk/poop/blob/main/src/progress.zig"

    %% Legend
    subgraph Legend
        L1["Command Processing"]:::exec
        L2["Performance Monitoring"]:::perf
        L3["Data Collection"]:::collector
        L4["Results Processing"]:::comparator
        L5["Hardware Counters"]:::counter
        L6["Memory Monitoring"]:::memory
        L7["Time Monitoring"]:::time
        L8["Data Aggregation"]:::aggregator
        L9["User Interface"]:::ui
    end
```
