# jitesh117/brainrot-lsp architecture

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

- Interactive diagram: https://gitdiagram.com/jitesh117/brainrot-lsp
- Repository: https://github.com/jitesh117/brainrot-lsp

## Overview

##### Main Components

a) Core LSP Server Components:
- Transport Layer (stdio, TCP, WebSocket, Node.js IPC)
- JSON-RPC 2.0 Handler
- LSP Protocol Handler

b) Application-Specific Components:
- Completion Handler
- Snippet Manager
- Brainrot Mapper

**┌─────────────────────────────────────────────┐**
- Editor Client               │
- ┘
- ↕️
**┌─────────────────────────────────────────────┐**
- Transport Layer                │
- (stdio/TCP/WebSocket/Node.js IPC)       │
- ┘
- ↕️
**┌─────────────────────────────────────────────┐**
- JSON-RPC 2.0 Handler              │
- ┘
- ↕️
**┌─────────────────────────────────────────────┐**
- LSP Protocol Handler                │
- ┘
- ↕️
**┌─────────────────────────────────────────────┐**
- Completion      │     Snippet            │
- Handler        │     Manager            │
- ┘
- ↕️
**┌─────────────────────────────────────────────┐**
- Brainrot Mapper                  │
- (Template & Completion Logic)           │
- ┘

##### Important Elements to Highlight

a) File-Component Mapping:
- How `completionHandler.go` interfaces with the LSP protocol
- How `brainrotMapper.go` and `snippets.go` work together
- Demonstrate the connection between `main.go` and the transport layer

b) Data Flow:
- Editor request flow
- Completion suggestion flow
- Snippet template resolution

##### Implementation Details to Note

- The project uses the glsp framework, so show its integration points
- Different transport protocol options
- Snippet trigger system

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        EC[Editor Client]:::client
        click EC "https://github.com/Jitesh117/brainrot-lsp/blob/master/brainrot.lua"
    end

    subgraph Transport
        TL[Transport Layer]:::transport
        click TL "https://github.com/Jitesh117/brainrot-lsp/blob/master/main.go"
    end

    subgraph Core
        JR[JSON-RPC 2.0 Handler]:::core
        LSP[LSP Protocol Handler]:::core
    end

    subgraph Handlers
        CH[Completion Handler]:::handler
        SM[Snippet Manager]:::handler
        click CH "https://github.com/Jitesh117/brainrot-lsp/blob/master/handlers/completionHandler.go"
        click SM "https://github.com/Jitesh117/brainrot-lsp/blob/master/mappers/snippets.go"
    end

    subgraph Logic
        BM[Brainrot Mapper]:::logic
        click BM "https://github.com/Jitesh117/brainrot-lsp/blob/master/mappers/brainrotMapper.go"
    end

    EC <--> TL
    TL <--> JR
    JR <--> LSP
    LSP <--> CH
    LSP <--> SM
    CH <--> BM
    SM <--> BM

    classDef client fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef transport fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef core fill:#57a773,stroke:#000,stroke-width:2px,color:#fff
    classDef handler fill:#ff8c42,stroke:#000,stroke-width:2px,color:#fff
    classDef logic fill:#845ec2,stroke:#000,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        L1[Client Interface]:::client
        L2[Transport Layer]:::transport
        L3[Core LSP Components]:::core
        L4[Application Handlers]:::handler
        L5[Business Logic]:::logic
    end
```
