# anthonyspiteri/project-otosukeru architecture

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

- Interactive diagram: https://gitdiagram.com/anthonyspiteri/project-otosukeru
- Repository: https://github.com/anthonyspiteri/project-otosukeru

## Overview

##### Project type and purpose
- Project Ōtosukēru is an automation/orchestration tool (open-source utility) that dynamically deploys, configures, scales, and destroys Veeam Backup proxies on a VMware vSphere platform using Terraform and PowerShell.

##### Top-level components from the file tree
- Root scripts:
- deploy_otosukeru.ps1 – master orchestration script
- first.ps1 – helper for Windows workgroup setup
- disk_creation.ps1 – (disk setup)
- pre.bat / post.bat – wrappers invoked by Veeam jobs
- Configuration:
- config.json – PowerShell input for VBR & VM credentials
- proxy_ips.json – optional IP management
- proxy_windows/ & proxy_linux/ – Terraform modules for Windows- and Linux-based proxies
- Logs:
- logs/ProjectOtosukeru-Log.txt
- CI/deploy helpers:
- .gitattributes, LICENSE, README.md

A. External systems & services
- Veeam Backup & Replication (VBR) Server (PowerShell snap-in)
- VMware vSphere / vCenter API
- Active Directory domain controller (for domain-joined VMs)
B. Orchestration layer
- User or Veeam job invokes pre.bat → deploy_otosukeru.ps1
- deploy_otosukeru.ps1:
– Reads config.json, command-line flags (–Windows/–Ubuntu/–CentOS/–SetProxies/–Destroy/–ProxyPerHost/–DHCP/–Workgroup)
– Connects to VBR via PowerShell cmdlets
– Determines desired proxy count and scale action
– Generates Terraform variable overrides (proxy count, IP offsets, distro)
– Calls “terraform apply” or “terraform destroy” in proxy_windows/ or proxy_linux/ folders
C. Provisioning layer
- Terraform modules (proxy_windows, proxy_linux):
– main.tf: vSphere provider + VM resource blocks
– anti-affinity_tf: host rules (optional HCI clusters)
– maps.tf (Linux only): firewall commands, template mapping per distro
– output.tf: expose VM names & IPs back to PowerShell
D. Post-provisioning configuration
- Terraform remote-exec or VMware customization: join domain, static/DHCP IPs
- deploy_otosukeru.ps1 picks up outputs and:
– Adds new proxies as managed servers in VBR
– Optionally removes proxies (on scale-down or destroy)
E. Veeam job integration
- pre.bat / post.bat wrap the PS script to run before/after Veeam backup jobs to ensure ephemeral proxies

##### Relationships and data‐flow
1. User/Veeam Job → invokes pre.bat
2. pre.bat → deploy_otosukeru.ps1 reads config + flags
3. PS → ► VBR Server (get jobs)
4. PS → determine count → write TF var file
5. PS → ► “terraform apply/destroy” → vSphere API
6. Terraform → ► VM Templates → create/destroy VMs
7. Terraform remote-exec → join domain, open FW ports
8. Terraform outputs → PS
9. PS → ► VBR Server (Add-VBRManagedServer or Remove-VBRManagedServer)
10. Job runs → uses proxies
11. After job, post.bat (if configured) cleans up

##### Architectural patterns & design principles
- Orchestration pattern: master script delegates provisioning to Terraform, configuration to PowerShell
- Infrastructure as Code (Terraform modules)
- Idempotency: scale up/down logic, destroy workflows
- Modular separation: Windows vs. Linux modules, maps.tf for distro specifics

## Diagram (Mermaid)

```mermaid
flowchart TD
    UV("User/Veeam Job"):::external
    subgraph "Orchestration Layer"
        pre("pre.bat"):::orchestration
        ps("deploy_otosukeru.ps1"):::orchestration
        first("first.ps1"):::orchestration
        disk("disk_creation.ps1"):::orchestration
        post("post.bat"):::orchestration
    end
    subgraph "Configuration Stores"
        cfg("config.json"):::config
        ips("proxy_ips.json"):::config
        logs("logs/ProjectOtosukeru-Log.txt"):::config
    end
    subgraph "Terraform Modules"
        subgraph "Windows Module"
            wmain("main.tf"):::tfmodule
            waff("anti-affinity_tf/"):::tfmodule
            wnoad("otosukeru-1-NoAD_tf/"):::tfmodule
            wdhcp("otosukeru-1-DHCP_tf/"):::tfmodule
            wcore("otosukeru-1.tf"):::tfmodule
            wvars("variables.tf"):::tfmodule
            wtfvars("terraform.tfvars"):::tfmodule
            woutput("output.tf"):::tfmodule
        end
        subgraph "Linux Module"
            lmain("main.tf"):::tfmodule
            laff("anti-affinity_tf/"):::tfmodule
            lmaps("maps.tf"):::tfmodule
            ldhcp("otosukeru-1-DHCP_tf/"):::tfmodule
            lcore("otosukeru-1.tf"):::tfmodule
            lvars("variables.tf"):::tfmodule
            ltftvars("terraform.tfvars"):::tfmodule
            loutput("output.tf"):::tfmodule
        end
    end
    cloudVBR(("VBR Server")):::external
    cloudvcenter(("vSphere/vCenter API")):::external
    clouddc(("AD Domain Controller")):::external

    UV -->|invokes| pre
    pre --> ps
    ps --> cfg
    ps --> ips
    ps --> first
    ps --> disk
    ps --> logs
    ps -->|"generates TF vars"| wtfvars
    ps -->|"generates TF vars"| ltftvars
    ps -->|"terraform apply/destroy"| wmain
    ps -->|"terraform apply/destroy"| lmain
    wmain -->|API call| cloudvcenter
    lmain -->|API call| cloudvcenter
    wmain -->|remote-exec| clouddc
    lmain -->|remote-exec| clouddc
    woutput -->|"TF outputs"| ps
    loutput -->|"TF outputs"| ps
    ps -->|Add/Remove Proxies| cloudVBR
    ps --> post

    click pre "https://github.com/anthonyspiteri/project-otosukeru/blob/master/pre.bat"
    click post "https://github.com/anthonyspiteri/project-otosukeru/blob/master/post.bat"
    click ps "https://github.com/anthonyspiteri/project-otosukeru/blob/master/deploy_otosukeru.ps1"
    click first "https://github.com/anthonyspiteri/project-otosukeru/blob/master/first.ps1"
    click disk "https://github.com/anthonyspiteri/project-otosukeru/blob/master/disk_creation.ps1"
    click cfg "https://github.com/anthonyspiteri/project-otosukeru/blob/master/config.json"
    click ips "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_ips.json"
    click logs "https://github.com/anthonyspiteri/project-otosukeru/blob/master/logs/ProjectOtosukeru-Log.txt"
    click wmain "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_windows/main.tf"
    click waff "https://github.com/anthonyspiteri/project-otosukeru/tree/master/proxy_windows/anti-affinity_tf/"
    click wnoad "https://github.com/anthonyspiteri/project-otosukeru/tree/master/proxy_windows/otosukeru-1-NoAD_tf/"
    click wdhcp "https://github.com/anthonyspiteri/project-otosukeru/tree/master/proxy_windows/otosukeru-1-DHCP_tf/"
    click wcore "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_windows/otosukeru-1.tf"
    click wvars "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_windows/variables.tf"
    click wtfvars "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_windows/terraform.tfvars"
    click woutput "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_windows/output.tf"
    click lmain "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_linux/main.tf"
    click laff "https://github.com/anthonyspiteri/project-otosukeru/tree/master/proxy_linux/anti-affinity_tf/"
    click lmaps "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_linux/maps.tf"
    click ldhcp "https://github.com/anthonyspiteri/project-otosukeru/tree/master/proxy_linux/otosukeru-1-DHCP_tf/"
    click lcore "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_linux/otosukeru-1.tf"
    click lvars "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_linux/variables.tf"
    click ltftvars "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_linux/terraform.tfvars"
    click loutput "https://github.com/anthonyspiteri/project-otosukeru/blob/master/proxy_linux/output.tf"
    click .gitattributes "https://github.com/anthonyspiteri/project-otosukeru/blob/master/.gitattributes"
    click LICENSE "https://github.com/anthonyspiteri/project-otosukeru/tree/master/LICENSE"
    click README.md "https://github.com/anthonyspiteri/project-otosukeru/blob/master/README.md"

    classDef orchestration fill:#D6EAF8,stroke:#1F618D
    classDef config fill:#D5F5E3,stroke:#2E7D32
    classDef external fill:#D5D8DC,stroke:#566573
    classDef tfmodule fill:#FAD7A0,stroke:#B9770E
```
