# advance-technologies-foundation/clio architecture

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

- Interactive diagram: https://gitdiagram.com/advance-technologies-foundation/clio
- Repository: https://github.com/advance-technologies-foundation/clio

## Overview

##### Main Components
- CLI Application Core: Start with the entry point (clio/Program.cs) that sets up the command-line interface, parses arguments, and dispatches the commands.
- Command Dispatcher and Handlers: The bulk of the commands reside in the clio/Command directory. Each command (for example, AddPackageCommand, DeletePackageCommand, DeployAppCommand, etc.) represents a concrete operation. This layer handles the routing of command-line instructions to the appropriate business logic.
- Domain Logic & Business Modules: Under directories like clio/Package, clio/Workspace, clio/CreatioModel, and clio/Environment, you have modules that encapsulate the domain functionalities. For instance:
- Package management (creating, installing, and updating packages)
- Workspace and environment configuration and restoration
- Creatio-specific model representations and actions.
- Shared Utilities and Infrastructure: The clio/Common directory includes cross-cutting services such as file handling (FileSystem, FileManager), logging (ConsoleLogger, ILogStreamer), process execution (IDotnetExecutor, IProcessExecutor), and configuration utilities.
- External Integration Modules: There are integrations with external systems (e.g., ClioGateway under clio/Common and modules in clio/cliogate) which handle interactions with external web services, NuGet (in clio/Package/NuGet), or even APIs of the Creatio platform.
- Testing and Validation: Several test projects (clio.TestsAPI, clio.tests, cliogate.tests) indicate that there is strong automated testing of both API and unit level modules.
- Templates and Configuration: The clio/tpl directory houses templates for generating project files, nuspecs, JSON schemas, and Docker deployment scripts. This supports extensibility for generating or validating external resources.
- Deployment and Containerization: The existence of a Dockerfile (under install/Dockerfile) and build scripts provide a layer for containerization and CI/CD integration.

##### Relationships and Interactions
- User/Developer Interaction → CLI Front-End:
– Users run commands (either via terminal or using the VS Code extension) that are parsed at the CLI entry point.
- CLI Dispatcher → Command Handlers:
– The command dispatcher routes execution to the proper command handlers.
- Command Handlers → Domain Modules & Shared Services:
– Business logic for each command contacts the underlying modules (for example, package installation, environment setup, file and process management).
– They leverage shared utilities found in clio/Common.
- Domain Modules → External Systems:
– Modules in clio/Package and clio/Workspace may call out to external APIs (e.g., Creatio’s services, NuGet package sources) or interact with the file system.
- Testing Frameworks:
– Automated tests in clio.tests and clio.TestsAPI simulate and validate interactions between these layers.
- Docker:
– The Docker components encapsulate the runtime for the CLI in containerized environments.

##### Architectural Patterns and Design Principles
- Command Pattern: Each operation is isolated as a distinct command, which enhances maintainability, testability, and extensibility.
- Separation of Concerns: The clear division between CLI input/dispatch, business logic (domain modules), utility services, and external integrations ensures that each piece is responsible for a specific concern.
- Layered Architecture: Presentation (CLI and VS Code extension), Application (commands and dispatchers), Domain (Creatio-centric packages, workspace management), and Infrastructure (common utilities, external service integrations) are separated in distinct layers.

## Diagram (Mermaid)

```mermaid
graph TD
    Developer["Developer (User)"]:::user
    CLI["CLI Front-End/Entry Point"]:::cli
    Dispatcher["Command Dispatcher & Handlers"]:::command

    subgraph "Domain Modules"
        Package["Package Management\n(Handles packages)"]:::domain
        Workspace["Workspace Management\n(Manages workspaces)"]:::domain
        Creatio["Creatio Model\n(Models Creatio entities)"]:::domain
        Environment["Environment Configuration\n(Sets environments)"]:::domain
    end

    Utilities["Shared Utilities & Infrastructure\n(File handling, Logging, Process execution)"]:::util
    Integration["External Integration Modules\n(API integrations, NuGet, ClioGateway)"]:::external
    Templates["Templates & Configuration\n(Templates, Docker scripts)"]:::config
    Testing["Testing & Validation Frameworks"]:::test
    Deployment["Deployment & Containerization\n(Docker, CI/CD pipelines)"]:::deploy

    %% Relationships
    Developer -->|"runs"| CLI
    CLI -->|"parses"| Dispatcher
    Dispatcher -->|"invokes"| Package
    Dispatcher -->|"invokes"| Workspace
    Dispatcher -->|"invokes"| Creatio
    Dispatcher -->|"invokes"| Environment

    Package -->|"uses"| Utilities
    Workspace -->|"uses"| Utilities
    Creatio -->|"uses"| Utilities
    Environment -->|"uses"| Utilities

    Package -->|"calls"| Integration
    Workspace -->|"calls"| Integration
    Creatio -->|"calls"| Integration
    Environment -->|"calls"| Integration

    Dispatcher -->|"generates"| Templates

    Testing -->|"tests"| Dispatcher
    Testing -->|"tests"| Package
    Testing -->|"tests"| Workspace
    Testing -->|"tests"| Creatio
    Testing -->|"tests"| Environment
    Testing -->|"tests"| CLI

    CLI -->|"containerized_with"| Deployment

    %% Click Events
    click CLI "https://github.com/advance-technologies-foundation/clio/blob/master/clio/Program.cs"
    click Dispatcher "https://github.com/advance-technologies-foundation/clio/tree/master/clio/Command"
    click Package "https://github.com/advance-technologies-foundation/clio/tree/master/clio/Package"
    click Workspace "https://github.com/advance-technologies-foundation/clio/tree/master/clio/Workspace"
    click Creatio "https://github.com/advance-technologies-foundation/clio/tree/master/clio/CreatioModel"
    click Environment "https://github.com/advance-technologies-foundation/clio/tree/master/clio/Environment"
    click Utilities "https://github.com/advance-technologies-foundation/clio/tree/master/clio/Common"
    click Integration "https://github.com/advance-technologies-foundation/clio/tree/master/clio/cliogate"
    click Templates "https://github.com/advance-technologies-foundation/clio/tree/master/clio/tpl"
    click Testing "https://github.com/advance-technologies-foundation/clio/blob/master/clio.TestsAPI"
    click Deployment "https://github.com/advance-technologies-foundation/clio/tree/master/install/Dockerfile"

    %% Styles
    classDef user fill:#ffdddd,stroke:#990000,stroke-width:2px;
    classDef cli fill:#ddffdd,stroke:#006600,stroke-width:2px;
    classDef command fill:#ddeeff,stroke:#003399,stroke-width:2px;
    classDef domain fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef util fill:#e0e0e0,stroke:#555555,stroke-width:2px;
    classDef external fill:#ffebcc,stroke:#cc6600,stroke-width:2px;
    classDef config fill:#e6f7ff,stroke:#005f99,stroke-width:2px;
    classDef test fill:#ffe6e6,stroke:#cc0000,stroke-width:2px;
    classDef deploy fill:#e6ffe6,stroke:#009900,stroke-width:2px;
```
