# alesbrelih/gitlab-ci-ls architecture

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

- Interactive diagram: https://gitdiagram.com/alesbrelih/gitlab-ci-ls
- Repository: https://github.com/alesbrelih/gitlab-ci-ls

## Overview

##### Main Components

a) Core Language Server (Rust-based):
- Parser Module
- Handler Module
- Git Integration
- TreeSitter Integration
- File System Utils
- Message Handling

b) VSCode Extension:
- Client Implementation
- Extension Host

c) External Integrations:
- Editor Clients (VSCode, Neovim, Emacs)
- GitLab Remote Repositories
- Local Git Configuration

**[Editor Clients Layer]**
- ↕
**[Language Server Core Layer]**
- ↕
**[External Services Layer]**

##### Component Relationships

a) Core Components:
- Handlers to process LSP requests/responses
- Link Git integration for remote file handling
- File System Utils for local cache management

b) Client Integration:
- Bidirectional communication between editor clients and the language server
- LSP protocol as the communication medium

##### Key Flows to Highlight

a) Feature Flows:
- Go to Definition path
- Find References path
- Autocompletion request/response
- Hover information retrieval
- Diagnostics pipeline
- Rename operation flow

b) File Handling:
- Remote file caching mechanism
- Local file processing
- Git repository interaction

##### Specific Implementation Details

Technical elements:
- TreeSitter query system
- GitLab CI YAML parsing
- LSP message handling
- Cache management
- Configuration options

**[Editor Integration]**
- VSCode Extension
- Neovim Integration
- Emacs Integration
- ↓
**[Core Language Server]**
- Parser System
- TreeSitter Integration
- YAML Processing
- Handler System
- LSP Protocol
- Feature Handlers
- File Management
- Git Integration
- Cache System
- ↓
**[External Services]**
- GitLab Repositories
- Local Git Config

##### Important Notes

- Clear separation between the language server core and editor integrations
- Caching mechanism for remote files
- Configuration points (cache location, log path, options)
- LSP protocol boundaries
- Initialization flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef editor fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef git fill:#FFA500,stroke:#333,stroke-width:2px
    classDef cache fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef utils fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Editor Layer
    subgraph EditorLayer["Editor Integration Layer"]
        VSCode["VSCode Extension"]
        Neovim["Neovim Integration"]
        Emacs["Emacs Integration"]
        VSCodeClient["VSCode Client"]
        VSCodeHost["VSCode Extension Host"]
    end

    %% Core Layer
    subgraph CoreLayer["Language Server Core"]
        CoreServer["Core Language Server"]
        Parser["Parser Module"]
        Handler["Handler Module"]
        TreeSitter["TreeSitter Integration"]
        TSQueries["TreeSitter Queries"]
        FSUtils["File System Utils"]
        MsgHandler["Message Handling"]
        ParserUtils["Parser Utilities"]
        PredefinedVars["GitLab Predefined Variables"]
    end

    %% External Layer
    subgraph ExternalLayer["External Services Layer"]
        GitInt["Git Integration"]
        GitLab["GitLab Repositories"]
        LocalGit["Local Git Config"]
    end

    %% Relationships
    VSCode --> VSCodeClient
    VSCodeClient --> VSCodeHost
    VSCodeHost --> CoreServer
    Neovim --> CoreServer
    Emacs --> CoreServer

    CoreServer --> Parser
    CoreServer --> Handler
    CoreServer --> MsgHandler
    Parser --> TreeSitter
    TreeSitter --> TSQueries
    Parser --> ParserUtils
    Parser --> PredefinedVars
    Handler --> FSUtils
    Handler --> GitInt
    GitInt --> GitLab
    GitInt --> LocalGit
    FSUtils --> LocalGit

    %% Click Events
    click CoreServer "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/mod.rs"
    click Parser "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/parser.rs"
    click Handler "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/handlers.rs"
    click GitInt "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/git.rs"
    click TreeSitter "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/treesitter.rs"
    click TSQueries "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/treesitter_queries.rs"
    click FSUtils "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/fs_utils.rs"
    click MsgHandler "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/messages.rs"
    click VSCodeClient "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/vscode-extension/client/src/extension.ts"
    click VSCodeHost "https://github.com/alesbrelih/gitlab-ci-ls/tree/main/vscode-extension/"
    click ParserUtils "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/gitlab_ci_ls_parser/parser_utils.rs"
    click PredefinedVars "https://github.com/alesbrelih/gitlab-ci-ls/blob/main/src/resources/gitlab_predefined_vars.yaml"

    %% Style Applications
    class VSCode,Neovim,Emacs,VSCodeClient,VSCodeHost editor
    class CoreServer,Parser,Handler,TreeSitter,TSQueries,MsgHandler,ParserUtils,PredefinedVars core
    class GitInt,GitLab,LocalGit git
    class FSUtils cache
```
