# kalvadtech/infraninja architecture

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

- Interactive diagram: https://gitdiagram.com/kalvadtech/infraninja
- Repository: https://github.com/kalvadtech/infraninja
- Video tour (about a minute): https://gitdiagram.com/kalvadtech/infraninja/video

## Overview

InfraNinja is a PyInfra-based infrastructure automation library. Users run reusable actions against managed hosts, gather read-only facts, or discover hosts through dynamic inventories. Composite actions group security setup stages; individual actions dispatch to OS-specific security implementations and PyInfra operations. The README documents the broader action catalog and inventory integrations; source excerpts only confirm selected implementations, so detailed wiring for unsampled features is not inferred.

Main entry points: [`infraninja/facts/__init__.py`](https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/__init__.py) (Fact API), [`infraninja/inventories/__init__.py`](https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/__init__.py) (Inventory API), [`infraninja/actions/__init__.py`](https://github.com/kalvadtech/infraninja/blob/main/infraninja/actions/__init__.py) (Action API), [`infraninja/actions`](https://github.com/kalvadtech/infraninja/tree/main/infraninja/actions) (Security Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_actions["Actions"]
  node_action_api["Action API<br/>[__init__.py]"]
  node_composites["Composite Actions"]
  node_action_base["Action Runtime<br/>[base.py]"]
  node_security_actions["Security Actions"]
end

subgraph group_security["Security Operations"]
  node_security_impl["OS Security Modules"]
  node_ssh_keys["SSH Key Management<br/>[pubkeys.py]"]
end

subgraph group_facts["Server Facts"]
  node_fact_api["Fact API<br/>[__init__.py]"]
  node_fact_base["Fact Framework<br/>[base.py]"]
  node_system_facts["System Facts<br/>[system_info.py]"]
  node_hardware_facts["Hardware Facts<br/>[hardware.py]"]
  node_full_facts["Composite Facts<br/>[full_facts.py]"]
end

subgraph group_inventory["Inventories"]
  node_inventory_api["Inventory API<br/>[__init__.py]"]
  node_jinn_inventory["Jinn Inventory<br/>[jinn.py]"]
  node_coolify_inventory["Coolify Inventory<br/>[coolify.py]"]
  node_inventory_base["Inventory Base<br/>[base.py]"]
end

node_user(("Engineer"))
node_pyinfra["PyInfra Runtime"]
node_hosts(("Managed Hosts"))
node_jinn_api["Jinn API"]
node_coolify_api["Coolify API"]
node_key_api["SSH Key API"]

node_user -->|"selects action"| node_action_api
node_action_api -->|"uses runtime"| node_action_base
node_action_api -->|"exposes composites"| node_composites
node_composites -->|"runs sub-actions"| node_security_actions
node_security_actions -->|"dispatches operations"| node_security_impl
node_security_actions -->|"executes deployment"| node_pyinfra
node_security_impl -->|"issues operations"| node_pyinfra
node_pyinfra -->|"configures or reads"| node_hosts
node_user -->|"requests facts"| node_fact_api
node_fact_api -->|"uses framework"| node_fact_base
node_fact_api -->|"exposes"| node_system_facts
node_fact_api -->|"exposes"| node_hardware_facts
node_fact_api -->|"exposes composite"| node_full_facts
node_full_facts -->|"aggregates facts"| node_fact_base
node_fact_base -->|"gathers remotely"| node_pyinfra
node_user -->|"requests hosts"| node_inventory_api
node_inventory_api -->|"uses base"| node_inventory_base
node_inventory_api -->|"exposes"| node_jinn_inventory
node_inventory_api -->|"exposes"| node_coolify_inventory
node_jinn_inventory -->|"fetches inventory"| node_jinn_api
node_coolify_inventory -->|"fetches inventory"| node_coolify_api
node_jinn_inventory -->|"formats hosts"| node_inventory_base
node_coolify_inventory -->|"formats hosts"| node_inventory_base
node_user -->|"manages keys"| node_ssh_keys
node_ssh_keys -.->|"fetches or deletes"| node_key_api
node_ssh_keys -->|"updates host keys"| node_pyinfra

click node_action_api "https://github.com/kalvadtech/infraninja/blob/main/infraninja/actions/__init__.py"
click node_composites "https://github.com/kalvadtech/infraninja/blob/main/infraninja/actions/full_security_setup.py"
click node_action_base "https://github.com/kalvadtech/infraninja/blob/main/infraninja/actions/base.py"
click node_security_actions "https://github.com/kalvadtech/infraninja/tree/main/infraninja/actions"
click node_security_impl "https://github.com/kalvadtech/infraninja/tree/main/infraninja/security"
click node_fact_api "https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/__init__.py"
click node_fact_base "https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/base.py"
click node_system_facts "https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/system_info.py"
click node_hardware_facts "https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/hardware.py"
click node_full_facts "https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/full_facts.py"
click node_inventory_api "https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/__init__.py"
click node_jinn_inventory "https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/jinn.py"
click node_coolify_inventory "https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/coolify.py"
click node_inventory_base "https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/base.py"
click node_ssh_keys "https://github.com/kalvadtech/infraninja/blob/main/infraninja/utils/pubkeys.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_action_api,node_composites,node_action_base,node_security_actions toneBlue
class node_security_impl,node_ssh_keys toneAmber
class node_fact_api,node_fact_base,node_system_facts,node_hardware_facts,node_full_facts,node_jinn_api,node_coolify_api,node_key_api toneMint
class node_inventory_api,node_jinn_inventory,node_coolify_inventory,node_inventory_base toneRose
class node_user,node_pyinfra,node_hosts toneIndigo
```

## Components

### Actions

- [Action API](https://github.com/kalvadtech/infraninja/blob/main/infraninja/actions/__init__.py): `infraninja/actions/__init__.py`
- [Composite Actions](https://github.com/kalvadtech/infraninja/blob/main/infraninja/actions/full_security_setup.py): `infraninja/actions/full_security_setup.py`
- [Action Runtime](https://github.com/kalvadtech/infraninja/blob/main/infraninja/actions/base.py): `infraninja/actions/base.py`
- [Security Actions](https://github.com/kalvadtech/infraninja/tree/main/infraninja/actions): `infraninja/actions`

### Security Operations

- [OS Security Modules](https://github.com/kalvadtech/infraninja/tree/main/infraninja/security): `infraninja/security`
- [SSH Key Management](https://github.com/kalvadtech/infraninja/blob/main/infraninja/utils/pubkeys.py): `infraninja/utils/pubkeys.py`

### Server Facts

- [Fact API](https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/__init__.py): `infraninja/facts/__init__.py`
- [Fact Framework](https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/base.py): `infraninja/facts/base.py`
- [System Facts](https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/system_info.py): `infraninja/facts/system_info.py`
- [Hardware Facts](https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/hardware.py): `infraninja/facts/hardware.py`
- [Composite Facts](https://github.com/kalvadtech/infraninja/blob/main/infraninja/facts/full_facts.py): `infraninja/facts/full_facts.py`

### Inventories

- [Inventory API](https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/__init__.py): `infraninja/inventories/__init__.py`
- [Jinn Inventory](https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/jinn.py): `infraninja/inventories/jinn.py`
- [Coolify Inventory](https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/coolify.py): `infraninja/inventories/coolify.py`
- [Inventory Base](https://github.com/kalvadtech/infraninja/blob/main/infraninja/inventories/base.py): `infraninja/inventories/base.py`

### Other components

- **Engineer**
- **PyInfra Runtime**
- **Managed Hosts**
- **Jinn API**
- **Coolify API**
- **SSH Key API**

## Connections

- Engineer → Action API: selects action
- Action API → Action Runtime: uses runtime
- Action API → Composite Actions: exposes composites
- Composite Actions → Security Actions: runs sub-actions
- Security Actions → OS Security Modules: dispatches operations
- Security Actions → PyInfra Runtime: executes deployment
- OS Security Modules → PyInfra Runtime: issues operations
- PyInfra Runtime → Managed Hosts: configures or reads
- Engineer → Fact API: requests facts
- Fact API → Fact Framework: uses framework
- Fact API → System Facts: exposes
- Fact API → Hardware Facts: exposes
- Fact API → Composite Facts: exposes composite
- Composite Facts → Fact Framework: aggregates facts
- Fact Framework → PyInfra Runtime: gathers remotely
- Engineer → Inventory API: requests hosts
- Inventory API → Inventory Base: uses base
- Inventory API → Jinn Inventory: exposes
- Inventory API → Coolify Inventory: exposes
- Jinn Inventory → Jinn API: fetches inventory
- Coolify Inventory → Coolify API: fetches inventory
- Jinn Inventory → Inventory Base: formats hosts
- Coolify Inventory → Inventory Base: formats hosts
- Engineer → SSH Key Management: manages keys
- SSH Key Management → SSH Key API: fetches or deletes
- SSH Key Management → PyInfra Runtime: updates host keys
