# gigachad80/gwencat-lan architecture

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

- Interactive diagram: https://gitdiagram.com/gigachad80/gwencat-lan
- Repository: https://github.com/gigachad80/gwencat-lan

## Overview

##### Project Type and Purpose
- This is a single‐binary, Go‐based CLI utility for high‐performance file transfers over TCP in LANs.
- It auto‐detects send/receive modes, streams files with progress updates, verifies integrity with SHA256, and handles network timeouts and IP filtering.

##### File Structure
- Top‐level files only:
- go.mod – Go module definition
- gwencat-lan.go – entire application source
- README.md, LICENSE
- No separate frontend/backend or microservices—this is a monolithic CLI tool.

##### README for Insights
- Describes core features: auto‐mode detection, cross‐platform, progress, verification, resilience, IP filtering.
- Uses only Go’s standard library (zero external dependencies).

a. Main Components
- CLI Parser
- Mode Detector
- Sender Module
- Receiver Module
- File I/O Subsystem
- Network I/O Subsystem
- SHA256 Integrity Verifier
- Progress Monitor
- Timeout & Error Handler
- IP Filter
- Underlying LAN / TCP Network

b. Relationships & Data Flows
1. User invokes `gwencat-lan` with flags → CLI Parser reads arguments.
2. Mode Detector checks local file existence or `-mode` override → branches to Sender or Receiver.
3. Sender Module:
- Opens local file (File I/O).
- Streams chunks over TCP (Network I/O) → Progress Monitor updates stats.
- Feeds data to SHA256 Verifier as it streams.
- Handles send‐side timeouts and errors.
4. Receiver Module:
- Listens on specified port (Network I/O) → accepts connection (subject to IP Filter).
- Writes incoming chunks to file (File I/O).
- Feeds data to SHA256 Verifier.
- Monitors progress and handles timeouts.
5. Upon completion, Verifier compares local checksum vs remote (embedded or negotiated) → success/failure output.

c. Architectural Patterns & Principles
- Monolithic but modularized internally into distinct packages/modules (in one file).
- Pipeline pattern for streaming + verification + monitoring.
- Fail‐fast and graceful error handling with timeouts.
- Single‐threaded or goroutine‐based streaming loops.

d. Key Technologies / Libraries
- Go standard library: flag, os, net, io, bufio, crypto/sha256, time.
- No external dependencies ensures a single portable binary.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI invocation
    CLI["User: gwencat-lan CLI"]:::external
    CLI -->|"flags|args"| CLIParser

    %% Parsing & Mode Detection
    CLIParser["CLI Parser"]:::parser
    CLIParser --> ModeDetector
    ModeDetector["Mode Detector"]:::parser

    %% Branch to Send or Receive
    ModeDetector -->|file exists or -mode send| SenderModule
    ModeDetector -->|no file or -mode receive| ReceiverModule

    %% Sender flow
    SenderModule["Sender Module"]:::module
    SenderModule -->|open file| FileIO_Sender
    SenderModule -->|stream chunks| NetworkIO_Sender
    NetworkIO_Sender["Network I/O Subsystem"]:::subsystem
    FileIO_Sender["File I/O Subsystem"]:::subsystem
    FileIO_Sender -->|file chunks| NetworkIO_Sender
    NetworkIO_Sender -->|TCP stream| Progress_Sender
    Progress_Sender["Progress Monitor"]:::monitor
    SenderModule -->|data to| Verifier_Sender
    Verifier_Sender["SHA256 Integrity Verifier"]:::verifier
    Progress_Sender --> Verifier_Sender
    NetworkIO_Sender -.->|handles| TimeoutHandler
    SenderModule -.->|error| TimeoutHandler

    %% Receiver flow
    ReceiverModule["Receiver Module"]:::module
    NetworkIO_Receiver["Network I/O Subsystem"]:::subsystem
    ReceiverModule --> NetworkIO_Receiver
    NetworkIO_Receiver -->|accept connection| IPFilter
    IPFilter["IP Filter"]:::filter
    IPFilter -->|incoming chunks| FileIO_Receiver
    FileIO_Receiver["File I/O Subsystem"]:::subsystem
    FileIO_Receiver -->|write chunks| Progress_Receiver
    Progress_Receiver["Progress Monitor"]:::monitor
    ReceiverModule -->|data to| Verifier_Receiver
    Verifier_Receiver["SHA256 Integrity Verifier"]:::verifier
    Progress_Receiver --> Verifier_Receiver
    NetworkIO_Receiver -.->|handles| TimeoutHandler
    ReceiverModule -.->|error| TimeoutHandler

    %% Completion & Output
    Verifier_Sender -->|checksum compare| CLIOutput
    Verifier_Receiver -->|checksum compare| CLIOutput
    CLIOutput["CLI Output\\nSuccess/Failure"]:::external

    %% Shared components
    TimeoutHandler["Timeout & Error Handler"]:::handler

    %% Project files
    subgraph "Project Files"
        GoMod["go.mod"]:::config
        Readme["README.md"]:::doc
        License["LICENSE"]:::doc
    end

    %% Click Events
    click CLIParser "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click ModeDetector "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click SenderModule "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click ReceiverModule "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click FileIO_Sender "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click FileIO_Receiver "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click NetworkIO_Sender "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click NetworkIO_Receiver "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click Verifier_Sender "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click Verifier_Receiver "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click Progress_Sender "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click Progress_Receiver "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click TimeoutHandler "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click IPFilter "https://github.com/gigachad80/gwencat-lan/blob/main/gwencat-lan.go"
    click GoMod "https://github.com/gigachad80/gwencat-lan/blob/main/go.mod"
    click Readme "https://github.com/gigachad80/gwencat-lan/blob/main/README.md"
    click License "https://github.com/gigachad80/gwencat-lan/tree/main/LICENSE"

    %% Styles
    classDef parser fill:#FFD580,stroke:#FFB347,stroke-width:2px
    classDef module fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px
    classDef subsystem fill:#ADD8E6,stroke:#1E90FF,stroke-width:2px
    classDef verifier fill:#E6E6FA,stroke:#9370DB,stroke-width:2px
    classDef monitor fill:#90EE90,stroke:#32CD32,stroke-width:2px
    classDef handler fill:#FFA07A,stroke:#FF4500,stroke-width:2px
    classDef filter fill:#FFFACD,stroke:#FFD700,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#A9A9A9,stroke-width:2px,stroke-dasharray: 5 5
    classDef config fill:#F0E68C,stroke:#BDB76B,stroke-width:2px
    classDef doc fill:#F5F5F5,stroke:#808080,stroke-width:1px,stroke-dasharray: 2 2
```
