# mountu0/pivpncustom architecture

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

- Interactive diagram: https://gitdiagram.com/mountu0/pivpncustom
- Repository: https://github.com/mountu0/pivpncustom

## Overview

##### Main Components Identification

The system appears to be a command-line tool for managing VPN configurations, supporting both OpenVPN and WireGuard protocols. Here's how to structure the main components:

##### Key Architectural Elements

a. Installation Layer:
- Auto-installation script system
- Pre-check mechanisms
- System configuration handlers

b. VPN Protocol Handlers:
- OpenVPN management subsystem
- WireGuard management subsystem
- Shared resources and utilities

c. System Services:
- Systemd service management
- Init.d scripts
- Unbound DNS resolver integration

**[User Interface Layer]**

- Command Line Interface
- OpenVPN Commands
- WireGuard Commands

**[Core Management Layer]**

- Installation Manager
- System Checks
- Configuration Setup

- VPN Protocol Handlers
- OpenVPN Manager
- Client Management
- Certificate Authority

- WireGuard Manager
- Peer Management
- Key Management

**[System Integration Layer]**

- Service Management
- Systemd Services
- Init Scripts

- Network Services
- DNS Resolution (Unbound)
- Network Configuration

##### Important Details to Highlight

a. Configuration Flow:
- How the installation process configures the system
- Relationship between command-line tools and their respective VPN backends
- Demonstrate how client/peer management works for both protocols

b. Security Components:
- Certificate management for OpenVPN
- Key management for WireGuard
- System security configurations

c. Integration Points:
- System service management
- Network configuration
- DNS resolution

##### Implementation Notes

- Clear hierarchical representation
- Exportable format for documentation

Remember to:
- Version information and date
- Document any assumptions or limitations

This system design should emphasize the modular nature of the project, showing how the different components interact while maintaining separation of concerns between the VPN protocols and system management functions.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        CLI["Command Line Interface"]:::ui
        OVPNCMD["OpenVPN Commands"]:::ui
        WGCMD["WireGuard Commands"]:::ui
        CLI --> OVPNCMD
        CLI --> WGCMD
    end

    subgraph Core["Core Management Layer"]
        InstallMgr["Installation Manager"]:::core
        SysCheck["System Checks"]:::core
        ConfigSetup["Configuration Setup"]:::core
        
        subgraph VPNHandlers["VPN Protocol Handlers"]
            OVPN["OpenVPN Manager"]:::vpn
            WG["WireGuard Manager"]:::vpn
            
            subgraph OVPNComp["OpenVPN Components"]
                ClientMgmtOVPN["Client Management"]:::vpn
                CertAuth["Certificate Authority"]:::vpn
                OVPNDebug["Debug Tools"]:::vpn
                OVPNConfig["Server Configuration"]:::vpn
            end
            
            subgraph WGComp["WireGuard Components"]
                PeerMgmt["Peer Management"]:::vpn
                KeyMgmt["Key Management"]:::vpn
                WGDebug["Debug Tools"]:::vpn
                WGConfig["Service Configuration"]:::vpn
            end
        end
        
        BackupSys["Backup System"]:::core
        UpdateSys["Update System"]:::core
        SelfCheck["System Check"]:::core
        Uninstaller["Uninstaller"]:::core
    end

    subgraph SysInt["System Integration Layer"]
        ServiceMgmt["Service Management"]:::system
        SysdServices["Systemd Services"]:::system
        InitScripts["Init Scripts"]:::system
        
        NetServices["Network Services"]:::system
        DNSResolver["DNS Resolution"]:::system
        NetConfig["Network Configuration"]:::system
    end

    %% Connections
    CLI --> InstallMgr
    InstallMgr --> SysCheck
    InstallMgr --> ConfigSetup
    
    OVPNCMD --> OVPN
    WGCMD --> WG
    
    OVPN --> ClientMgmtOVPN
    OVPN --> CertAuth
    OVPN --> OVPNDebug
    OVPN --> OVPNConfig
    
    WG --> PeerMgmt
    WG --> KeyMgmt
    WG --> WGDebug
    WG --> WGConfig
    
    VPNHandlers --> ServiceMgmt
    ServiceMgmt --> SysdServices
    ServiceMgmt --> InitScripts
    ServiceMgmt --> NetServices
    NetServices --> DNSResolver
    NetServices --> NetConfig

    %% Click Events
    click InstallMgr "https://github.com/MountU0/pivpnCustom/blob/master/auto_install/install.sh"
    click SysCheck "https://github.com/MountU0/pivpnCustom/blob/master/ciscripts/pre_checks.sh"
    click OVPN "https://github.com/MountU0/pivpnCustom/blob/master/scripts/openvpn/pivpn.sh"
    click ClientMgmtOVPN "https://github.com/MountU0/pivpnCustom/blob/master/scripts/openvpn/makeOVPN.sh"
    click OVPNDebug "https://github.com/MountU0/pivpnCustom/blob/master/scripts/openvpn/pivpnDebug.sh"
    click OVPNConfig "https://github.com/MountU0/pivpnCustom/blob/master/files/etc/openvpn/server_config.txt"
    click WG "https://github.com/MountU0/pivpnCustom/blob/master/scripts/wireguard/pivpn.sh"
    click PeerMgmt "https://github.com/MountU0/pivpnCustom/blob/master/scripts/wireguard/makeCONF.sh"
    click WGDebug "https://github.com/MountU0/pivpnCustom/blob/master/scripts/wireguard/pivpnDEBUG.sh"
    click WGConfig "https://github.com/MountU0/pivpnCustom/blob/master/files/etc/systemd/system/wg-quick@.service.d/override.conf"
    click InitScripts "https://github.com/MountU0/pivpnCustom/tree/master/files/etc/init.d/wg-quick"
    click DNSResolver "https://github.com/MountU0/pivpnCustom/blob/master/files/etc/unbound/unbound.conf.d/recursive_verifying_resolver.conf"
    click BackupSys "https://github.com/MountU0/pivpnCustom/blob/master/scripts/backup.sh"
    click UpdateSys "https://github.com/MountU0/pivpnCustom/blob/master/scripts/update.sh"
    click SelfCheck "https://github.com/MountU0/pivpnCustom/blob/master/scripts/self_check.sh"
    click Uninstaller "https://github.com/MountU0/pivpnCustom/blob/master/scripts/uninstall.sh"

    %% Styles
    classDef ui fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef core fill:#48a9a6,stroke:#000,stroke-width:2px,color:#fff
    classDef vpn fill:#4ea5d9,stroke:#000,stroke-width:2px,color:#fff
    classDef system fill:#e4572e,stroke:#000,stroke-width:2px,color:#fff
```
