# ssotops/gitspace architecture

> Architecture diagram of the GitHub repository ssotops/gitspace, 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/ssotops/gitspace
- Repository: https://github.com/ssotops/gitspace

## Overview

##### Main Components
- CLI Application (Entry Point): Represented by main.go at the project root together with additional UI handling (ui.go) and command initializations. This is the user-exposed layer where commands are parsed and actions triggered.
- Configuration Manager: The tool expects a gs.toml configuration file. Show a component responsible for reading and validating global settings, auth, and group rules as outlined in the README.
- Repository Manager: This component reads configuration details and handles cloning repositories from the specified SCM (e.g., GitHub or Gitea). Files in the lib directory such as gitea.go, github.go, scm_provider.go, and types.go suggest a well-abstracted handling of SCM interactions.
- Plugin System: gitspace supports plugins to extend its functionality (see the “plugin” directory containing handler.go, installer.go, manager.go, etc.). This subsystem manages plugin installation/uninstallation and runtime invocation.
- Utility Modules & Supporting Scripts: Utilities (utils.go); symlink creation (symlink.go); core repository management (repository.go) which contains the logic for organizing the cloned repos; and the versioning (version.go).
- Build & Deployment Scripts: Several scripts such as build.sh, ecosystem-build.sh, install.sh, and uninstall.sh indicate how the project is built, installed, and deployed. These should be shown as part of the development and deployment pipeline.
- External Integrations: Although not a separate service, the architecture logically integrates with external systems (GitHub, Gitea, etc.) as defined by the SCM provider components.

##### Relationships and Data Flow
- Once repositories are managed, symlink creation and labeling tasks are executed; include interactions between “Repository Manager” and utility modules (symlink creation utility).
- Build & Deployment scripts are used during development and CI/CD (e.g., ecosystem-build.sh and build.sh), so include a separate “Build Pipeline” component connected to source components and deployment targets.

##### Important Architectural Patterns and Design Principles
- Modularity: The separation of configuration, repository handling, and the plugin system shows a modular design. Each module (CLI, lib, plugin) is self-contained.
- Abstraction: The use of interfaces for SCM providers indicates that the system is designed to accommodate multiple source control systems seamlessly.
- Extensibility: The dedicated plugin directory and manager suggests a clear extension point for adding new functionality without disturbing core logic.
- Clear Separation of Concerns: The division between configuration processing, execution of clone/symlink operations, and the plugin system helps isolate responsibilities.

##### Technologies and Frameworks
- Go Language: The entire codebase is implemented in Go.
- Deployment and CI/CD: GitHub Actions workflows (in the .github/workflows directory) and provisioning scripts indicate integration with modern CI/CD practices.
- Configuration Format: The use of TOML (gs.toml) for configuration.

– From “CLI Application” to “Configuration Manager” (indicating config file loading).
– From “Configuration Manager” to “Repository Manager” (indicating usage of settings).
– From “Repository Manager” to “External SCM Systems” (illustrating cloning operations).
– Between “Repository Manager” and “Plugin System” to denote extension points.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Layer"
        CLI["CLI: Entry Point (main.go, ui.go)"]:::core
    end

    subgraph "Core Logic"
        Config["Configuration Manager (config.go, gs.toml)"]:::core
        Repo["Repository Manager (repository.go, lib)"]:::core
        Plugin["Plugin System (plugin directory)"]:::plugin
    end

    subgraph "External Systems"
        GitHub["GitHub"]:::external
        Gitea["Gitea"]:::external
    end

    subgraph "Supporting Modules"
        Utils["Utilities (utils.go, symlink.go, version.go)"]:::core
    end

    subgraph "Build Pipeline"
        Build["Build & Deployment Scripts (build.sh, ecosystem-build.sh, install.sh, uninstall.sh, local-install.sh, rm-docker.sh, test.sh)"]:::build
    end

    CLI -->|"load_config"| Config
    Config -->|"pass_settings"| Repo
    Config -->|"setup_plugins"| Plugin
    Repo -->|"clone_repos"| GitHub
    Repo -->|"clone_repos"| Gitea
    Repo -->|"create_symlinks"| Utils
    Plugin <-->|"extend_functionality"| Repo
    CLI <-->|"plugin_interaction"| Plugin
    Build -->|"build_deploy"| CLI
    Build -->|"build_deploy"| Repo
    Build -->|"build_deploy"| Plugin

    classDef core fill:#a8d8ea,stroke:#333,stroke-width:2px;
    classDef plugin fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef external fill:#ffdab9,stroke:#333,stroke-width:2px;
    classDef build fill:#dda0dd,stroke:#333,stroke-width:2px;

    click CLI "https://github.com/ssotops/gitspace/blob/master/main.go"
    click Config "https://github.com/ssotops/gitspace/blob/master/config.go"
    click Repo "https://github.com/ssotops/gitspace/blob/master/repository.go"
    click Plugin "https://github.com/ssotops/gitspace/blob/master/plugin/handler.go"
    click Utils "https://github.com/ssotops/gitspace/blob/master/utils.go"
    click Build "https://github.com/ssotops/gitspace/blob/master/build.sh"
```
