# leboncoin/cassh architecture

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

- Interactive diagram: https://gitdiagram.com/leboncoin/cassh
- Repository: https://github.com/leboncoin/cassh

## Overview

Based on our analysis of the file tree and README, CASSH is an SSH key signing solution developed to automate the signing of user public keys (a process traditionally done manually). In this project the core idea is to provide a set of tools – a client CLI to submit signing requests, a backend server to process them, and a WebUI for administrative and interactive operations – all containerized for easier deployment and scalability.

##### Main Components
- Client CLI: Located in src/client, this is the command-line tool that individuals use to add, sign, check status, and manage keys.
- Server Core: Found in src/server, this contains the business logic for processing key-signing, administration commands, and configuration management. Note that this also includes several subcomponents:
– The core signing engine (server.py, server/lib)
– SQL scripts (src/server/sql) that suggest likely database initialization or configuration (even if it is a file-based storage or an actual DB).
– SSH utilities (src/server/ssh_utils) that manage the SSH key operations.
- WebUI: Under src/server/web, this component provides a graphical management interface (with its own Dockerfile and set of templates/static assets) to manage various functions (e.g., signing statuses, administrative actions, etc.).
- Supporting/Deployment Infrastructure: You have several Dockerfiles (for client, server, and WebUI), scripts in the contrib directory for service and Docker setups, and CI/CD files (like .travis.yml) that support deployment and testing.

##### Component Relationships and Data Flow
- The Client CLI issues “add”, “sign”, and “status” commands to the Server.
- The Server processes requests – it reads configuration files, applies signing logic using its tools and SQL configurations, and may interact with SSH utilities.
- For administrative operations (active, revoke, delete, etc.) the Admin CLI (using the same client tool with admin options) communicates with the Server.
- The WebUI serves as an alternative or supplemental administrative tool, providing a browser-based interface that interacts with the same Server or its dedicated REST endpoints (if available).

##### Architectural Patterns and Design Principles
- Separation of concerns is clearly visible – the project is divided into distinct submodules (client, server core, and web front-end).
- Containerization is emphasized – each major part has Docker support.
- There is a testing infrastructure as seen in the tests folder, indicating a layered approach where unit, integration, and system tests simulate the interactions between components.
- The design implies a microservice or modular monolith pattern: although the components might be deployed in separate containers, they are tightly integrated so that even if deployed independently (multiple server instances as indicated in the README), they work as a cohesive system.

##### Relevant Technologies/Frameworks
- Python is the main development language.
- Docker for containerizing the client, server, and web modules.
- Travis CI (as seen in .travis.yml) for continuous integration.
- SSH, OpenSSH, and related libraries are central for key generation and signing.
- SQL scripts hint at some form of configuration or state management (even if not a full-fledged RDBMS, they may be used for initial setup or audits).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        CLI["Client CLI"]:::client
    end

    %% Server Layer with Internal Components
    subgraph "Server Layer"
        SC["Server Core"]:::server
        subgraph "Server Internal"
            Engine["Core Signing Engine (server.py & lib)"]:::engine
            SQL["SQL Config & Data Management (sql)"]:::sql
            SSH["SSH Utilities"]:::ssh
        end
    end

    %% Web Layer
    subgraph "Web Layer"
        Web["WebUI"]:::web
    end

    %% Deployment/Infrastructure
    subgraph "Deployment / Infrastructure"
        Deploy["Docker & Service (contrib)"]:::deploy
        CICD["CI/CD (.travis.yml)"]:::ci
    end

    %% Relationships
    CLI -->|"Key Sign Request"| Engine
    CLI -->|"Status Request"| Engine
    Engine -->|"Executes SQL"| SQL
    Engine -->|"Uses SSH Utils"| SSH
    Engine -->|"Sends Response"| CLI
    Web -->|"Admin Actions/Status"| Engine

    Deploy --- CLI
    Deploy --- Engine
    Deploy --- Web
    CICD --- CLI
    CICD --- Engine
    CICD --- Web

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef server fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef engine fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef sql fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef ssh fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef web fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
    classDef deploy fill:#fefefe,stroke:#ced4da,stroke-width:2px;
    classDef ci fill:#ffcccc,stroke:#cc0000,stroke-width:2px;

    %% Click Events
    click CLI "https://github.com/leboncoin/cassh/tree/master/src/client"
    click Engine "https://github.com/leboncoin/cassh/blob/master/src/server/server.py"
    click SQL "https://github.com/leboncoin/cassh/tree/master/src/server/sql"
    click SSH "https://github.com/leboncoin/cassh/tree/master/src/server/ssh_utils"
    click Web "https://github.com/leboncoin/cassh/tree/master/src/server/web"
    click Deploy "https://github.com/leboncoin/cassh/tree/master/contrib"
    click CICD "https://github.com/leboncoin/cassh/blob/master/.travis.yml"
```
