# shadielfares/hldr architecture

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

- Interactive diagram: https://gitdiagram.com/shadielfares/hldr
- Repository: https://github.com/shadielfares/hldr

## Overview

##### Project Type Identification
This is an AI-powered educational tool/mentor system that analyzes code and provides feedback to help developers improve their programming skills. The project has evolved from a WebSocket-based architecture to a more streamlined, file-based approach.

##### Main Components

A. Core Components (Primary Layer):
- CLI Interface (cli/cli.py)
- Client Handler (client/client.py)
- Main Application Logic (app/main.py)
- Analysis Engine (utils/analysis.py)
- Code Linting System (utils/linting.py)

B. External Services Layer:
- OpenAI API Integration (for code analysis and feedback)
- Editor Integrations (Vim/VS Code)

**[User/IDE Layer]**

- ▼
**[CLI Interface] ←→ [Client Handler]**

- ▼
**[Main Application Logic]**

- → [Analysis Engine]

- ▼
- [OpenAI API]

- → [Linting System]

##### Key Relationships to Highlight

a. Input Flow:
- How code input flows from editors through the CLI
- Demonstrate the client handler's role in managing requests

b. Processing Flow:
- How the analysis engine processes code
- Interaction with OpenAI API for generating feedback
- Linting system's integration

c. Output Flow:
- How feedback returns to the user through the CLI/editor

##### Additional Elements

A notes section explaining:
- The asynchronous nature of the feedback system
- The intentional delay in feedback (on file save rather than real-time)
- The OpenAI API usage optimization strategy

##### Technical Details

- Python-based implementation
- FastAPI integration (if still relevant)
- Editor plugin architecture
- File monitoring system

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef analysis fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef editor fill:#e74c3c,stroke:#c0392b,color:white

    %% User/IDE Layer
    subgraph IDE
        VIM["Vim Editor"]:::editor
        VSC["VS Code"]:::editor
    end

    %% Core Components
    CLI["CLI Interface"]:::ui
    CH["Client Handler"]:::core
    MAL["Main Application Logic"]:::core
    AE["Analysis Engine"]:::analysis
    LS["Code Linting System"]:::analysis
    OAPI["OpenAI API"]:::external

    %% Relationships
    VIM --> CLI
    VSC --> CLI
    CLI <--> CH
    CH --> MAL
    MAL --> AE
    MAL --> LS
    AE --> OAPI
    
    %% Return Flow
    OAPI --> AE
    AE --> MAL
    LS --> MAL
    MAL --> CH
    CH --> CLI
    CLI --> VIM
    CLI --> VSC

    %% Click Events
    click CLI "https://github.com/shadielfares/hldr/blob/main/cli/cli.py"
    click CH "https://github.com/shadielfares/hldr/blob/main/client/client.py"
    click MAL "https://github.com/shadielfares/hldr/blob/main/app/main.py"
    click AE "https://github.com/shadielfares/hldr/blob/main/utils/analysis.py"
    click LS "https://github.com/shadielfares/hldr/blob/main/utils/linting.py"

    %% Legend
    subgraph Legend
        UI["User Interface"]:::ui
        CORE["Core Components"]:::core
        AN["Analysis Components"]:::analysis
        EX["External Services"]:::external
        ED["Editors"]:::editor
    end
```
