# dennislwm/viki architecture

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

- Interactive diagram: https://gitdiagram.com/dennislwm/viki
- Repository: https://github.com/dennislwm/viki

## Overview

##### Main Components Identification

The system consists of several key components that should be represented:

a) CLI Interface Layer
- Entry point (viki.py)
- Command processing (cli.py, cli_request.py)

b) Core Processing Layer
- Response handlers (apply_response.py, fetch_response.py, plan_response.py)
- Base response handling (base_response.py)

c) Infrastructure Layer
- SSH communication (my_ssh.py, ssh_command.py)
- Configuration management
- State management

**┌─────────────────────────────────────┐**
- User Input               │
- ┘
- ↓
**┌─────────────────────────────────────┐**
- CLI Interface Layer         │
- ┌─────────┐        ┌──────────┐   │
- viki.py │←──────→│  cli.py  │   │
- ┘        └──────────┘   │
- ┘
- ↓
**┌─────────────────────────────────────┐**
- Core Processing Layer         │
- ┌─────────┐    ┌───────────────┐  │
- Response │←───│base_response.py│  │
- Handlers │    └───────────────┘  │
- ┘                       │
- ┘
- ↓
**┌─────────────────────────────────────┐**
- Infrastructure Layer           │
- ┌─────────┐    ┌───────────────┐  │
- SSH/Command    │Configuration  │  │
- Management│←──→│& State Files  │  │
- ┘    └───────────────┘  │
- ┘
- ↓
**┌─────────────────────────────────────┐**
- Target Servers              │
- ┘

##### Important Elements

a) File Interactions:
- YAML configuration file input
- JSON state file storage
- Command module definitions (DATA_COMMAND and MODS_COMMAND)

b) Process Flows:
- Command processing path
- SSH communication flow
- State management operations

##### Notes Section

A notes section highlighting:
- No dependencies between modules
- No update operations (only add/destroy)
- No priority in resource creation/destruction
- No local server support (future TODO)

Remember to emphasize the declarative nature of the configuration management and how the state file interacts with the system components. This is crucial for understanding the tool's core functionality and operation model.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef cli fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef infra fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef support fill:#9b59b6,stroke:#8e44ad,color:white

    %% User Input
    UserInput[User Input]:::external

    %% CLI Interface Layer
    subgraph CLI
        EntryPoint[viki.py]:::cli
        CliProcessor[cli.py]:::cli
        CliRequest[cli_request.py]:::cli
    end

    %% Core Processing Layer
    subgraph Core
        BaseResponse[base_response.py]:::core
        ApplyResponse[apply_response.py]:::core
        FetchResponse[fetch_response.py]:::core
        PlanResponse[plan_response.py]:::core
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        SSHCore[my_ssh.py]:::infra
        SSHCommand[ssh_command.py]:::infra
        ConfigState[Configuration & State Files]:::infra
    end

    %% Supporting Components
    Logger[logger.py]:::support

    %% Target Servers
    TargetServers[Target Servers]:::external

    %% Relationships
    UserInput --> EntryPoint
    EntryPoint --> CliProcessor
    CliProcessor --> CliRequest
    CliRequest --> BaseResponse
    BaseResponse --> ApplyResponse & FetchResponse & PlanResponse
    ApplyResponse & FetchResponse & PlanResponse --> SSHCore
    SSHCore --> SSHCommand
    SSHCommand --> ConfigState
    SSHCommand --> TargetServers
    
    %% Logger connections
    Logger -.-> EntryPoint
    Logger -.-> CliProcessor
    Logger -.-> BaseResponse
    Logger -.-> SSHCore

    %% Click Events
    click EntryPoint "https://github.com/dennislwm/viki/blob/main/app/viki.py"
    click CliProcessor "https://github.com/dennislwm/viki/blob/main/app/common/cli.py"
    click CliRequest "https://github.com/dennislwm/viki/blob/main/app/common/cli_request.py"
    click BaseResponse "https://github.com/dennislwm/viki/blob/main/app/common/base_response.py"
    click ApplyResponse "https://github.com/dennislwm/viki/blob/main/app/common/apply_response.py"
    click FetchResponse "https://github.com/dennislwm/viki/blob/main/app/common/fetch_response.py"
    click PlanResponse "https://github.com/dennislwm/viki/blob/main/app/common/plan_response.py"
    click SSHCore "https://github.com/dennislwm/viki/blob/main/app/common/my_ssh.py"
    click SSHCommand "https://github.com/dennislwm/viki/blob/main/app/common/ssh_command.py"
    click Logger "https://github.com/dennislwm/viki/blob/main/app/common/logger.py"

    %% Legend
    subgraph Legend
        CLI_Legend[CLI Interface]:::cli
        Core_Legend[Core Processing]:::core
        Infra_Legend[Infrastructure]:::infra
        Support_Legend[Support Components]:::support
        External_Legend[External Components]:::external
    end
```
