# termux/proot-distro architecture

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

- Interactive diagram: https://gitdiagram.com/termux/proot-distro
- Repository: https://github.com/termux/proot-distro

## Overview

PRoot-Distro manages rootless Linux containers: users install registry images or local archives, enter or run commands inside them, and manage their lifecycle. It also supports Dockerfile builds and registry publishing, plus search, backup/restore, file transfer, and session management. The graph combines README-documented capabilities with relationships visible in sampled source and the SOURCE INDEX; several command implementations were not sampled, so their internal connections are not inferred.

Main entry points: [`proot_distro/helpers/docker/pull.py`](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/pull.py) (Registry pull), [`proot_distro/commands/install.py`](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/install.py) (Install image), [`proot_distro/helpers/docker/search.py`](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/search.py) (Registry search), [`proot_distro/commands/restore.py`](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/restore.py) (Restore archive)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Image acquisition"]
  node_install["Install image<br/>[install.py]"]
  node_local_install["Install archive<br/>[install_local.py]"]
  node_docker_search["Registry search<br/>[search.py]"]
  node_pull["Registry pull<br/>[pull.py]"]
  node_transport["Registry transport<br/>[transport.py]"]
  node_download["HTTP downloads<br/>[download.py]"]
  node_image_cache[("Image cache<br/>[cache.py]")]
  node_extract["Layer extraction<br/>[tar_extract.py]"]
end

subgraph group_runtime["Container runtime"]
  node_proot["proot runtime"]
  node_login["Login session<br/>[__init__.py]"]
  node_proot_command["proot command<br/>[proot_cmd.py]"]
  node_session_registry[("Session registry<br/>[session.py]")]
end

subgraph group_build["Image build and publish"]
  node_build_command["Build command<br/>[build.py]"]
  node_build_engine["Dockerfile engine<br/>[engine.py]"]
  node_build_handlers["Build handlers<br/>[handlers.py]"]
  node_copy_step["Build copy step<br/>[copy_step.py]"]
  node_push["Registry push<br/>[push.py]"]
end

subgraph group_management["Container management"]
  node_lifecycle["Container lifecycle<br/>[remove.py]"]
  node_backup["Backup archive<br/>[backup.py]"]
  node_restore["Restore archive<br/>[restore.py]"]
  node_file_transfer["File transfer<br/>[sync.py]"]
  node_filesystem["Filesystem safety<br/>[dirfd.py]"]
  node_state_paths["State and paths<br/>[paths.py]"]
end

node_user(("User"))
node_entry["CLI entry"]
node_registry[("OCI registry")]

node_user -->|"invokes"| node_entry
node_entry -->|"selects command"| node_install
node_entry -->|"selects command"| node_local_install
node_entry -->|"selects search"| node_docker_search
node_install -->|"pulls image"| node_pull
node_pull -->|"requests registry"| node_transport
node_pull -->|"downloads blobs"| node_download
node_docker_search -->|"queries registry"| node_transport
node_docker_search -->|"fetches data"| node_download
node_transport -->|"sends requests"| node_registry
node_pull -->|"fetches image"| node_registry
node_pull -->|"caches manifests"| node_image_cache
node_local_install -->|"extracts archive"| node_extract
node_install -->|"assembles layers"| node_extract
node_login -->|"builds invocation"| node_proot_command
node_proot_command -->|"executes"| node_proot
node_login -->|"records session"| node_session_registry
node_entry -->|"selects command"| node_login
node_entry -->|"selects build"| node_build_command
node_build_command -->|"builds image"| node_build_engine
node_build_engine -->|"dispatches instructions"| node_build_handlers
node_build_handlers -->|"handles copy"| node_copy_step
node_entry -->|"selects push"| node_push
node_push -->|"publishes image"| node_registry
node_entry -->|"selects management"| node_lifecycle
node_entry -->|"selects backup"| node_backup
node_entry -->|"selects restore"| node_restore
node_entry -->|"selects sync"| node_file_transfer
node_restore -->|"extracts archive"| node_extract
node_restore -->|"writes safely"| node_filesystem
node_image_cache -->|"uses state paths"| node_state_paths
node_state_paths -->|"walks descriptors"| node_filesystem

click node_install "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/install.py"
click node_local_install "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/install_local.py"
click node_docker_search "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/search.py"
click node_pull "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/pull.py"
click node_transport "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/transport.py"
click node_download "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/download.py"
click node_image_cache "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/cache.py"
click node_extract "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/tar_extract.py"
click node_login "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/login/__init__.py"
click node_proot_command "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/login/proot_cmd.py"
click node_session_registry "https://github.com/termux/proot-distro/blob/master/proot_distro/session.py"
click node_build_command "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/build.py"
click node_build_engine "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/build_engine/engine.py"
click node_build_handlers "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/build_engine/handlers.py"
click node_copy_step "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/build_engine/copy_step.py"
click node_push "https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/push.py"
click node_lifecycle "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/remove.py"
click node_backup "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/backup.py"
click node_restore "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/restore.py"
click node_file_transfer "https://github.com/termux/proot-distro/blob/master/proot_distro/commands/sync.py"
click node_filesystem "https://github.com/termux/proot-distro/blob/master/proot_distro/dirfd.py"
click node_state_paths "https://github.com/termux/proot-distro/blob/master/proot_distro/paths.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_install,node_local_install,node_docker_search,node_pull,node_transport,node_download,node_image_cache,node_extract,node_user toneBlue
class node_proot,node_login,node_proot_command,node_session_registry,node_registry toneAmber
class node_build_command,node_build_engine,node_build_handlers,node_copy_step,node_push toneMint
class node_lifecycle,node_backup,node_restore,node_file_transfer,node_filesystem,node_state_paths toneRose
class node_entry toneIndigo
```

## Components

### Image acquisition

- [Install image](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/install.py): `proot_distro/commands/install.py`
- [Install archive](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/install_local.py): `proot_distro/commands/install_local.py`
- [Registry search](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/search.py): `proot_distro/helpers/docker/search.py`
- [Registry pull](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/pull.py): `proot_distro/helpers/docker/pull.py`
- [Registry transport](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/transport.py): `proot_distro/helpers/docker/transport.py`
- [HTTP downloads](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/download.py): `proot_distro/helpers/download.py`
- [Image cache](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/cache.py): `proot_distro/helpers/docker/cache.py`
- [Layer extraction](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/tar_extract.py): `proot_distro/helpers/tar_extract.py`

### Container runtime

- **proot runtime**
- [Login session](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/login/__init__.py): `proot_distro/commands/login/__init__.py`
- [proot command](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/login/proot_cmd.py): `proot_distro/commands/login/proot_cmd.py`
- [Session registry](https://github.com/termux/proot-distro/blob/master/proot_distro/session.py): `proot_distro/session.py`

### Image build and publish

- [Build command](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/build.py): `proot_distro/commands/build.py`
- [Dockerfile engine](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/build_engine/engine.py): `proot_distro/helpers/build_engine/engine.py`
- [Build handlers](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/build_engine/handlers.py): `proot_distro/helpers/build_engine/handlers.py`
- [Build copy step](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/build_engine/copy_step.py): `proot_distro/helpers/build_engine/copy_step.py`
- [Registry push](https://github.com/termux/proot-distro/blob/master/proot_distro/helpers/docker/push.py): `proot_distro/helpers/docker/push.py`

### Container management

- [Container lifecycle](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/remove.py): `proot_distro/commands/remove.py`
- [Backup archive](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/backup.py): `proot_distro/commands/backup.py`
- [Restore archive](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/restore.py): `proot_distro/commands/restore.py`
- [File transfer](https://github.com/termux/proot-distro/blob/master/proot_distro/commands/sync.py): `proot_distro/commands/sync.py`
- [Filesystem safety](https://github.com/termux/proot-distro/blob/master/proot_distro/dirfd.py): `proot_distro/dirfd.py`
- [State and paths](https://github.com/termux/proot-distro/blob/master/proot_distro/paths.py): `proot_distro/paths.py`

### Other components

- **User**
- **CLI entry**
- **OCI registry**

## Connections

- User → CLI entry: invokes
- CLI entry → Install image: selects command
- CLI entry → Install archive: selects command
- CLI entry → Registry search: selects search
- Install image → Registry pull: pulls image
- Registry pull → Registry transport: requests registry (evidence: `proot_distro/helpers/docker/pull.py`)
- Registry pull → HTTP downloads: downloads blobs (evidence: `proot_distro/helpers/docker/pull.py`)
- Registry search → Registry transport: queries registry (evidence: `proot_distro/helpers/docker/search.py`)
- Registry search → HTTP downloads: fetches data (evidence: `proot_distro/helpers/docker/search.py`)
- Registry transport → OCI registry: sends requests (evidence: `proot_distro/helpers/docker/transport.py`)
- Registry pull → OCI registry: fetches image
- Registry pull → Image cache: caches manifests (evidence: `proot_distro/helpers/docker/pull.py`)
- Install archive → Layer extraction: extracts archive
- Install image → Layer extraction: assembles layers
- Login session → proot command: builds invocation (evidence: `proot_distro/commands/login/__init__.py`)
- proot command → proot runtime: executes
- Login session → Session registry: records session (evidence: `proot_distro/commands/login/__init__.py`)
- CLI entry → Login session: selects command
- CLI entry → Build command: selects build
- Build command → Dockerfile engine: builds image
- Dockerfile engine → Build handlers: dispatches instructions (evidence: `proot_distro/helpers/build_engine/engine.py`)
- Build handlers → Build copy step: handles copy (evidence: `proot_distro/helpers/build_engine/handlers.py`)
- CLI entry → Registry push: selects push
- Registry push → OCI registry: publishes image
- CLI entry → Container lifecycle: selects management
- CLI entry → Backup archive: selects backup
- CLI entry → Restore archive: selects restore
- CLI entry → File transfer: selects sync
- Restore archive → Layer extraction: extracts archive (evidence: `proot_distro/commands/restore.py`)
- Restore archive → Filesystem safety: writes safely (evidence: `proot_distro/commands/restore.py`)
- Image cache → State and paths: uses state paths (evidence: `proot_distro/helpers/docker/cache.py`)
- State and paths → Filesystem safety: walks descriptors (evidence: `proot_distro/paths.py`)
