# yaronsumel/piper architecture

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

- Interactive diagram: https://gitdiagram.com/yaronsumel/piper
- Repository: https://github.com/yaronsumel/piper

## Overview

##### Main Components
- Client Module: Represented by client.go. This component is responsible for connecting to a remote server (via TLS), receiving the forwarded stdout stream, and outputting it (e.g., redirecting it to a log file).
- Server Module: Represented by server.go (and main.go for overall orchestration). The server listens on a specified TCP port (e.g., 8080) and accepts connections. It reads data piped from the process’s stdout and sends it to any connected clients.
- Storage/Buffer Component: storage.go likely implements some form of temporary data management or buffering. Although “storage” might not be as complex as a database, represent it as a module that handles log persistence or transient storage if applicable.
- TLS Security Layer: Although not a separate file, the tool’s documentation emphasizes secure (TLS) connections. Include a security component that covers the TLS handshake, certificate verification/management, and encryption/decryption of data streams.

##### Component Interactions and Data Flow
- Data Source Integration: Show an external process (e.g., “tail -f log.txt”) piping its stdout into the piper server application.
- Client Operation: On the client side, illustrate a connection being established to the server. Once the TLS handshake is complete, the client receives data which it then outputs (e.g., sending the received log stream to standard output or a file).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The design cleanly separates roles (server for ingestion and forwarding, client for connecting and receiving data, storage for buffering/log management).
- Command-line / Pipeline Integration: Demonstrate how the tool integrates into UNIX pipelines (illustrate “tail -f log.txt | piper -a 0.0.0.0:8080” for the server and “piper -a remotehost:8080 > log.txt” for the client).

##### Relevant Technologies
- Go (as the programming language with modules go.mod and go.sum)
- TLS libraries (the Go standard library’s crypto/tls)
- Command-line interface (CLI) design principles

##### Detailed Labeling and Data Flows
- Flow of data (from stdout through the server, across the secure channel, to the client).
- Optionally, include annotations for specific technical details (like TLS usage, command-line usage, and any storage buffering logic) to provide a complete picture.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Process
    EP["tail -f log.txt"]:::external

    %% Piper Server Subgraph
    subgraph "Piper Server"
        S1["server.go"]:::server
        M1["main.go"]:::server
        ST1["storage.go"]:::storage
    end

    %% TLS Security Layer
    TLS["TLS Security Layer"]:::security

    %% Piper Client Subgraph
    subgraph "Piper Client"
        C1["client.go"]:::client
    end

    %% CI/CD / Deployment Subgraph
    subgraph "CI/CD / Deployment"
        CD1[".github/workflows/codeql-analysis.yml"]:::cicd
        CD2[".github/dependabot.yml"]:::cicd
    end

    %% Data Flow
    EP -->|"pipes_stdout"| S1
    S1 -->|"buffers_data"| ST1
    S1 -->|"orchestrates_via"| M1
    S1 -->|"forwards_encrypted"| TLS
    TLS -->|"secure_channel"| C1
    C1 -->|"outputs_to"| C1

    %% Optional: CI/CD influencing deployment (not data flow, just annotation)
    CD1 ---|"triggers_deployments"| S1
    CD2 ---|"monitors_updates"| S1

    %% Click Events
    click C1 "https://github.com/yaronsumel/piper/blob/master/client.go"
    click S1 "https://github.com/yaronsumel/piper/blob/master/server.go"
    click M1 "https://github.com/yaronsumel/piper/blob/master/main.go"
    click ST1 "https://github.com/yaronsumel/piper/blob/master/storage.go"
    click CD1 "https://github.com/yaronsumel/piper/blob/master/.github/workflows/codeql-analysis.yml"
    click CD2 "https://github.com/yaronsumel/piper/blob/master/.github/dependabot.yml"

    %% Styles
    classDef external fill:#FFEFBA,stroke:#F39C12,stroke-width:2px;
    classDef server fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef storage fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef security fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef client fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef cicd fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
```
