# lljbash/clangd-tidy architecture

> Architecture diagram of the GitHub repository lljbash/clangd-tidy, 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/lljbash/clangd-tidy
- Repository: https://github.com/lljbash/clangd-tidy

## Overview

##### Main Components

a) Core Components:
- Input Handler (handles file paths and compilation database)
- Clangd Interface (manages communication with clangd process)
- Diagnostic Processor (formats and processes diagnostics)
- Output Formatter (handles different output formats)

b) External Dependencies:
- clangd (external process)
- compilation database
- source files

##### Specific Implementation Details

- main_cli.py (entry point and CLI handling)
- diagnostic_formatter.py (formatting logic)
- pylspclient/ (LSP communication)
- json_rpc_endpoint.py
- lsp_client.py
- lsp_endpoint.py
- lsp_structs.py

**[Input Files & Compilation DB] →**
- [Input Handler] →
- [Clangd Interface] ↔ [clangd process]
- ↓
- [Diagnostic Processor]
- ↓
- [Output Formatter] →
- [Diagnostic Output]

##### Additional Elements

A notes section showing:
- Supported file extensions
- Configuration options
- Output format options (GitHub Actions, compact, etc.)

##### Technical Details to Highlight

- LSP (Language Server Protocol) communication
- Async worker support
- File extension filtering
- Severity level handling
- Output formatting options

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef core fill:#b3d1ff,stroke:#4d88ff
    classDef external fill:#90EE90,stroke:#006400
    classDef io fill:#FFE5B4,stroke:#FFA500
    classDef dep fill:#D3D3D3,stroke:#808080

    %% Legend
    subgraph Legend
        L1[Internal Component]:::core
        L2[External Process]:::external
        L3[Input/Output]:::io
        L4[External Dependency]:::dep
        L1 --- L2
        L2 --- L3
        L3 --- L4
    end

    %% Main Flow
    InputFiles[/"Source Files & Compilation DB"/]:::io
    
    subgraph Core["Core Application Components"]
        EntryPoint["Application Entry Point"]:::core
        InputHandler["Input Handler"]:::core
        ClangdInterface["Clangd Interface"]:::core
        DiagProcessor["Diagnostic Processor"]:::core
        OutputFormatter["Output Formatter"]:::core
        
        subgraph LSPLayer["LSP Communication Layer"]
            LSPClient["LSP Client"]:::core
            JSONRPCEndpoint["JSON RPC Communication"]:::core
            LSPEndpoint["LSP Protocol Handler"]:::core
            LSPStructs["LSP Data Structures"]:::core
        end
    end
    
    ClangdProcess[("clangd Process")]:::external
    
    OutputFiles[/"Diagnostic Output"/]:::io
    
    %% Relationships
    InputFiles --> EntryPoint
    EntryPoint --> InputHandler
    InputHandler --> ClangdInterface
    
    ClangdInterface <--> LSPLayer
    LSPLayer <--> ClangdProcess
    
    ClangdInterface --> DiagProcessor
    DiagProcessor --> OutputFormatter
    OutputFormatter --> OutputFiles
    
    %% Click events
    click EntryPoint "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/__main__.py"
    click InputHandler "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/main_cli.py"
    click ClangdInterface "https://github.com/lljbash/clangd-tidy/tree/master/clangd_tidy/pylspclient/"
    click LSPClient "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/pylspclient/lsp_client.py"
    click JSONRPCEndpoint "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/pylspclient/json_rpc_endpoint.py"
    click LSPEndpoint "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/pylspclient/lsp_endpoint.py"
    click LSPStructs "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/pylspclient/lsp_structs.py"
    click DiagProcessor "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/diagnostic_formatter.py"
    click OutputFormatter "https://github.com/lljbash/clangd-tidy/blob/master/clangd_tidy/diagnostic_formatter.py"

    %% Notes
    subgraph Notes["Configuration & Features"]
        direction TB
        N1["Supported Extensions"]
        N2["Configuration Options"]
        N3["Output Formats"]
        N4["Severity Levels"]
    end
```
