# grendel-consulting/steampipe-plugin-kolide architecture

> Architecture diagram of the GitHub repository grendel-consulting/steampipe-plugin-kolide, 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/grendel-consulting/steampipe-plugin-kolide
- Repository: https://github.com/grendel-consulting/steampipe-plugin-kolide

## Overview

##### Main Components

a. Client Layer:
- Steampipe CLI/Postgres FDW/SQLite Extension/Export/Turbot Pipes (show as entry points)
- Configuration Component (~/.steampipe/config/kolide.spc)

b. Plugin Core:
- Plugin Interface (plugin.go)
- Connection Configuration (connection_config.go)
- Table Definitions (all table_kolide_*.go files)
- Client Implementation (client/* files)

c. External Systems:
- Kolide API
- Kolide Backend Services

##### Component Relationships

- User Query → Steampipe Engine
- Steampipe Engine → Plugin Interface
- Plugin Interface → Table Definitions
- Table Definitions → Client Implementation
- Client Implementation → Kolide API
- Pagination handling and error management flows

##### Specific Implementation Details

Create distinct sections for:
- Authentication Flow (using API tokens)
- Query Processing Pipeline
- Data Transformation Layer
- Resource Types (Admin Users, Devices, People, Checks, Issues, etc.)

##### Key Architectural Patterns to Highlight

- Table-based abstraction pattern (shown by table definitions)
- API client pattern (shown in client implementation)
- Plugin architecture pattern (showing how it integrates with Steampipe)

##### Layer Organization

1. User/Client Layer (Steampipe interfaces)
2. Plugin Layer (Core plugin components)
3. Integration Layer (API client and handlers)
4. External Service Layer (Kolide API)

- The plugin's role as a bridge between Steampipe and Kolide
- The transformation of SQL queries into API calls
- The handling of various resource types (reflected in the table definitions)
- Error handling and pagination mechanisms
- Configuration management

Keep the abstraction level focused on the architectural components while including enough detail to show the plugin's specific functionality for Kolide integration. This balance will help maintain clarity while providing valuable technical insight.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef steampipe fill:#90EE90,stroke:#333,stroke-width:2px
    classDef plugin fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef kolide fill:#FFA500,stroke:#333,stroke-width:2px
    classDef config fill:#FFE4B5,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        CLI["Steampipe CLI"]:::steampipe
        PFDW["Postgres FDW"]:::steampipe
        SQLE["SQLite Extension"]:::steampipe
        EXP["Export"]:::steampipe
        TPS["Turbot Pipes"]:::steampipe
        CONFIG["Configuration File"]:::config
    end

    %% Plugin Core Layer
    subgraph PluginCore["Plugin Core"]
        PINT["Plugin Interface"]:::plugin
        CCONF["Connection Configuration"]:::plugin
        
        subgraph Tables["Table Definitions"]
            TADM["Admin Users Table"]:::plugin
            TDEV["Devices Table"]:::plugin
            TPER["People Table"]:::plugin
            TISS["Issues Table"]:::plugin
        end
        
        subgraph Client["Client Implementation"]
            CMAIN["Main Client"]:::plugin
            CFETCH["API Interaction"]:::plugin
            CPAG["Pagination Handler"]:::plugin
            CSEARCH["Search Handler"]:::plugin
            CERR["Error Management"]:::plugin
        end
    end

    %% Resource Handlers
    subgraph ResHandlers["Resource Type Handlers"]
        HADM["Admin Users Handler"]:::plugin
        HDEV["Devices Handler"]:::plugin
        HPER["People Handler"]:::plugin
        HISS["Issues Handler"]:::plugin
    end

    %% External Systems
    subgraph External["External Systems"]
        KAPI["Kolide API"]:::kolide
        KBACK["Kolide Backend Services"]:::kolide
    end

    %% Relationships
    CLI & PFDW & SQLE & EXP & TPS --> PINT
    CONFIG --> PINT
    PINT --> CCONF
    CCONF --> Tables
    Tables --> Client
    Client --> ResHandlers
    ResHandlers --> KAPI
    KAPI --> KBACK

    %% Click Events
    click CONFIG "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/config/kolide.spc"
    click PINT "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/plugin.go"
    click CCONF "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/connection_config.go"
    click TADM "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/table_kolide_admin_user.go"
    click TDEV "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/table_kolide_device.go"
    click TPER "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/table_kolide_person.go"
    click TISS "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/table_kolide_issue.go"
    click CMAIN "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/client.go"
    click CFETCH "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/fetch.go"
    click CPAG "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/pagination.go"
    click CSEARCH "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/search.go"
    click CERR "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/errors.go"
    click HADM "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/admin_users.go"
    click HDEV "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/devices.go"
    click HPER "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/people.go"
    click HISS "https://github.com/grendel-consulting/steampipe-plugin-kolide/blob/main/kolide/client/issues.go"

    %% Legend
    subgraph Legend
        L1["Steampipe Components"]:::steampipe
        L2["Plugin Components"]:::plugin
        L3["Kolide Components"]:::kolide
        L4["Configuration"]:::config
    end
```
