# turbot/powerpipe architecture

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

- Interactive diagram: https://gitdiagram.com/turbot/powerpipe
- Repository: https://github.com/turbot/powerpipe

## Overview

##### Main Components Identification

a) Core Components:
- Command Line Interface (CLI)
- Dashboard Engine
- Control/Benchmark Engine
- Database Connectors
- WebSocket Server
- UI Dashboard

b) Supporting Components:
- Resource Management
- Workspace Management
- Query Execution
- Configuration Management

**┌─ User Interface Layer ─────────────────────┐**
- Web Dashboard UI (React-based)           │
- CLI Interface                            │
- ┬───────────────────────┘
- ↓
**┌─ Application Layer ──────────────────────────────────────────┐**
- ┌─ Dashboard Engine ─┐ ┌─ Control Engine ─┐ ┌─ Server ─────┐ │
- Layout Manager   │ │ - Benchmark      │ │ - WebSocket  │ │
- Data Processor   │ │ - Controls       │ │ - API        │ │
- State Manager    │ │ - Compliance     │ │ - Events     │ │
- ┘ └─────────────────┘ └─────────────┘ │
- ┬──────────────────────────────┘
- ↓
**┌─ Data Access Layer ──────────────────────────────────────────┐**
- ┌─ Database Connectors ─────────────────────────────────────┐│
- PostgreSQL                                              ││
- SQLite                                                  ││
- DuckDB                                                  ││
- MySQL                                                   ││
- ┘│
- ┘

##### Component Relationships

- User interactions → CLI/UI
- CLI/UI → Dashboard/Control Engines
- Engines → Database Connectors
- WebSocket Server ↔ UI (bi-directional)
- Resource Management → All Components

##### Additional Details

Annotations for:
- Configuration file locations
- Plugin architecture
- Authentication flow
- Resource dependency resolution
- Snapshot management
- Workspace context

##### Implementation Notes

- The modular nature of the system
- The separation between UI and backend components
- The plugin-based database connectivity
- The event-driven architecture for real-time updates
- The configuration-as-code approach

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef data fill:#FF9800,stroke:#EF6C00,color:white
    classDef comm fill:#9C27B0,stroke:#6A1B9A,color:white

    %% User Interface Layer
    subgraph UI[User Interface Layer]
        WebUI[Web Dashboard UI]
        CLI[CLI Interface]
    end

    %% Application Layer
    subgraph APP[Application Layer]
        subgraph DE[Dashboard Engine]
            LayoutMgr[Layout Manager]
            DataProc[Data Processor]
            StateMgr[State Manager]
        end

        subgraph CE[Control Engine]
            Benchmark[Benchmark Processor]
            Controls[Control Executor]
            Compliance[Compliance Checker]
        end

        subgraph SRV[Server Components]
            WS[WebSocket Server]
            API[API Service]
            Events[Dashboard Events]
        end

        subgraph CORE[Core Services]
            ResMgr[Resource Management]
            WorkMgr[Workspace Management]
            QueryExec[Query Execution]
            ConfigMgr[Configuration Management]
            Assets[Dashboard Assets]
            Types[Dashboard Types]
            Display[Control Display]
        end
    end

    %% Data Access Layer
    subgraph DAL[Data Access Layer]
        subgraph DBC[Database Connectors]
            Postgres[PostgreSQL]
            SQLite[SQLite]
            DuckDB[DuckDB]
            MySQL[MySQL]
        end
    end

    %% Relationships
    WebUI --> WS
    CLI --> DE
    CLI --> CE
    DE --> QueryExec
    CE --> QueryExec
    QueryExec --> DBC
    WS <--> Events
    API --> Events
    ResMgr --> DE
    ResMgr --> CE
    WorkMgr --> ResMgr
    ConfigMgr --> ResMgr

    %% Click Events
    click WebUI "https://github.com/turbot/powerpipe/tree/develop/ui/dashboard"
    click CLI "https://github.com/turbot/powerpipe/tree/develop/internal/cmd"
    click DE "https://github.com/turbot/powerpipe/tree/develop/internal/dashboardexecute"
    click CE "https://github.com/turbot/powerpipe/tree/develop/internal/controlexecute"
    click WS "https://github.com/turbot/powerpipe/tree/develop/internal/dashboardserver"
    click API "https://github.com/turbot/powerpipe/tree/develop/internal/service/api"
    click DBC "https://github.com/turbot/powerpipe/tree/develop/internal/db_client"
    click ResMgr "https://github.com/turbot/powerpipe/tree/develop/internal/resources"
    click WorkMgr "https://github.com/turbot/powerpipe/tree/develop/internal/workspace"
    click QueryExec "https://github.com/turbot/powerpipe/tree/develop/internal/queryresult"
    click ConfigMgr "https://github.com/turbot/powerpipe/tree/develop/internal/powerpipeconfig"
    click Events "https://github.com/turbot/powerpipe/tree/develop/internal/dashboardevents"
    click Display "https://github.com/turbot/powerpipe/tree/develop/internal/controldisplay"
    click Types "https://github.com/turbot/powerpipe/tree/develop/internal/dashboardtypes"
    click Assets "https://github.com/turbot/powerpipe/tree/develop/internal/dashboardassets"

    %% Style Applications
    class WebUI,CLI ui
    class LayoutMgr,DataProc,StateMgr,Benchmark,Controls,Compliance,ResMgr,WorkMgr,QueryExec,ConfigMgr,Assets,Types,Display core
    class Postgres,SQLite,DuckDB,MySQL data
    class WS,API,Events comm

    %% Legend
    subgraph Legend
        UI_L[User Interface]:::ui
        CORE_L[Core Components]:::core
        DATA_L[Data Components]:::data
        COMM_L[Communication]:::comm
    end
```
