# vitessio/vt architecture

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

- Interactive diagram: https://gitdiagram.com/vitessio/vt
- Repository: https://github.com/vitessio/vt

## Overview

a. Primary Flows:
- Test Files → Test Executor → Results Comparison → Output
- Query Logs → Log Parser → Analysis Modules → JSON/Markdown Output
- VSchema + Query Analysis → Plan Analyzer → Classification Output

b. Secondary Flows:
- Database Backup → Test Environment Initialization
- Schema Information → Analysis Enhancement

a. External Systems:
- MySQL Database
- Vitess (VTGate)
- File System (for logs and backups)

##### Component Relationships

Create distinct zones showing:
- Input Processing Zone
- Analysis Zone
- Output Generation Zone
- Test Execution Zone

##### Additional Elements

a. Environment Containers:
- Test Environment
- Analysis Environment
- Reporting Environment

b. Configuration Components:
- VSchema Configuration
- Test Directives
- Database Settings

Key Design Considerations:

##### Modularity
- Clear separation between different utility functions
- Reusable components across commands

##### Data Flow
- Transformation of data from input to output
- How different components interact

##### Integration
- External system dependencies
- Configuration points and their impact

##### Extensibility
- Points where new functionality can be added
- Plugin or extension mechanisms

Use a hierarchical layout with:
- Commands at the top
- Processing modules in the middle
- Storage and external systems at the bottom

- Blue: Core processing modules
- Green: Input/Output components
- Orange: Command interfaces
- Gray: External systems
- Purple: Configuration elements

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Commands
        VT[("vt Command")]:::command
        TC["Test Command"]:::command
        KC["Keys Command"]:::command
        TRC["Transactions Command"]:::command
        PC["Plan Analysis Command"]:::command
        SC["Summarize Command"]:::command
        DBC["DBInfo Command"]:::command

        VT --> TC
        VT --> KC
        VT --> TRC
        VT --> PC
        VT --> SC
        VT --> DBC
    end

    subgraph "Processing Modules"
        DP["Data Processing"]:::core
        KA["Keys Analysis"]:::core
        TA["Transaction Analysis"]:::core
        TE["Test Execution"]:::core
        PA["Plan Analysis"]:::core
        SU["Summarization"]:::core
    end

    subgraph "Input Processing"
        QLP["Query Log Parser"]:::input
        VTLP["VTGate Log Parser"]:::input
        CSVP["CSV Log Parser"]:::input
        VSL["VSchema Loader"]:::input
    end

    subgraph "Output Generation"
        MG["Markdown Generation"]:::output
        SG["Summary Generation"]:::output
        TR["Test Reports"]:::output
    end

    subgraph "Test Environment"
        TES["Test Environment Setup"]:::test
        TEX["Test Execution"]:::test
        TSM["Test State Management"]:::test
    end

    subgraph "External Systems"
        MySQL[(MySQL DB)]:::external
        VTGate[(VTGate)]:::external
        FS[(File System)]:::external
    end

    subgraph "Web Interface"
        WS["Web Server"]:::web
        WT["Web Templates"]:::web
    end

    %% Data Flow Connections
    TC --> TE
    KC --> KA
    TRC --> TA
    PC --> PA
    SC --> SU
    DBC --> DP

    DP --> |Processes| QLP
    DP --> |Processes| VTLP
    DP --> |Processes| CSVP
    KA --> |Uses| VSL

    TE --> TR
    SU --> MG
    SU --> SG

    TES --> TEX
    TEX --> TSM

    %% External System Connections
    MySQL -.-> TE
    VTGate -.-> DP
    FS -.-> QLP

    WS --> WT

    %% Click Events
    click TC "https://github.com/vitessio/vt/blob/main/go/cmd/tester.go"
    click KC "https://github.com/vitessio/vt/blob/main/go/cmd/keys.go"
    click TRC "https://github.com/vitessio/vt/blob/main/go/cmd/transactions.go"
    click PC "https://github.com/vitessio/vt/blob/main/go/cmd/planalyze.go"
    click SC "https://github.com/vitessio/vt/blob/main/go/cmd/summarize.go"
    click DBC "https://github.com/vitessio/vt/blob/main/go/cmd/dbinfo.go"
    click DP "https://github.com/vitessio/vt/tree/main/go/data/"
    click KA "https://github.com/vitessio/vt/tree/main/go/keys/"
    click TA "https://github.com/vitessio/vt/tree/main/go/transactions/"
    click TE "https://github.com/vitessio/vt/tree/main/go/tester/"
    click PA "https://github.com/vitessio/vt/tree/main/go/planalyze/"
    click SU "https://github.com/vitessio/vt/tree/main/go/summarize/"
    click QLP "https://github.com/vitessio/vt/blob/main/go/data/query_log_parse.go"
    click VTLP "https://github.com/vitessio/vt/blob/main/go/data/vtgate_log_parse.go"
    click CSVP "https://github.com/vitessio/vt/blob/main/go/data/csv_log_parse.go"
    click VSL "https://github.com/vitessio/vt/blob/main/go/data/vschema_loader.go"
    click MG "https://github.com/vitessio/vt/blob/main/go/markdown/markdown.go"
    click SG "https://github.com/vitessio/vt/blob/main/go/summarize/summary.go"
    click TR "https://github.com/vitessio/vt/blob/main/go/tester/reporter.go"
    click TES "https://github.com/vitessio/vt/blob/main/go/tester/environment.go"
    click TEX "https://github.com/vitessio/vt/blob/main/go/tester/execute.go"
    click TSM "https://github.com/vitessio/vt/blob/main/go/tester/state/state.go"
    click WS "https://github.com/vitessio/vt/blob/main/go/web/web.go"
    click WT "https://github.com/vitessio/vt/tree/main/go/web/templates/"

    %% Styling
    classDef command fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef core fill:#3498db,stroke:#333,stroke-width:2px;
    classDef input fill:#2ecc71,stroke:#333,stroke-width:2px;
    classDef output fill:#e74c3c,stroke:#333,stroke-width:2px;
    classDef test fill:#9b59b6,stroke:#333,stroke-width:2px;
    classDef external fill:#95a5a6,stroke:#333,stroke-width:2px;
    classDef web fill:#34495e,stroke:#333,stroke-width:2px;
```
