# anirudhsudhir/snoopy architecture

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

- Interactive diagram: https://gitdiagram.com/anirudhsudhir/snoopy
- Repository: https://github.com/anirudhsudhir/snoopy

## Overview

##### Project Type & Purpose
- Snoopy is a network tool that implements a VPN. It leverages Rust’s capabilities for network programming.
- The project is structured as a command-line application (with a clear entry point in src/main.rs) that uses additional library code (src/lib.rs) to encapsulate VPN functionality.
- It is also containerized via a Dockerfile, which indicates it can run in isolated environments and demonstrate connectivity (as shown by the netcat demo).

##### File Structure
- Top-level files and directories:
- Cargo.toml, Cargo.lock: Indicates the Rust project structure and dependency management.
- src/ directory: Contains main.rs (the application entry point) and lib.rs (likely where the VPN logic is implemented).
- Dockerfile: Suggests container deployment.
- Makefile: May be used for build automation.
- This structure points to a clean separation between application code (core VPN functionality) and deployment (containerization, build automation).

##### Reading the README
- The README informs us that Snoopy operates as a VPN and demonstrates connectivity between a host and a container via virtual network (tun interface) settings.
- The demo details (physical and virtual IP addresses) imply that the system design should clearly represent both local (host) and virtual (container-based) network interfaces.

a. Main Components:
- Snoopy VPN Application:
- Main Application (src/main.rs) – handles runtime concerns.
- VPN Library (src/lib.rs) – encapsulates the core VPN features.
- Deployment Components:
- Docker Container – showing where the VPN code is run in a containerized environment.
- Host System – the physical machine running the host’s VPN client, netcat, and other tools.
- Networking Components:
- Virtual Network Interfaces (tun interfaces) – indicate the virtual IPs (10.0.0.2 on host and 10.0.0.3 in container).
- Physical Interfaces – the actual network connectivity (e.g., 192.168.97.x addresses).

b. Relationships and Interactions:
- The Snoopy application runs inside a Docker container and interacts with the host via its configured tun interface.
- From the Host (producing network traffic via netcat) → to the Container’s virtual network interface.
- Inside the container, highlight how the VPN application routes traffic over the virtual tunnel.
- That the VPN library encapsulates the logic for handling the VPN’s network packets, possibly interfacing with OS-level tun operations.

c. Architectural Patterns & Design Principles:
- Separation of concerns:
- Application entry: main.rs
- Core functionality: lib.rs
- Containerization: Dockerfile alongside deployment artifacts.
- That the design leverages standard Rust project organization and container-based deployment, which is common in microservices or network daemons.

d. Relevant Technologies & Frameworks:
- Rust (for system implementation).
- Docker (for container orchestration).
- Networking (tun interfaces, netcat for demo/testing).
- Build and package tools such as Cargo and Make.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Deployment & Build Artifacts
    subgraph "Deployment & Build"
        ct("Cargo.toml"):::deployment
        cl("Cargo.lock"):::deployment
        ma("Makefile"):::deployment
        doc("Dockerfile"):::deployment
        res("Demo Assets (resources)"):::deployment
    end

    %% Container Environment with Snoopy VPN Application
    subgraph "Container Environment"
        subgraph "Docker Container"
            subgraph "Snoopy VPN Application"
                main("Entry Point (main.rs)"):::code
                library("Core VPN Engine (lib.rs)"):::code
            end
            vnetC("Virtual Interface (10.0.0.3)"):::network
        end
    end

    %% Host System
    subgraph "Host System"
        phys("Physical Interface (192.168.97.x)"):::system
        vnetH("Virtual Interface (10.0.0.2)"):::network
        netcat("Netcat Demo"):::system
    end

    %% Network Interactions
    netcat -->|"sendsTraffic"| vnetH
    vnetH -->|"tunnelConnects"| vnetC
    vnetC -->|"forwardsPackets"| main
    main -->|"callsVPNLogic"| library

    %% Build/Deployment Support Connections
    doc -->|"deploys"| main
    ct -->|"dependency"| main
    cl -->|"dependency"| main
    ma -->|"builds"| main
    res -->|"supportsDemo"| netcat

    %% Click Events
    click main "https://github.com/anirudhsudhir/snoopy/blob/main/src/main.rs"
    click library "https://github.com/anirudhsudhir/snoopy/blob/main/src/lib.rs"
    click doc "https://github.com/anirudhsudhir/snoopy/tree/main/Dockerfile"
    click ct "https://github.com/anirudhsudhir/snoopy/blob/main/Cargo.toml"
    click cl "https://github.com/anirudhsudhir/snoopy/blob/main/Cargo.lock"
    click ma "https://github.com/anirudhsudhir/snoopy/tree/main/Makefile"
    click res "https://github.com/anirudhsudhir/snoopy/tree/main/resources"

    %% Styles
    classDef deployment fill:#E0F7FA,stroke:#006064,stroke-width:2px;
    classDef code fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef network fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef system fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
```
