# luluno01/cloush architecture

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

- Interactive diagram: https://gitdiagram.com/luluno01/cloush
- Repository: https://github.com/luluno01/cloush

## Overview

##### Project Type and Purpose
- Cloush is a single-page, cross-platform SSH client built with Vue.js. Its sole purpose is to let users initiate SSH connections via a web browser. Note that it works as a client that connects to externally hosted services (namely, a WebSSHD server for pseudoterminal processes and a separate credential storage server). It’s designed for distributed credential management and remote SSH connectivity.

##### File Structure
- The project is organized in a typical Vue.js structure:
- The root-level files (like package.json, vue.config.js, and tsconfig.json) indicate configuration for building and serving the application.
- The src folder holds the bulk of the code:
▪ Main entry point (main.ts)
▪ Components (with views and reusable UI like SSHConsole, EditServer, VirtualKeyboard)
▪ Views broken down into different screens (Home, ServerList, CredentialStorage, etc.)
▪ Store modules for state management (ConfigStore, CredentialStore, etc.)
▪ Router configuration suggesting multiple pages for different functionalities.
▪ Helper functions (for handling HTTP errors and WebSocket tasks) which indicate how external communications are managed.
- The structure suggests a separation between UI components, state management, routing, and helper libraries for network communications.

##### Extract Architectural Insights from the README
- The README clarifies that the role of Cloush is a client for SSH connections. It needs to interact with:
- A WebSSHD server (via WebSocket using libraries like Socket.IO and node-pty behind the scenes).
- A separate credential storage server, which manages credentials externally.

a. Main Components:
- User Interface (Browser-based SPA using Vue.js with components including views, modals, and controls such as SSHConsole and VirtualKeyboard).
- State Management Layer (Vuex store modules: ConfigStore, CredentialStore, SSHConsoles, UpstreamStore) which orchestrate data flow within the client.
- Network/Communication Helpers (from the src/helpers directory handling HTTP and WebSocket communications).
- External Services:
▪ WebSSHD Server: accepts WebSocket connections to run a pseudo-terminal session.
▪ Credential Storage Server: manages credentials which the client queries.
b. Relationships and Interactions:
- The UI components interact with the state management layer to retrieve data, display proper views, and manage user input.
- The helpers serve as intermediaries that fetch data (credentials) or signal errors via HTTP calls and establish WebSocket connections to the WebSSHD server.
- The client’s router (in src/router) manages the navigation between views such as Home, CredentialStorage, and ServerList.
c. Architectural Patterns & Design Principles:
- Separation of concerns: UI components, routing, state management, and network communication are clearly separated.
- Single Page Application (SPA) design with Vue.js, ensuring modularity and reusability.
- Client-centric design where the heavy lifting (credential storage and terminal handling) is offloaded to backend servers.
d. Specify Relevant Technologies, Frameworks, or Libraries:
- Vue.js (component & SPA framework)
- Vuetify (UI framework, incorporated via a plugin)
- TypeScript (seen in various .ts files and shims)
- Socket.IO and node-pty (implied for user’s WebSSHD server integration)
- Vue Router (for navigation)
- Possible use of REST API calls (fetchJSON, fetchText helpers)

##### Bringing All Elements Together
- To indicate that the client is the orchestrator that enters user commands and then relays these commands to the external SSH service, using stored credentials retrieved from the credential service.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client SPA"
        subgraph "User Interface (Vue.js)"
            UI1["SSHConsole"]:::ui
            UI2["EditServer"]:::ui
            UI3["VirtualKeyboard"]:::ui
            subgraph "Views"
                V1["Home"]:::view
                V2["ServerList"]:::view
                V3["CredentialStorage"]:::view
                V4["About"]:::view
                V5["Consoles"]:::view
                V6["Settings"]:::view
            end
        end
        subgraph "State Management & Routing"
            SM1["ConfigStore"]:::store
            SM2["CredentialStore"]:::store
            SM3["SSHConsoles"]:::store
            SM4["UpstreamStore"]:::store
            SMIndex["Store Index"]:::store
            Router["Router"]:::router
        end
        subgraph "Network Helpers"
            NH1["HTTPErrors"]:::helper
            NH2["SocketHandler"]:::helper
            NH3["fetchJSON"]:::helper
            NH4["fetchText"]:::helper
            NH5["sha512"]:::helper
        end
    end

    subgraph "External Services"
        E1["Credential Storage Server"]:::external
        E2["WebSSHD Server"]:::external
    end

    UI1 -->|"navigate"| Router
    UI1 -->|"updateState"| SMIndex
    Router -->|"route"| V1
    SMIndex -->|"fetchCredentials"| NH3
    SMIndex -->|"initiateSSH"| NH2
    NH3 -->|"REST"| E1
    NH4 -->|"REST"| E1
    NH2 -->|"WebSocket"| E2

    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef view fill:#87CEEB,stroke:#000,stroke-width:1px;
    classDef store fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef router fill:#98FB98,stroke:#000,stroke-width:1px;
    classDef helper fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef external fill:#FF6347,stroke:#000,stroke-width:1px;

    click UI1 "https://github.com/luluno01/cloush/blob/master/src/components/SSHConsole.vue"
    click UI2 "https://github.com/luluno01/cloush/blob/master/src/components/EditServer.vue"
    click UI3 "https://github.com/luluno01/cloush/blob/master/src/components/VirtualKeyboard.vue"
    click V1 "https://github.com/luluno01/cloush/blob/master/src/views/Home.vue"
    click V2 "https://github.com/luluno01/cloush/blob/master/src/views/ServerList.vue"
    click V3 "https://github.com/luluno01/cloush/blob/master/src/views/CredentialStorage.vue"
    click V4 "https://github.com/luluno01/cloush/blob/master/src/views/About.vue"
    click V5 "https://github.com/luluno01/cloush/blob/master/src/views/Consoles.vue"
    click V6 "https://github.com/luluno01/cloush/blob/master/src/views/Settings.vue"
    click SM1 "https://github.com/luluno01/cloush/blob/master/src/store/ConfigStore.ts"
    click SM2 "https://github.com/luluno01/cloush/blob/master/src/store/CredentialStore.ts"
    click SM3 "https://github.com/luluno01/cloush/blob/master/src/store/SSHConsoles.ts"
    click SM4 "https://github.com/luluno01/cloush/blob/master/src/store/UpstreamStore.ts"
    click SMIndex "https://github.com/luluno01/cloush/blob/master/src/store/index.ts"
    click Router "https://github.com/luluno01/cloush/blob/master/src/router/index.ts"
    click NH1 "https://github.com/luluno01/cloush/blob/master/src/helpers/HTTPErrors.ts"
    click NH2 "https://github.com/luluno01/cloush/blob/master/src/helpers/SocketHandler.ts"
    click NH3 "https://github.com/luluno01/cloush/blob/master/src/helpers/fetchJSON.ts"
    click NH4 "https://github.com/luluno01/cloush/blob/master/src/helpers/fetchText.ts"
    click NH5 "https://github.com/luluno01/cloush/blob/master/src/helpers/sha512.ts"
```
