# blackmamoth/sshsync architecture

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

- Interactive diagram: https://gitdiagram.com/blackmamoth/sshsync
- Repository: https://github.com/blackmamoth/sshsync

## Overview

##### Project type and purpose
- This is a standalone, open-source Python CLI tool (“sshsync”) for running shell commands and transferring files over SSH to multiple servers in parallel. It’s distributed via PyPI and managed as a typical Python package.

##### File structure
- Top‐level config files:
- pyproject.toml (build & dependencies)
- pyrightconfig.json (type checking)
- .github/workflows/pypi.yml (CI/CD)
- Source tree under src/sshsync:
- cli.py – Click‐style command layer (parses user input, dispatches subcommands)
- client.py – Core engine: orchestrates SSH connections, concurrency, command/file operations
- config.py – Reads/writes YAML config (group → hosts mapping) and loads ~/.ssh/config
- schemas.py – Pydantic or dataclass schemas for validation (hosts, groups, options)
- logging.py – Sets up structured logging and writes to platform‐specific log dirs
- utils.py – Low‐level helpers (path normalization, dry‐run simulation, concurrency wrappers)
- There is no frontend/web layer or database—state is in the user’s filesystem (YAML + SSH config + logs).

##### README for additional insights
- Architecture is implicit: CLI → config lookup → async SSH connections → logging
- Leverages asyncssh library for concurrency
- Stores operations history locally; uses existing ~/.ssh/config

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User environment
    User["User Terminal"]:::user

    %% Application modules
    subgraph "Application"
        CLIModule["CLI Module\n(cli.py)"]:::frontend
        CoreEngine["Core Engine\n(client.py)"]:::core
        Utils["Utility Helpers\n(utils.py)"]:::core
        Schemas["Schemas\n(schemas.py)"]:::core
    end

    %% Configuration and logging
    subgraph "Configuration Store" 
        ConfigStore["Config Store\n(config.py)"]:::storage
    end

    subgraph "Logging Subsystem"
        Logging["Logging Subsystem\n(logging.py)"]:::storage
    end

    %% External dependencies
    asyncssh["asyncssh Library"]:::external
    Remote["Remote Servers\n(SSH Daemons)"]:::external

    %% Project metadata
    subgraph "Project Configuration"
        Init["Package Init\n(__init__.py)"]:::meta
        PyProject["pyproject.toml"]:::meta
        Pyright["pyrightconfig.json"]:::meta
        CICD["CI/CD Workflow\n(.github/workflows/pypi.yml)"]:::meta
    end

    %% Data flows
    User -->|invokes sshsync| CLIModule
    CLIModule -->|dispatches command| CoreEngine
    CoreEngine -->|reads hosts/groups| ConfigStore
    CoreEngine -->|validates data| Schemas
    CoreEngine -->|helper functions| Utils
    CoreEngine -.->|opens SSH session| asyncssh
    asyncssh -->|SSH session| Remote
    Remote -->|command results| CoreEngine
    CoreEngine -->|aggregates results| CLIModule
    CLIModule -->|outputs to user| User
    CoreEngine -->|writes log entry| Logging

    %% Click events
    click CLIModule "https://github.com/blackmamoth/sshsync/blob/main/src/sshsync/cli.py"
    click CoreEngine "https://github.com/blackmamoth/sshsync/blob/main/src/sshsync/client.py"
    click ConfigStore "https://github.com/blackmamoth/sshsync/blob/main/src/sshsync/config.py"
    click Schemas "https://github.com/blackmamoth/sshsync/blob/main/src/sshsync/schemas.py"
    click Utils "https://github.com/blackmamoth/sshsync/blob/main/src/sshsync/utils.py"
    click Logging "https://github.com/blackmamoth/sshsync/blob/main/src/sshsync/logging.py"
    click Init "https://github.com/blackmamoth/sshsync/blob/main/src/sshsync/__init__.py"
    click PyProject "https://github.com/blackmamoth/sshsync/blob/main/pyproject.toml"
    click Pyright "https://github.com/blackmamoth/sshsync/blob/main/pyrightconfig.json"
    click CICD "https://github.com/blackmamoth/sshsync/blob/main/.github/workflows/pypi.yml"

    %% Styles
    classDef user fill:#D0E4F5,stroke:#3182bd,color:#0b3c5d
    classDef frontend fill:#BEE3F8,stroke:#3182bd,color:#0b3c5d
    classDef core fill:#D1FAE5,stroke:#22C55E,color:#166534
    classDef external fill:#FEF9C3,stroke:#D97706,color:#92400E
    classDef storage fill:#E5E7EB,stroke:#6B7280,color:#374151
    classDef meta fill:#F3F4F6,stroke:#9CA3AF,color:#4B5563
```
