# kong/deck architecture

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

- Interactive diagram: https://gitdiagram.com/kong/deck
- Repository: https://github.com/kong/deck

## Overview

##### Main Components Identification

a) Core Command Components (cmd/)
- Configuration Management Commands
- Gateway Management Commands
- Konnect Integration Commands

b) Conversion Components (convert/, kong2kic/, kong2tf/)
- Kong to Kubernetes Ingress Controller converter
- Kong to Terraform converter
- General format converter

c) Validation Layer (validate/)
- Configuration validator
- Konnect compatibility checker

d) Integration Layer (tests/integration/)
- Kong Gateway interface
- Konnect interface

**┌─────────────────────────────────────────────────────────────┐**
- decK CLI                             │
- ┬─────────────────┬────────────────┬─────────┘

**┌───────────────▼───┐    ┌───────▼──────┐  ┌─────▼─────────┐**
- Command Layer    │    │ Convert Layer │  │ Validate Layer│

- Sync           │    │ - Kong2KIC   │  │ - Schema      │
- Diff           │    │ - Kong2TF    │  │ - Compatibility│
- Dump           │    │ - Format     │  │               │
- ┬────────┘    └──────┬───────┘  └───────────────┘

**┌─────────▼────────────────────▼───────────────────────┐**
- Integration Layer                      │

- Kong Gateway Interface                             │
- Konnect Interface                                  │
- ┬───────────────────────────┘

**┌─────────────────────────▼───────────────────────────┐**
- External Systems                        │

- Kong Gateway                                      │
- Kong Konnect                                      │
- Kubernetes                                        │
- Terraform                                         │
- ┘

##### Data Flow Indicators

- Configuration file input/output
- API calls to Kong/Konnect
- Conversion processes
- Validation flows

##### Important Details

- File formats supported (YAML)
- Integration points with Kong Gateway
- Conversion capabilities
- Validation rules
- Command operations (sync, diff, dump)

##### Notes for Implementation

- Clear separation between local operations and external system interactions
- Declarative nature of the tool
- Version compatibility information
- Parallel operation capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["decK CLI"]
        direction TB
        Entry["CLI Entry Point"]:::cli
    end

    subgraph CommandLayer["Command Layer"]
        direction TB
        ConfigMgmt["Configuration Management"]:::cmd
        GatewayMgmt["Gateway Management"]:::cmd
        KonnectMgmt["Konnect Integration"]:::cmd
        CommonUtils["Common Utilities"]:::cmd
        FileOps["File Operations"]:::cmd
        VersionMgmt["Version Management"]:::cmd
    end

    subgraph ConvertLayer["Convert Layer"]
        direction TB
        Kong2KIC["Kong to K8s Converter"]:::convert
        Kong2TF["Kong to Terraform Converter"]:::convert
        FormatConv["General Format Converter"]:::convert
    end

    subgraph ValidateLayer["Validate Layer"]
        direction TB
        ConfigVal["Configuration Validator"]:::validate
        KonnectCompat["Konnect Compatibility Checker"]:::validate
    end

    subgraph IntegrationLayer["Integration Layer"]
        direction TB
        KongInterface["Kong Gateway Interface"]:::integration
        KonnectInterface["Konnect Interface"]:::integration
        IntegrationTests["Integration Tests"]:::integration
    end

    subgraph ExternalSystems["External Systems"]
        direction TB
        KongGateway["Kong Gateway"]:::external
        Konnect["Kong Konnect"]:::external
        Kubernetes["Kubernetes"]:::external
        Terraform["Terraform"]:::external
    end

    Entry --> CommandLayer
    Entry --> ConvertLayer
    Entry --> ValidateLayer

    CommandLayer --> IntegrationLayer
    ConvertLayer --> IntegrationLayer
    ValidateLayer --> IntegrationLayer

    IntegrationLayer --> ExternalSystems

    %% Click events for component mapping
    click ConfigMgmt "https://github.com/Kong/deck/blob/main/cmd/file.go"
    click GatewayMgmt "https://github.com/Kong/deck/blob/main/cmd/gateway.go"
    click KonnectMgmt "https://github.com/Kong/deck/blob/main/cmd/konnect.go"
    click Kong2KIC "https://github.com/Kong/deck/blob/main/kong2kic/kong2kic.go"
    click Kong2TF "https://github.com/Kong/deck/blob/main/kong2tf/kong2tf.go"
    click FormatConv "https://github.com/Kong/deck/blob/main/convert/convert.go"
    click ConfigVal "https://github.com/Kong/deck/blob/main/validate/validate.go"
    click KonnectCompat "https://github.com/Kong/deck/blob/main/validate/konnect_compatibility.go"
    click KongInterface "https://github.com/Kong/deck/blob/main/tests/integration/test_utils.go"
    click IntegrationTests "https://github.com/Kong/deck/blob/main/tests/integration/sync_test.go"
    click KonnectInterface "https://github.com/Kong/deck/tree/main/tests/integration/testdata/sync/026-konnect-rename"
    click CommonUtils "https://github.com/Kong/deck/blob/main/cmd/common.go"
    click FileOps "https://github.com/Kong/deck/blob/main/cmd/file.go"
    click VersionMgmt "https://github.com/Kong/deck/blob/main/cmd/version.go"

    %% Styling
    classDef cli fill:#2374ab
    classDef cmd fill:#457b9d
    classDef convert fill:#2a9d8f
    classDef validate fill:#e9c46a
    classDef integration fill:#a8dadc
    classDef external fill:#f4f1de

    %% Legend
    subgraph Legend
        CLI_Component["CLI Component"]:::cli
        Command_Component["Command Component"]:::cmd
        Convert_Component["Convert Component"]:::convert
        Validate_Component["Validate Component"]:::validate
        Integration_Component["Integration Component"]:::integration
        External_Component["External Component"]:::external
    end
```
