# openchami/magellan architecture

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

- Interactive diagram: https://gitdiagram.com/openchami/magellan
- Repository: https://github.com/openchami/magellan

## Overview

Magellan is a Go CLI for discovering BMCs and collecting Redfish inventory, with additional commands for PDU inventory, firmware updates, and power control. The main workflow takes target or cached scan data, maps BMC identifiers, connects to Redfish, gathers inventory, and emits structured data for files or SMD. The graph includes major README capabilities, but excerpts are partial; uncertain command wiring and the unlisted secrets implementation are not expanded.

Main entry points: [`cmd/root.go`](https://github.com/openchami/magellan/blob/main/cmd/root.go) (Command router), [`pkg/collect.go`](https://github.com/openchami/magellan/blob/main/pkg/collect.go) (Inventory collection), [`cmd/collect.go`](https://github.com/openchami/magellan/blob/main/cmd/collect.go) (Collect command), [`pkg/scan.go`](https://github.com/openchami/magellan/blob/main/pkg/scan.go) (Network scan)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_commands["Command router<br/>[root.go]"]
  node_scan_cmd["Scan command<br/>[scan.go]"]
  node_collect_cmd["Collect command<br/>[collect.go]"]
  node_pdu_cmd["PDU collect<br/>[pdu-collect.go]"]
  node_update_cmd["Update command<br/>[update.go]"]
  node_power_cmd["Power command<br/>[power.go]"]
end

subgraph group_discovery["Discovery and inventory"]
  node_scanner["Network scan<br/>[scan.go]"]
  node_inventory["Inventory collection<br/>[collect.go]"]
  node_redfish_crawler["Redfish crawler<br/>[main.go]"]
  node_id_mapping["BMC ID mapping"]
  node_pdu_inventory["PDU inventory<br/>[pdu-inventory.go]"]
  node_pdu_crawler["JAWS PDU crawler<br/>[pdu-crawler.go]"]
end

subgraph group_integrations["External integrations"]
  node_redfish{{"BMC Redfish API"}}
  node_smd_client["SMD client<br/>[smd.go]"]
  node_smd{{"OpenCHAMI SMD"}}
end

subgraph group_state["Local state and output"]
  node_cache[("Scan cache<br/>[cache.go]")]
  node_data_format["JSON YAML format<br/>[format.go]"]
  node_secret_store["BMC secrets"]
  node_output["Inventory files"]
end

subgraph group_operations["Device operations"]
  node_firmware["Firmware update<br/>[update.go]"]
  node_power["Power control<br/>[power.go]"]
end

node_operator(("Operator"))

node_operator -->|"invokes"| node_commands
node_commands -->|"dispatches"| node_scan_cmd
node_commands -->|"dispatches"| node_collect_cmd
node_commands -->|"dispatches"| node_pdu_cmd
node_commands -->|"dispatches"| node_update_cmd
node_commands -->|"dispatches"| node_power_cmd
node_scan_cmd -->|"runs scan"| node_scanner
node_scanner -->|"probes"| node_redfish
node_scanner -->|"stores results"| node_cache
node_collect_cmd -->|"loads targets"| node_cache
node_collect_cmd -->|"collects inventory"| node_inventory
node_collect_cmd -->|"loads credentials"| node_secret_store
node_inventory -->|"maps identifiers"| node_id_mapping
node_inventory -->|"crawls BMCs"| node_redfish_crawler
node_redfish_crawler -->|"queries Redfish"| node_redfish
node_inventory -->|"formats output"| node_data_format
node_inventory -->|"writes inventory"| node_output
node_inventory -->|"submits inventory"| node_smd_client
node_smd_client -->|"sends data"| node_smd
node_pdu_cmd -->|"collects PDU data"| node_pdu_inventory
node_pdu_inventory -->|"uses crawler"| node_pdu_crawler
node_pdu_crawler -->|"queries devices"| node_redfish
node_update_cmd -->|"runs update"| node_firmware
node_firmware -->|"updates firmware"| node_redfish
node_power_cmd -->|"controls power"| node_power
node_power -->|"reads and resets"| node_redfish

click node_commands "https://github.com/openchami/magellan/blob/main/cmd/root.go"
click node_scan_cmd "https://github.com/openchami/magellan/blob/main/cmd/scan.go"
click node_collect_cmd "https://github.com/openchami/magellan/blob/main/cmd/collect.go"
click node_pdu_cmd "https://github.com/openchami/magellan/blob/main/cmd/pdu-collect.go"
click node_update_cmd "https://github.com/openchami/magellan/blob/main/cmd/update.go"
click node_power_cmd "https://github.com/openchami/magellan/blob/main/cmd/power.go"
click node_scanner "https://github.com/openchami/magellan/blob/main/pkg/scan.go"
click node_inventory "https://github.com/openchami/magellan/blob/main/pkg/collect.go"
click node_redfish_crawler "https://github.com/openchami/magellan/blob/main/pkg/crawler/main.go"
click node_id_mapping "https://github.com/openchami/magellan/blob/main/pkg/idmap/user_provided_mapper.go"
click node_pdu_inventory "https://github.com/openchami/magellan/blob/main/pkg/pdu/pdu-inventory.go"
click node_pdu_crawler "https://github.com/openchami/magellan/blob/main/pkg/jaws/pdu-crawler.go"
click node_smd_client "https://github.com/openchami/magellan/blob/main/pkg/client/smd.go"
click node_firmware "https://github.com/openchami/magellan/blob/main/pkg/update.go"
click node_power "https://github.com/openchami/magellan/blob/main/pkg/power/power.go"
click node_cache "https://github.com/openchami/magellan/blob/main/internal/cache/cache.go"
click node_data_format "https://github.com/openchami/magellan/blob/main/internal/format/format.go"

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_commands,node_scan_cmd,node_collect_cmd,node_pdu_cmd,node_update_cmd,node_power_cmd toneBlue
class node_scanner,node_inventory,node_redfish_crawler,node_id_mapping,node_pdu_inventory,node_pdu_crawler toneAmber
class node_redfish,node_smd_client,node_smd toneMint
class node_cache,node_data_format,node_secret_store,node_output toneRose
class node_firmware,node_power,node_operator toneIndigo
```

## Components

### CLI workflows

- [Command router](https://github.com/openchami/magellan/blob/main/cmd/root.go): `cmd/root.go`
- [Scan command](https://github.com/openchami/magellan/blob/main/cmd/scan.go): `cmd/scan.go`
- [Collect command](https://github.com/openchami/magellan/blob/main/cmd/collect.go): `cmd/collect.go`
- [PDU collect](https://github.com/openchami/magellan/blob/main/cmd/pdu-collect.go): `cmd/pdu-collect.go`
- [Update command](https://github.com/openchami/magellan/blob/main/cmd/update.go): `cmd/update.go`
- [Power command](https://github.com/openchami/magellan/blob/main/cmd/power.go): `cmd/power.go`

### Discovery and inventory

- [Network scan](https://github.com/openchami/magellan/blob/main/pkg/scan.go): `pkg/scan.go`
- [Inventory collection](https://github.com/openchami/magellan/blob/main/pkg/collect.go): `pkg/collect.go`
- [Redfish crawler](https://github.com/openchami/magellan/blob/main/pkg/crawler/main.go): `pkg/crawler/main.go`
- [BMC ID mapping](https://github.com/openchami/magellan/blob/main/pkg/idmap/user_provided_mapper.go): `pkg/idmap/user_provided_mapper.go`
- [PDU inventory](https://github.com/openchami/magellan/blob/main/pkg/pdu/pdu-inventory.go): `pkg/pdu/pdu-inventory.go`
- [JAWS PDU crawler](https://github.com/openchami/magellan/blob/main/pkg/jaws/pdu-crawler.go): `pkg/jaws/pdu-crawler.go`

### External integrations

- **BMC Redfish API**
- [SMD client](https://github.com/openchami/magellan/blob/main/pkg/client/smd.go): `pkg/client/smd.go`
- **OpenCHAMI SMD**

### Local state and output

- [Scan cache](https://github.com/openchami/magellan/blob/main/internal/cache/cache.go): `internal/cache/cache.go`
- [JSON YAML format](https://github.com/openchami/magellan/blob/main/internal/format/format.go): `internal/format/format.go`
- **BMC secrets**
- **Inventory files**

### Device operations

- [Firmware update](https://github.com/openchami/magellan/blob/main/pkg/update.go): `pkg/update.go`
- [Power control](https://github.com/openchami/magellan/blob/main/pkg/power/power.go): `pkg/power/power.go`

### Other components

- **Operator**

## Connections

- Operator → Command router: invokes
- Command router → Scan command: dispatches
- Command router → Collect command: dispatches
- Command router → PDU collect: dispatches
- Command router → Update command: dispatches
- Command router → Power command: dispatches
- Scan command → Network scan: runs scan
- Network scan → BMC Redfish API: probes
- Network scan → Scan cache: stores results
- Collect command → Scan cache: loads targets
- Collect command → Inventory collection: collects inventory
- Collect command → BMC secrets: loads credentials
- Inventory collection → BMC ID mapping: maps identifiers
- Inventory collection → Redfish crawler: crawls BMCs
- Redfish crawler → BMC Redfish API: queries Redfish
- Inventory collection → JSON YAML format: formats output
- Inventory collection → Inventory files: writes inventory
- Inventory collection → SMD client: submits inventory
- SMD client → OpenCHAMI SMD: sends data
- PDU collect → PDU inventory: collects PDU data
- PDU inventory → JAWS PDU crawler: uses crawler
- JAWS PDU crawler → BMC Redfish API: queries devices
- Update command → Firmware update: runs update
- Firmware update → BMC Redfish API: updates firmware
- Power command → Power control: controls power
- Power control → BMC Redfish API: reads and resets
