# jbellis/llmap architecture

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

- Interactive diagram: https://gitdiagram.com/jbellis/llmap
- Repository: https://github.com/jbellis/llmap

## Overview

Key Components to Include:

##### Input Processing Layer
- CLI interface accepting file paths and search queries
- File type detection system (currently Java and Python)
- Tree-sitter parsing component (implied by the .scm files)

##### Analysis Pipeline (Core Architecture)
a. Skeleton Analysis Stage
- Connection to language-specific queries (./queries/{java,python})
- To DeepSeek-V3 API
b. Full Source Analysis Stage
- Connection to DeepSeek-V3 API
c. Refinement Stage
- Connection to DeepSeek-R1 API

##### External Services
- DeepSeek API Services (both V3 and R1)
- Local Cache System (located at ~/.cache/llmap)

##### Data Flow Components
- File input stream
- Concurrent processing manager
- Results aggregator
- Output formatter

- [Input] → [Stage 1] → [Stage 2] → [Stage 3] → [Output]

##### Component Relationships
- Double lines: API boundaries

##### Technical Details
- Concurrent processing capability (default 500 files)
- Cache read/write paths
- Language-specific components

##### The configuration flexibility

Keep the abstraction level focused on the architectural components while showing enough detail to understand the unique features of LLMap, particularly its efficient use of LLM APIs and caching strategy.

Remember to indicate the extensibility points where new language support can be added, as mentioned in the README's limitations section.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Process]:::process
        L2[(Database)]:::db
        L3[/API/]:::api
        L4[CLI Tool]:::cli
        L5[File Component]:::file
        
        style Legend fill:#f0f0f0,stroke:#333
    end

    CLI[CLI Interface]:::cli
    click CLI "https://github.com/jbellis/llmap/blob/master/src/llmap/llmap.py"
    
    subgraph "Input Processing"
        FD[File Type Detection]:::process
        click FD "https://github.com/jbellis/llmap/blob/master/src/llmap/parse.py"
        TP[Tree-sitter Parser]:::process
        click TP "https://github.com/jbellis/llmap/blob/master/src/llmap/parse.py"
    end

    subgraph "Language Support"
        JQ["Java Queries"]:::file
        click JQ "https://github.com/jbellis/llmap/blob/master/src/llmap/queries/java/skeleton.scm"
        PQ["Python Queries"]:::file
        click PQ "https://github.com/jbellis/llmap/blob/master/src/llmap/queries/python/skeleton.scm"
    end

    subgraph "Analysis Pipeline"
        SA["Skeleton Analysis"]:::process
        FA["Full Source Analysis"]:::process
        RA["Refinement Analysis"]:::process
    end

    subgraph "External Services"
        DV3[/"DeepSeek-V3 API"/]:::api
        click DV3 "https://github.com/jbellis/llmap/blob/master/src/llmap/ai.py"
        DR1[/"DeepSeek-R1 API"/]:::api
        click DR1 "https://github.com/jbellis/llmap/blob/master/src/llmap/ai.py"
        TK["Tokenizer"]:::file
        click TK "https://github.com/jbellis/llmap/blob/master/src/llmap/deepseek_v3_tokenizer/tokenizer.json"
    end

    subgraph "Cache System"
        LC[(Local Cache)]:::db
        click LC "https://github.com/jbellis/llmap/blob/master/src/llmap/cache.py"
    end

    subgraph "Error Handling"
        EH[Error Handler]:::process
        click EH "https://github.com/jbellis/llmap/blob/master/src/llmap/exceptions.py"
    end

    subgraph "Configuration"
        CF[Config]:::file
        click CF "https://github.com/jbellis/llmap/blob/master/pyproject.toml"
    end

    CLI --> FD
    FD --> TP
    TP --> |Language Detection| JQ
    TP --> |Language Detection| PQ
    JQ & PQ --> SA
    SA --> FA
    FA --> RA
    SA & FA --> |API Calls| DV3
    RA --> |API Calls| DR1
    DV3 & DR1 --> TK
    SA & FA & RA -.-> |Cache Check| LC
    LC -.-> SA & FA & RA
    EH --> CLI

    classDef process fill:#90EE90,stroke:#333
    classDef db fill:#DDA0DD,stroke:#333
    classDef api fill:#FFD700,stroke:#333
    classDef cli fill:#87CEEB,stroke:#333
    classDef file fill:#D3D3D3,stroke:#333
```
