# spaceinventor/csh architecture

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

- Interactive diagram: https://gitdiagram.com/spaceinventor/csh
- Repository: https://github.com/spaceinventor/csh

## Overview

CSP Shell is an interactive command interpreter for CSP- and libparam-based applications. Its main workflow is to start a shell, load the default or selected init script, and run commands; users can also load APM extensions. The graph preserves the documented extension capability and sampled command areas for parameters, CSP, firmware, and memory transfers, plus parameter telemetry and metrics exporters. Some command-registration and startup details are unsampled, so only documented or source-index-supported relationships are shown.

Main entry points: [`src/param_sniffer.c`](https://github.com/spaceinventor/csh/blob/missions/src/param_sniffer.c) (Parameter sniffer), [`src/slash_apm.c`](https://github.com/spaceinventor/csh/blob/missions/src/slash_apm.c) (APM commands), [`src/main.c`](https://github.com/spaceinventor/csh/blob/missions/src/main.c) (Shell startup), [`src/python/python_loader.c`](https://github.com/spaceinventor/csh/blob/missions/src/python/python_loader.c) (Python extensions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Shell runtime"]
  node_main["Shell startup<br/>[main.c]"]
  node_environment["Environment commands<br/>[environment.c]"]
end

subgraph group_commands["Command domains"]
  node_param_commands["Parameter commands<br/>[param_slash.c]"]
  node_param_lists["Parameter lists<br/>[param_list_slash.c]"]
  node_csp_commands["CSP commands<br/>[slash_csp.c]"]
  node_spaceboot["Firmware operations<br/>[spaceboot_slash.c]"]
  node_vmem["Memory transfers"]
  node_vmem_ftp["Resumable transfers"]
end

subgraph group_extensions["Extensions"]
  node_apm_commands["APM commands<br/>[slash_apm.c]"]
  node_python_loader["Python extensions<br/>[python_loader.c]"]
  node_directory_walk["Directory traversal<br/>[walkdir.c]"]
end

subgraph group_telemetry["Telemetry and metrics"]
  node_param_sniffer["Parameter sniffer<br/>[param_sniffer.c]"]
  node_hk_sniffer["Housekeeping sniffer<br/>[hk_param_sniffer.c]"]
  node_known_hosts[("Known hosts<br/>[known_hosts.c]")]
  node_prometheus["Prometheus exporter<br/>[prometheus.c]"]
  node_victoria["Victoria Metrics<br/>[victoria_metrics.c]"]
  node_vts["VTS metrics<br/>[vts.c]"]
  node_loki["Loki logging<br/>[loki.c]"]
end

node_user(("Shell user"))

node_user -->|"starts"| node_main
node_main -->|"sets up"| node_environment
node_user -->|"loads APMs"| node_apm_commands
node_apm_commands -->|"loads Python"| node_python_loader
node_apm_commands -->|"searches files"| node_directory_walk
node_python_loader -->|"walks directories"| node_directory_walk
node_spaceboot -->|"uploads firmware"| node_vmem
node_param_sniffer -->|"checks packets"| node_hk_sniffer
node_param_sniffer -->|"gets host names"| node_known_hosts
node_param_sniffer -.->|"uses exporter"| node_prometheus
node_param_sniffer -.->|"uses exporter"| node_victoria
node_param_sniffer -.->|"records values"| node_vts

click node_main "https://github.com/spaceinventor/csh/blob/missions/src/main.c"
click node_environment "https://github.com/spaceinventor/csh/blob/missions/src/environment.c"
click node_param_commands "https://github.com/spaceinventor/csh/blob/missions/src/param_slash.c"
click node_param_lists "https://github.com/spaceinventor/csh/blob/missions/src/param_list_slash.c"
click node_csp_commands "https://github.com/spaceinventor/csh/blob/missions/src/slash_csp.c"
click node_spaceboot "https://github.com/spaceinventor/csh/blob/missions/src/spaceboot_slash.c"
click node_vmem "https://github.com/spaceinventor/csh/blob/missions/src/vmem_client_slash.c"
click node_vmem_ftp "https://github.com/spaceinventor/csh/blob/missions/src/vmem_client_slash_ftp.c"
click node_apm_commands "https://github.com/spaceinventor/csh/blob/missions/src/slash_apm.c"
click node_python_loader "https://github.com/spaceinventor/csh/blob/missions/src/python/python_loader.c"
click node_directory_walk "https://github.com/spaceinventor/csh/blob/missions/src/walkdir.c"
click node_param_sniffer "https://github.com/spaceinventor/csh/blob/missions/src/param_sniffer.c"
click node_hk_sniffer "https://github.com/spaceinventor/csh/blob/missions/src/hk_param_sniffer.c"
click node_known_hosts "https://github.com/spaceinventor/csh/blob/missions/src/known_hosts.c"
click node_prometheus "https://github.com/spaceinventor/csh/blob/missions/src/prometheus.c"
click node_victoria "https://github.com/spaceinventor/csh/blob/missions/src/victoria_metrics.c"
click node_vts "https://github.com/spaceinventor/csh/blob/missions/src/vts.c"
click node_loki "https://github.com/spaceinventor/csh/blob/missions/src/loki.c"

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_environment,node_user toneBlue
class node_param_commands,node_param_lists,node_csp_commands,node_spaceboot,node_vmem,node_vmem_ftp toneAmber
class node_apm_commands,node_python_loader,node_directory_walk toneMint
class node_param_sniffer,node_hk_sniffer,node_known_hosts,node_prometheus,node_victoria,node_vts,node_loki toneRose
```

## Components

### Shell runtime

- [Shell startup](https://github.com/spaceinventor/csh/blob/missions/src/main.c): `src/main.c`
- [Environment commands](https://github.com/spaceinventor/csh/blob/missions/src/environment.c): `src/environment.c`

### Command domains

- [Parameter commands](https://github.com/spaceinventor/csh/blob/missions/src/param_slash.c): `src/param_slash.c`
- [Parameter lists](https://github.com/spaceinventor/csh/blob/missions/src/param_list_slash.c): `src/param_list_slash.c`
- [CSP commands](https://github.com/spaceinventor/csh/blob/missions/src/slash_csp.c): `src/slash_csp.c`
- [Firmware operations](https://github.com/spaceinventor/csh/blob/missions/src/spaceboot_slash.c): `src/spaceboot_slash.c`
- [Memory transfers](https://github.com/spaceinventor/csh/blob/missions/src/vmem_client_slash.c): `src/vmem_client_slash.c`
- [Resumable transfers](https://github.com/spaceinventor/csh/blob/missions/src/vmem_client_slash_ftp.c): `src/vmem_client_slash_ftp.c`

### Extensions

- [APM commands](https://github.com/spaceinventor/csh/blob/missions/src/slash_apm.c): `src/slash_apm.c`
- [Python extensions](https://github.com/spaceinventor/csh/blob/missions/src/python/python_loader.c): `src/python/python_loader.c`
- [Directory traversal](https://github.com/spaceinventor/csh/blob/missions/src/walkdir.c): `src/walkdir.c`

### Telemetry and metrics

- [Parameter sniffer](https://github.com/spaceinventor/csh/blob/missions/src/param_sniffer.c): `src/param_sniffer.c`
- [Housekeeping sniffer](https://github.com/spaceinventor/csh/blob/missions/src/hk_param_sniffer.c): `src/hk_param_sniffer.c`
- [Known hosts](https://github.com/spaceinventor/csh/blob/missions/src/known_hosts.c): `src/known_hosts.c`
- [Prometheus exporter](https://github.com/spaceinventor/csh/blob/missions/src/prometheus.c): `src/prometheus.c`
- [Victoria Metrics](https://github.com/spaceinventor/csh/blob/missions/src/victoria_metrics.c): `src/victoria_metrics.c`
- [VTS metrics](https://github.com/spaceinventor/csh/blob/missions/src/vts.c): `src/vts.c`
- [Loki logging](https://github.com/spaceinventor/csh/blob/missions/src/loki.c): `src/loki.c`

### Other components

- **Shell user**

## Connections

- Shell user → Shell startup: starts
- Shell startup → Environment commands: sets up (evidence: `src/main.c`)
- Shell user → APM commands: loads APMs
- APM commands → Python extensions: loads Python (evidence: `src/slash_apm.c`)
- APM commands → Directory traversal: searches files (evidence: `src/slash_apm.c`)
- Python extensions → Directory traversal: walks directories (evidence: `src/python/python_loader.c`)
- Firmware operations → Memory transfers: uploads firmware (evidence: `src/spaceboot_slash.c`)
- Parameter sniffer → Housekeeping sniffer: checks packets (evidence: `src/param_sniffer.c`)
- Parameter sniffer → Known hosts: gets host names (evidence: `src/param_sniffer.c`)
- Parameter sniffer → Prometheus exporter: uses exporter
- Parameter sniffer → Victoria Metrics: uses exporter
- Parameter sniffer → VTS metrics: records values
