# mstrpi/pyspawn architecture

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

- Interactive diagram: https://gitdiagram.com/mstrpi/pyspawn
- Repository: https://github.com/mstrpi/pyspawn

## Overview

pyspawn is an unfinished interactive tool for creating systemd-nspawn containers. The user supplies a container name, base distribution, and network mode; the main script then checks prerequisites, prepares host directories and package dependencies, installs the selected base system, configures networking, and sets the root password. The graph follows calls visible in the excerpts; several calls have argument mismatches, so it represents intended dispatch as written, not confirmed successful execution.

Main entry points: [`main.py`](https://github.com/mstrpi/pyspawn/blob/master/main.py) (Setup orchestrator), [`resources/functions.py`](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py) (Private networking), [`resources/container.py`](https://github.com/mstrpi/pyspawn/blob/master/resources/container.py) (Container choices)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup flow"]
  node_main["Setup orchestrator<br/>[main.py]"]
  node_container_config["Container choices<br/>[container.py]"]
  node_privilege["Root check<br/>[functions.py]"]
  node_pkg_setup["Package dependencies<br/>[functions.py]"]
end

subgraph group_provision["Container provisioning"]
  node_debian["Debian bootstrap<br/>[functions.py]"]
  node_fedora["Fedora bootstrap<br/>[functions.py]"]
  node_arch["Arch bootstrap<br/>[functions.py]"]
  node_password["Root password<br/>[functions.py]"]
end

subgraph group_network["Networking"]
  node_host_network["Host networking<br/>[functions.py]"]
  node_private_network["Private networking<br/>[functions.py]"]
  node_bridge["Bridge setup<br/>[functions.py]"]
  node_macvlan["Macvlan setup<br/>[functions.py]"]
end

subgraph group_host["Host operations"]
  node_filesystem["Host directories<br/>[functions.py]"]
  node_btrfs["Btrfs option<br/>[functions.py]"]
  node_selinux["SELinux controls<br/>[functions.py]"]
  node_system["Host system tools"]
end

node_user(("Administrator"))

node_user -->|"enters choices"| node_container_config
node_main -->|"creates"| node_container_config
node_container_config -->|"provides settings"| node_main
node_main -->|"checks access"| node_privilege
node_main -->|"checks option"| node_btrfs
node_main -->|"creates directories"| node_filesystem
node_main -->|"installs dependencies"| node_pkg_setup
node_main -->|"selects distro"| node_debian
node_main -->|"selects distro"| node_fedora
node_main -->|"selects distro"| node_arch
node_main -->|"selects network"| node_host_network
node_main -->|"selects network"| node_private_network
node_private_network -->|"dispatches bridge"| node_bridge
node_private_network -->|"dispatches macvlan"| node_macvlan
node_main -->|"toggles controls"| node_selinux
node_main -->|"sets password"| node_password
node_btrfs -->|"runs command"| node_system
node_pkg_setup -->|"runs package commands"| node_system
node_debian -->|"runs bootstrap"| node_system
node_fedora -->|"runs bootstrap"| node_system
node_arch -->|"runs bootstrap"| node_system
node_host_network -->|"writes config"| node_system
node_bridge -->|"writes config"| node_system
node_macvlan -->|"writes config"| node_system
node_selinux -->|"runs commands"| node_system
node_password -->|"runs nspawn"| node_system

click node_main "https://github.com/mstrpi/pyspawn/blob/master/main.py"
click node_container_config "https://github.com/mstrpi/pyspawn/blob/master/resources/container.py"
click node_privilege "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_pkg_setup "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_filesystem "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_btrfs "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_debian "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_fedora "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_arch "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_host_network "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_private_network "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_bridge "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_macvlan "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_selinux "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"
click node_password "https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py"

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_main,node_container_config,node_privilege,node_pkg_setup toneBlue
class node_debian,node_fedora,node_arch,node_password toneAmber
class node_host_network,node_private_network,node_bridge,node_macvlan toneMint
class node_filesystem,node_btrfs,node_selinux,node_system toneRose
class node_user toneIndigo
```

## Components

### Setup flow

- [Setup orchestrator](https://github.com/mstrpi/pyspawn/blob/master/main.py): `main.py`
- [Container choices](https://github.com/mstrpi/pyspawn/blob/master/resources/container.py): `resources/container.py`
- [Root check](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Package dependencies](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`

### Container provisioning

- [Debian bootstrap](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Fedora bootstrap](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Arch bootstrap](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Root password](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`

### Networking

- [Host networking](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Private networking](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Bridge setup](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Macvlan setup](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`

### Host operations

- [Host directories](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [Btrfs option](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- [SELinux controls](https://github.com/mstrpi/pyspawn/blob/master/resources/functions.py): `resources/functions.py`
- **Host system tools**

### Other components

- **Administrator**

## Connections

- Administrator → Container choices: enters choices (evidence: `resources/container.py`)
- Setup orchestrator → Container choices: creates (evidence: `main.py`)
- Container choices → Setup orchestrator: provides settings (evidence: `main.py`)
- Setup orchestrator → Root check: checks access (evidence: `main.py`)
- Setup orchestrator → Btrfs option: checks option (evidence: `main.py`)
- Setup orchestrator → Host directories: creates directories (evidence: `main.py`)
- Setup orchestrator → Package dependencies: installs dependencies (evidence: `main.py`)
- Setup orchestrator → Debian bootstrap: selects distro (evidence: `main.py`)
- Setup orchestrator → Fedora bootstrap: selects distro (evidence: `main.py`)
- Setup orchestrator → Arch bootstrap: selects distro (evidence: `main.py`)
- Setup orchestrator → Host networking: selects network (evidence: `main.py`)
- Setup orchestrator → Private networking: selects network (evidence: `main.py`)
- Private networking → Bridge setup: dispatches bridge (evidence: `resources/functions.py`)
- Private networking → Macvlan setup: dispatches macvlan (evidence: `resources/functions.py`)
- Setup orchestrator → SELinux controls: toggles controls (evidence: `main.py`)
- Setup orchestrator → Root password: sets password (evidence: `main.py`)
- Btrfs option → Host system tools: runs command (evidence: `resources/functions.py`)
- Package dependencies → Host system tools: runs package commands (evidence: `resources/functions.py`)
- Debian bootstrap → Host system tools: runs bootstrap (evidence: `resources/functions.py`)
- Fedora bootstrap → Host system tools: runs bootstrap (evidence: `resources/functions.py`)
- Arch bootstrap → Host system tools: runs bootstrap (evidence: `resources/functions.py`)
- Host networking → Host system tools: writes config (evidence: `resources/functions.py`)
- Bridge setup → Host system tools: writes config (evidence: `resources/functions.py`)
- Macvlan setup → Host system tools: writes config (evidence: `resources/functions.py`)
- SELinux controls → Host system tools: runs commands (evidence: `resources/functions.py`)
- Root password → Host system tools: runs nspawn (evidence: `resources/functions.py`)
