# quick-lint/quick-lint-js architecture

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

- Interactive diagram: https://gitdiagram.com/quick-lint/quick-lint-js
- Repository: https://github.com/quick-lint/quick-lint-js

## Overview

##### Main Components
The system architecture should be divided into these core components:

a) Core Engine Components:
- Lexer (src/quick-lint-js/fe/lex.*)
- Parser (src/quick-lint-js/fe/parse.*)
- Variable Analyzer (src/quick-lint-js/fe/variable-analyzer.*)
- Diagnostic System (src/quick-lint-js/diag/*)

b) Interface Components:
- CLI Interface (src/quick-lint-js/cli/*)
- LSP Server (src/quick-lint-js/lsp/*)
- Editor Plugins
- VSCode
- Vim/Neovim
- Emacs
- Sublime Text
- Kate

c) Supporting Systems:
- Configuration System (src/quick-lint-js/configuration/*)
- I/O Management (src/quick-lint-js/io/*)
- Internationalization (src/quick-lint-js/i18n/*)
- Logging/Tracing (src/quick-lint-js/logging/*)

**┌─────────────────── Editor Integrations ───────────────────┐**
- VSCode  │  Vim  │  Emacs  │  Sublime  │  Kate  │  CLI   │
- Interface Layer ──────────────────────┤
- LSP Server         │      Direct API Access      │
- Core Engine Layer ────────────────────┤

- Lexer → Parser → Variable Analyzer → Diagnostics     │

- Support Systems ─────────────────────┤
- Config │ I/O Manager │ i18n │ Logging │ Error Reporting │
- ┘

##### Component Interactions

a) Input Flow:
- JavaScript source code enters through editor plugins or CLI
- Code flows through LSP server or direct API
- Lexer processes input into tokens
- Parser creates AST
- Variable analyzer checks for semantic errors
- Diagnostics system generates error reports

b) Configuration Flow:
- Configuration system reads settings
- Settings influence all components' behavior
- I/O manager handles file operations

##### Additional Details

Annotations for:
- File formats supported
- Communication protocols
- Performance-critical paths
- Error handling flows
- Configuration options

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef editor fill:#b3d9ff,stroke:#333
    classDef interface fill:#ffffcc,stroke:#333
    classDef core fill:#98fb98,stroke:#333
    classDef support fill:#ffd700,stroke:#333
    classDef flow fill:none,stroke:#333

    %% Editor Integrations Layer
    subgraph Editors
        VSCode["VSCode Plugin"]:::editor
        Vim["Vim/Neovim Plugin"]:::editor
        Emacs["Emacs Plugin"]:::editor
        Sublime["Sublime Plugin"]:::editor
        Kate["Kate Plugin"]:::editor
        CLI["CLI Interface"]:::editor
    end

    %% Interface Layer
    subgraph Interface
        LSP["LSP Server"]:::interface
        API["Direct API Access"]:::interface
    end

    %% Core Engine Layer
    subgraph CoreEngine
        Lexer["Lexer"]:::core
        Parser["Parser"]:::core
        VarAnalyzer["Variable Analyzer"]:::core
        Diagnostics["Diagnostics System"]:::core
    end

    %% Support Systems Layer
    subgraph Support
        Config["Configuration System"]:::support
        IO["I/O Manager"]:::support
        i18n["Internationalization"]:::support
        Logging["Logging/Tracing"]:::support
        ErrorReport["Error Reporting"]:::support
    end

    %% Connections
    VSCode --> LSP
    Vim --> LSP
    Emacs --> LSP
    Sublime --> LSP
    Kate --> LSP
    CLI --> API

    LSP --> Lexer
    API --> Lexer
    Lexer --> Parser
    Parser --> VarAnalyzer
    VarAnalyzer --> Diagnostics
    Diagnostics --> ErrorReport

    Config --> LSP
    Config --> API
    IO --> Lexer
    i18n --> ErrorReport
    Logging --> |"Monitors"| CoreEngine

    %% Click Events
    click VSCode "https://github.com/quick-lint/quick-lint-js/tree/master/plugin/vscode/"
    click Vim "https://github.com/quick-lint/quick-lint-js/tree/master/plugin/vim/"
    click Emacs "https://github.com/quick-lint/quick-lint-js/tree/master/plugin/emacs/"
    click Sublime "https://github.com/quick-lint/quick-lint-js/tree/master/plugin/vscode-lsp/"
    click Kate "https://github.com/quick-lint/quick-lint-js/tree/master/plugin/vscode-lsp/"
    click CLI "https://github.com/quick-lint/quick-lint-js/tree/master/src/quick-lint-js/cli/"
    click LSP "https://github.com/quick-lint/quick-lint-js/tree/master/src/quick-lint-js/lsp/"
    click Lexer "https://github.com/quick-lint/quick-lint-js/blob/master/src/quick-lint-js/fe/lex.cpp"
    click Parser "https://github.com/quick-lint/quick-lint-js/blob/master/src/quick-lint-js/fe/parse.cpp"
    click VarAnalyzer "https://github.com/quick-lint/quick-lint-js/blob/master/src/quick-lint-js/fe/variable-analyzer.cpp"
    click Diagnostics "https://github.com/quick-lint/quick-lint-js/tree/master/src/quick-lint-js/diag/"
    click Config "https://github.com/quick-lint/quick-lint-js/tree/master/src/quick-lint-js/configuration/"
    click IO "https://github.com/quick-lint/quick-lint-js/tree/master/src/quick-lint-js/io/"
    click i18n "https://github.com/quick-lint/quick-lint-js/tree/master/src/quick-lint-js/i18n/"
    click Logging "https://github.com/quick-lint/quick-lint-js/tree/master/src/quick-lint-js/logging/"

    %% Legend
    subgraph Legend
        L1["Editor Plugin"]:::editor
        L2["Interface Component"]:::interface
        L3["Core Component"]:::core
        L4["Support System"]:::support
    end
```
