# hatemosphere/protonvpn-wg-confgen architecture

> Architecture diagram of the GitHub repository hatemosphere/protonvpn-wg-confgen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hatemosphere/protonvpn-wg-confgen
- Repository: https://github.com/hatemosphere/protonvpn-wg-confgen

## Overview

This CLI authenticates to ProtonVPN, selects a suitable server, requests or manages a WireGuard certificate, and writes a usable tunnel configuration. It also supports server/config listing, renewal, revocation, and session-only certificates. The graph combines explicit README workflows with the shown calls; several command setup and VPN request details are excerpted incompletely, so uncertain internal links are omitted.

Main entry points: [`cmd/protonvpn-wg/main.go`](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/cmd/protonvpn-wg/main.go) (Command modes), [`internal/vpn/client.go`](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/vpn/client.go) (VPN API client), [`internal/vpn/servers.go`](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/vpn/servers.go) (Server filtering), [`internal/auth/auth.go`](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/auth/auth.go) (SRP and 2FA login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command line"]
  node_entry["Command modes<br/>[main.go]"]
  node_flags["Flags and validation<br/>[flags.go]"]
end

subgraph group_identity["Authentication"]
  node_auth["SRP and 2FA login<br/>[auth.go]"]
  node_session["Session persistence<br/>[session.go]"]
  node_sessionfile["Private file writes<br/>[write.go]"]
end

subgraph group_vpn["VPN services"]
  node_vpnclient["VPN API client<br/>[client.go]"]
  node_servers["Server filtering<br/>[servers.go]"]
  node_status["V2 server scoring<br/>[serverstatus.go]"]
end

subgraph group_wireguard["Configuration output"]
  node_wgconfig["WireGuard config<br/>[config.go]"]
end

subgraph group_protocol["API protocol"]
  node_apiwire["Wire transport<br/>[wire.go]"]
  node_apitransport["HTTP API helpers<br/>[transport.go]"]
  node_apitypes["API data types<br/>[types.go]"]
end

node_user(("CLI user"))
node_proton{{"ProtonVPN API"}}
node_configfile["WireGuard profile"]

node_user -->|"runs commands"| node_entry
node_entry -->|"parses flags"| node_flags
node_entry -->|"applies plan"| node_vpnclient
node_entry -->|"filters servers"| node_servers
node_entry -->|"generates profile"| node_wgconfig
node_entry -->|"supports list, renew, revoke"| node_proton
node_auth -->|"authenticates"| node_proton
node_auth -->|"persists session"| node_session
node_session -->|"writes session"| node_sessionfile
node_vpnclient -->|"requests VPN data"| node_proton
node_vpnclient -->|"fetches server list"| node_servers
node_servers -->|"ranks v2 servers"| node_status
node_wgconfig -->|"writes profile"| node_configfile
node_apiwire -->|"sends HTTP requests"| node_proton
node_apitransport -.->|"uses transport"| node_apiwire
node_vpnclient -.->|"uses API helpers"| node_apitransport
node_vpnclient -.->|"decodes responses"| node_apitypes

click node_entry "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/cmd/protonvpn-wg/main.go"
click node_flags "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/config/flags.go"
click node_auth "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/auth/auth.go"
click node_session "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/auth/session.go"
click node_sessionfile "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/securefile/write.go"
click node_vpnclient "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/vpn/client.go"
click node_servers "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/vpn/servers.go"
click node_status "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/serverstatus/serverstatus.go"
click node_wgconfig "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/wireguard/config.go"
click node_apiwire "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/api/wire.go"
click node_apitransport "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/api/transport.go"
click node_apitypes "https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/api/types.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_flags,node_user toneBlue
class node_auth,node_session,node_sessionfile toneAmber
class node_vpnclient,node_servers,node_status,node_proton toneMint
class node_wgconfig toneRose
class node_apiwire,node_apitransport,node_apitypes,node_configfile toneIndigo
```

## Components

### Command line

- [Command modes](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/cmd/protonvpn-wg/main.go): `cmd/protonvpn-wg/main.go`
- [Flags and validation](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/config/flags.go): `internal/config/flags.go`

### Authentication

- [SRP and 2FA login](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/auth/auth.go): `internal/auth/auth.go`
- [Session persistence](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/auth/session.go): `internal/auth/session.go`
- [Private file writes](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/securefile/write.go): `internal/securefile/write.go`

### VPN services

- [VPN API client](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/vpn/client.go): `internal/vpn/client.go`
- [Server filtering](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/vpn/servers.go): `internal/vpn/servers.go`
- [V2 server scoring](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/serverstatus/serverstatus.go): `internal/serverstatus/serverstatus.go`

### Configuration output

- [WireGuard config](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/wireguard/config.go): `internal/wireguard/config.go`

### API protocol

- [Wire transport](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/api/wire.go): `internal/api/wire.go`
- [HTTP API helpers](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/api/transport.go): `internal/api/transport.go`
- [API data types](https://github.com/hatemosphere/protonvpn-wg-confgen/blob/main/internal/api/types.go): `internal/api/types.go`

### Other components

- **CLI user**
- **ProtonVPN API**
- **WireGuard profile**

## Connections

- CLI user → Command modes: runs commands (evidence: `README.md`)
- Command modes → Flags and validation: parses flags (evidence: `cmd/protonvpn-wg/main.go`)
- Command modes → VPN API client: applies plan (evidence: `cmd/protonvpn-wg/main.go`)
- Command modes → Server filtering: filters servers (evidence: `cmd/protonvpn-wg/main.go`)
- Command modes → WireGuard config: generates profile (evidence: `cmd/protonvpn-wg/main.go`)
- Command modes → ProtonVPN API: supports list, renew, revoke (evidence: `README.md`)
- SRP and 2FA login → ProtonVPN API: authenticates (evidence: `README.md`)
- SRP and 2FA login → Session persistence: persists session (evidence: `README.md`)
- Session persistence → Private file writes: writes session (evidence: `internal/auth/session.go`)
- VPN API client → ProtonVPN API: requests VPN data (evidence: `README.md`)
- VPN API client → Server filtering: fetches server list (evidence: `internal/vpn/client.go`)
- Server filtering → V2 server scoring: ranks v2 servers (evidence: `README.md`)
- WireGuard config → WireGuard profile: writes profile (evidence: `README.md`)
- Wire transport → ProtonVPN API: sends HTTP requests (evidence: `internal/api/wire.go`)
- HTTP API helpers → Wire transport: uses transport
- VPN API client → HTTP API helpers: uses API helpers
- VPN API client → API data types: decodes responses
