# satorici/satori-cli architecture

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

- Interactive diagram: https://gitdiagram.com/satorici/satori-cli
- Repository: https://github.com/satorici/satori-cli

## Overview

#### Purpose and Runtime

Satori CLI is a Python command-line client for Satori CI, a remote testing platform. It submits playbooks plus relevant local files for execution, then exposes reports, repositories, schedules/monitors, teams, and account configuration. The remote platform executes tests in Docker instances hosted on AWS; the CLI communicates with Satori’s API.

Entry points are `src/satoricli/__main__.py` and package initialization in `src/satoricli/__init__.py`. Packaging/dependency definitions are in `pyproject.toml`.

#### CLI Dispatch Layer

The command hierarchy is rooted in `src/satoricli/cli/commands/root.py`, with argument parsing in `src/satoricli/cli/arguments.py` and shared command behavior in `src/satoricli/cli/commands/base.py`.

Command modules form the public control boundary. Important domains include:
- Run and local execution: `src/satoricli/cli/commands/run.py`, `src/satoricli/cli/commands/local.py`
- Remote resource management: `src/satoricli/cli/commands/repo.py`, `src/satoricli/cli/commands/monitor.py`, `src/satoricli/cli/commands/playbook.py`
- Result retrieval/presentation: `src/satoricli/cli/commands/report.py`, `src/satoricli/cli/commands/reports.py`

#### Authentication, Configuration, and API Boundary

`src/satoricli/cli/commands/config.py` and `src/satoricli/cli/commands/settings.py` manage user-facing configuration, notably the API token required to use Satori.

`src/satoricli/api.py` is the primary client-to-service boundary: command handlers should delegate remote operations through it rather than encode service interactions themselves. API failures and CLI-level error translation are represented by `src/satoricli/exceptions.py`.

External services include the Satori CI web/API platform, GitHub-connected repositories and GitHub App workflows, and optional notification destinations configured through playbooks (Slack, email, GitHub issues, Discord, Telegram).

#### Playbook Input Model

Playbooks are YAML-based test specifications that define commands, assertions on stdout/stderr/return codes, imports, and monitoring settings. Playbook-specific handling is centralized in `src/satoricli/playbooks.py`; validation boundaries are in `src/satoricli/validations.py`.

The CLI accepts files or directories, resolves playbook inputs and imports, and preserves a test payload for remote execution. Repository examples under `.satori/` demonstrate supported input modes, imports, failures, file inclusion, and monitoring, including `.satori/input.yml` and `.satori/import/pass.yml`.

#### Bundling and Submission Flow

`src/satoricli/bundler.py` is the material packaging stage. It gathers the target project/playbook content into an uploadable bundle while separating local filesystem concerns from the remote execution API.

The main on-demand flow is:
1. `run` command accepts a path and execution flags.
2. Playbook parsing/validation resolves instructions and imports.
3. Bundler prepares files and playbook payload.
4. API client uploads/submits the run.
5. CLI prints the returned UUID/report URL and may poll for completion when synchronous execution is requested.

Relevant paths: `src/satoricli/cli/commands/run.py`, `src/satoricli/bundler.py`, `src/satoricli/api.py`.

#### Execution Modes and Result Lifecycle

Remote runs create reports containing overall status, individual test outcomes, assertions, and elapsed time. Report commands fetch and render this lifecycle, while scan commands apply it to repository history.

Key command surfaces are `src/satoricli/cli/commands/scan.py`, `src/satoricli/cli/commands/report.py`, and `src/satoricli/cli/commands/repo.py`. `--sync`-style behavior is a control-flow distinction: asynchronous submission returns a remote identifier; synchronous mode waits and displays finalized status.

#### Scheduled Monitoring and Managed Resources

A playbook with a cron-like schedule becomes a monitor managed by the platform. Monitor commands visualize and manage these scheduled executions, while related plural commands support resource listing.

Core paths: `src/satoricli/cli/commands/monitor.py`, `src/satoricli/cli/commands/monitors.py`, `src/satoricli/cli/commands/playbooks.py`.

Repository, team, template, shard, and AI commands are additional API-backed management domains under `src/satoricli/cli/commands/`; they share the same CLI dispatch, authentication, and service-client boundaries rather than defining separate runtimes.

Main entry points: [`src/satoricli/api.py`](https://github.com/satorici/satori-cli/blob/main/src/satoricli/api.py) (API client), [`src/satoricli/cli/commands/base.py`](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/base.py) (Command base), [`src/satoricli/cli/commands/root.py`](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/root.py) (Command root), [`src/satoricli/cli/commands/run.py`](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/run.py) (Run command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI control plane"]
  node_entry["CLI entry point<br/>Python module<br/>[__main__.py]"]
  node_root["Command root<br/>command dispatch<br/>[root.py]"]
  node_arguments["Argument parsing<br/>CLI parser<br/>[arguments.py]"]
  node_base["Command base<br/>shared command behavior<br/>[base.py]"]
  node_run["Run command<br/>execution command<br/>[run.py]"]
  node_local["Local command<br/>execution command<br/>[local.py]"]
  node_resources["Resource commands<br/>management commands<br/>[repo.py]"]
  node_reports["Report and scan commands<br/>result commands<br/>[report.py]"]
  node_config["Config and settings<br/>credential commands<br/>[config.py]"]
end

subgraph group_inputs["Playbook packaging"]
  node_playbooks["Playbook handling<br/>YAML input model<br/>[playbooks.py]"]
  node_validation["Validation<br/>[validations.py]"]
  node_bundler["Bundler<br/>payload packaging<br/>[bundler.py]"]
end

subgraph group_remote["Satori CI platform"]
  node_api{{"API client<br/>service client<br/>[api.py]"}}
  node_errors["Error translation<br/>exceptions<br/>[exceptions.py]"]
  node_satori{{"Satori CI API<br/>remote platform"}}
  node_reports_data[("Run reports<br/>remote results")]
  node_integrations["GitHub and notifications<br/>external integrations"]
end

node_entry -->|"starts"| node_root
node_root -->|"parses"| node_arguments
node_root -->|"dispatches through"| node_base
node_base -->|"shared behavior"| node_run
node_base -->|"shared behavior"| node_local
node_base -->|"shared behavior"| node_resources
node_base -->|"shared behavior"| node_reports
node_base -->|"shared behavior"| node_config
node_run -->|"resolves input"| node_playbooks
node_playbooks -->|"validates"| node_validation
node_playbooks -->|"provides payload"| node_bundler
node_bundler -->|"upload bundle"| node_api
node_run -->|"submit and poll"| node_api
node_resources -->|"manage remote resources"| node_api
node_reports -->|"fetch reports and scans"| node_api
node_config -->|"configures token use"| node_api
node_api -->|"translates failures"| node_errors
node_api -->|"HTTPS API"| node_satori
node_satori -->|"creates and stores"| node_reports_data
node_reports_data -->|"returned for rendering"| node_api
node_satori -->|"connects and notifies"| node_integrations

click node_entry "https://github.com/satorici/satori-cli/blob/main/src/satoricli/__main__.py"
click node_root "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/root.py"
click node_arguments "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/arguments.py"
click node_base "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/base.py"
click node_run "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/run.py"
click node_local "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/local.py"
click node_resources "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/repo.py"
click node_reports "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/report.py"
click node_config "https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/config.py"
click node_playbooks "https://github.com/satorici/satori-cli/blob/main/src/satoricli/playbooks.py"
click node_validation "https://github.com/satorici/satori-cli/blob/main/src/satoricli/validations.py"
click node_bundler "https://github.com/satorici/satori-cli/blob/main/src/satoricli/bundler.py"
click node_api "https://github.com/satorici/satori-cli/blob/main/src/satoricli/api.py"
click node_errors "https://github.com/satorici/satori-cli/blob/main/src/satoricli/exceptions.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_entry,node_root,node_arguments,node_base,node_run,node_local,node_resources,node_reports,node_config toneBlue
class node_playbooks,node_validation,node_bundler toneAmber
class node_api,node_errors,node_satori,node_reports_data,node_integrations toneMint
```

## Components

### CLI control plane

- [CLI entry point](https://github.com/satorici/satori-cli/blob/main/src/satoricli/__main__.py): Python module · `src/satoricli/__main__.py`
- [Command root](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/root.py): command dispatch · `src/satoricli/cli/commands/root.py`
- [Argument parsing](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/arguments.py): CLI parser · `src/satoricli/cli/arguments.py`
- [Command base](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/base.py): shared command behavior · `src/satoricli/cli/commands/base.py`
- [Run command](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/run.py): execution command · Submits playbooks and can wait for completion. · `src/satoricli/cli/commands/run.py`
- [Local command](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/local.py): execution command · `src/satoricli/cli/commands/local.py`
- [Resource commands](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/repo.py): management commands · Repositories, monitors, playbooks, teams, templates, shards, and AI. · `src/satoricli/cli/commands/repo.py`
- [Report and scan commands](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/report.py): result commands · `src/satoricli/cli/commands/report.py`
- [Config and settings](https://github.com/satorici/satori-cli/blob/main/src/satoricli/cli/commands/config.py): credential commands · Manages the API token and user configuration. · `src/satoricli/cli/commands/config.py`

### Playbook packaging

- [Playbook handling](https://github.com/satorici/satori-cli/blob/main/src/satoricli/playbooks.py): YAML input model · Resolves specifications and imports. · `src/satoricli/playbooks.py`
- [Validation](https://github.com/satorici/satori-cli/blob/main/src/satoricli/validations.py): input validation · `src/satoricli/validations.py`
- [Bundler](https://github.com/satorici/satori-cli/blob/main/src/satoricli/bundler.py): payload packaging · Collects project files and playbook payloads for upload. · `src/satoricli/bundler.py`

### Satori CI platform

- [API client](https://github.com/satorici/satori-cli/blob/main/src/satoricli/api.py): service client · Single boundary for remote Satori operations. · `src/satoricli/api.py`
- [Error translation](https://github.com/satorici/satori-cli/blob/main/src/satoricli/exceptions.py): exceptions · `src/satoricli/exceptions.py`
- **Satori CI API**: remote platform · Executes Docker-hosted tests on AWS and stores resources and reports.
- **Run reports**: remote results · Status, test outcomes, assertions, and elapsed time.
- **GitHub and notifications**: external integrations · GitHub App workflows plus optional Slack, email, issue, Discord, and Telegram delivery.

## Connections

- CLI entry point → Command root: starts
- Command root → Argument parsing: parses
- Command root → Command base: dispatches through
- Command base → Run command: shared behavior
- Command base → Local command: shared behavior
- Command base → Resource commands: shared behavior
- Command base → Report and scan commands: shared behavior
- Command base → Config and settings: shared behavior
- Run command → Playbook handling: resolves input
- Playbook handling → Validation: validates
- Playbook handling → Bundler: provides payload
- Bundler → API client: upload bundle
- Run command → API client: submit and poll
- Resource commands → API client: manage remote resources
- Report and scan commands → API client: fetch reports and scans
- Config and settings → API client: configures token use
- API client → Error translation: translates failures
- API client → Satori CI API: HTTPS API
- Satori CI API → Run reports: creates and stores
- Run reports → API client: returned for rendering
- Satori CI API → GitHub and notifications: connects and notifies
