# briankohler/stunnel-openvpn architecture

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

- Interactive diagram: https://gitdiagram.com/briankohler/stunnel-openvpn
- Repository: https://github.com/briankohler/stunnel-openvpn

## Overview

##### Project Overview and Main Components
- The project provisions a remote OpenVPN server on DigitalOcean using Terraform, and it automatically connects a macOS client (with prerequisites like Tunnelblick and Homebrew) to the VPN via an STunnel wrapper.
- Key components include:
- Client Side: macOS machine running Tunnelblick (the VPN client).
- Provisioning Layer: Shell scripts (create.sh, destroy.sh) to trigger infrastructure provisioning and teardown.
- Infrastructure Management: Terraform script (digitalocean.tf) to provision a DigitalOcean droplet.
- Configuration Management: Puppet modules (within the puppet directory including Puppetfile, and rpm packages such as firehol.rpm, iprange.rpm, netdata.rpm, along with the site.pp file) that configure the droplet.
- Server Services: OpenVPN and STunnel installed on the provisioned remote server, as well as any auxiliary services (possibly monitored by Netdata) and additional security/firewall setups.

##### Architectural Relationships and Interactions
- The process begins with the user running create.sh, which calls Terraform (via digitalocean.tf) to create a droplet on DigitalOcean.
- Once the droplet is provisioned, Puppet is used (with files in the puppet directory and site.pp) to configure the server—this involves:
- Generating new SSH keys and SSL certificates.
- Installing and configuring STunnel to wrap OpenVPN connections so that they mimic normal HTTPS traffic.
- The userdata.sh script likely acts as an initialization script that runs on the new server to drive these configurations.
- The client (macOS) then connects using Tunnelblick, which interfaces with the server’s OpenVPN/STunnel setup.
- Optionally, destroy.sh is provided for tearing down the infrastructure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Provisioning and Orchestration Subgraph
    subgraph "Provisioning & Orchestration"
        A["create.sh"]:::provisioning
        B["destroy.sh"]:::provisioning
        C["digitalocean.tf"]:::provisioning
        D["userdata.sh"]:::provisioning
    end

    %% Configuration Management Subgraph
    subgraph "Configuration Management"
        E["Puppet Modules"]:::config
        F["site.pp"]:::config
    end

    %% Server Subgraph
    subgraph "Server"
        G["DigitalOcean Droplet"]:::server
        H["VPN Service (OpenVPN + STunnel)"]:::server
    end

    %% Client Node
    I["Client (macOS, Tunnelblick)"]:::client

    %% Connections/Flow
    A -->|"invoke"| C
    C -->|"provisions"| G
    G -->|"initializes via"| D
    D -->|"triggers configuration"| E
    E -->|"applies config using"| F
    E -->|"configures"| G
    G -->|"runs"| H
    I -->|"connects"| H
    B ---|"teardown"| G

    %% Click Events
    click A "https://github.com/briankohler/stunnel-openvpn/blob/master/create.sh"
    click B "https://github.com/briankohler/stunnel-openvpn/blob/master/destroy.sh"
    click C "https://github.com/briankohler/stunnel-openvpn/blob/master/digitalocean.tf"
    click D "https://github.com/briankohler/stunnel-openvpn/blob/master/userdata.sh"
    click E "https://github.com/briankohler/stunnel-openvpn/tree/master/puppet"
    click F "https://github.com/briankohler/stunnel-openvpn/blob/master/site.pp"

    %% Styles
    classDef provisioning fill:#f3e5ab,stroke:#333,stroke-width:2px,color:#000;
    classDef config fill:#c3e5ff,stroke:#333,stroke-width:2px,color:#000;
    classDef server fill:#d5ffe5,stroke:#333,stroke-width:2px,color:#000;
    classDef client fill:#ffdfd5,stroke:#333,stroke-width:2px,color:#000;
```
