# mikeslattery/tunic architecture

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

- Interactive diagram: https://gitdiagram.com/mikeslattery/tunic
- Repository: https://github.com/mikeslattery/tunic

## Overview

##### Main Components
- Installer Controller: The core logic appears to be implemented in main.go, with additional support from run.py and setup.py. This controller orchestrates the installation process.
- Validator Module: This component validates system requirements (Windows version, disk space, UEFI, etc.) before proceeding.
- UI/Interaction Module: Since Tunic asks the user several questions up front (without “babysitting” the install), a component is dedicated to the user prompt and configuration collection.
- Partition Manager: For dual boot, this handles tasks like shrinking the Windows C: drive (with support from tools/scripting found in files and test folders).
- Download and ISO Management: A networking component that downloads the chosen Linux ISO (from Linux Mint, Ubuntu, etc.).
- Bootloader Setup: Installs and configures Grub with Secure Boot support. The presence of files such as grub.cfg and preseed.cfg, along with tunic.nsi and tunic.ps1, indicates that bootloader configuration and installer packaging are part of the flow.
- Linux Installer Integration: After setup, the system reboots to launch Ubiquity (the Linux installer). This module handles the handover from Windows to Linux installation and may involve auto-configuration (using preseed mechanisms).

##### Out Their Relationships and Interactions
- The Installer Controller is the central hub controlling the workflow.
- The UI/Interaction component gathers initial configuration and options from the user, which it passes to the Controller.
- The Validator ensures that system requirements are met and informs the Controller to proceed or abort.
- If dual boot is selected, the Partition Manager interacts with the Windows disk environment to shrink existing partitions.
- The Download Kit is triggered by the Controller to fetch the required Linux ISO.
- Once all preparations are complete, the Bootloader Setup module configures Grub (using provided configurations and scripts) to add a new boot option for Linux.
- Finally, the system reboots and hands over to the Linux Installer Integration component which manages a seamless transition into the Ubiquity installer (with pre-defined preseed configurations).

##### Architectural Patterns and Design Principles
- Modular separation of concerns: Each task (validation, UI, partitioning, downloading, bootloader configuration, and installer handoff) is encapsulated into its own module/area.
- Script and configuration-driven behavior: The presence of multiple scripts (PowerShell, NSIS, Python, Makefile) and configuration files (grub.cfg, preseed.cfg) suggest that Tunic uses external scripts to complement the Go–based main logic.

##### Relevant Technologies, Frameworks, and Libraries
- Go (for core installer logic).
- Python (likely used for ancillary tasks or orchestration via run.py).
- PowerShell and Batch scripts (for scripting tasks on Windows, as seen in build.ps1, tunic.ps1, and files in test/).
- NSIS (Nullsoft Scriptable Install System) for packaging the installer (as indicated by tunic.nsi).
- External Linux components such as the Ubiquity installer and Grub bootloader.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Pre-Installation Phase
    subgraph "Pre-Installation Phase"
        A["Installer Controller"]:::goModule
        B["Validator Module"]:::goModule
        C["UI/Interaction Module"]:::scriptModule
        D["Partition Manager"]:::scriptModule
        E["Download & ISO Management"]:::scriptModule
    end

    %% Transition Phase
    subgraph "Transition Phase"
        F["Grub Setup"]:::bootModule
        G["NSIS Packaging"]:::bootModule
    end

    %% Installation Phase
    subgraph "Installation Phase"
        H["Linux Installer Integration"]:::installModule
    end

    %% Connections
    C -->|"sendsConfig"| A
    B -->|"validates"| A
    A -->|"triggersPartitioning"| D
    A -->|"initiatesDownload"| E
    A -->|"configuresBootloader"| F
    A -->|"packagesInstaller"| G
    F -->|"handoff/reboot"| H
    G -->|"handoff/reboot"| H

    %% Click Events
    click A "https://github.com/mikeslattery/tunic/blob/master/main.go"
    click B "https://github.com/mikeslattery/tunic/blob/master/main.go"
    click C "https://github.com/mikeslattery/tunic/blob/master/run.py"
    click D "https://github.com/mikeslattery/tunic/tree/master/test/"
    click E "https://github.com/mikeslattery/tunic/blob/master/files/distros.ps1"
    click F "https://github.com/mikeslattery/tunic/blob/master/files/grub.cfg"
    click G "https://github.com/mikeslattery/tunic/blob/master/tunic.nsi"
    click H "https://github.com/mikeslattery/tunic/blob/master/files/preseed.cfg"

    %% Styles
    classDef goModule fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef scriptModule fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef bootModule fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef installModule fill:#DDA0DD,stroke:#000,stroke-width:2px;
```
