# leen2233/hey-py architecture

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

- Interactive diagram: https://gitdiagram.com/leen2233/hey-py
- Repository: https://github.com/leen2233/hey-py

## Overview

##### Component Relationships

a. Primary Flow:
- CLI → API Client → DuckDuckGo AI Service

b. Supporting Flows:
- CLI ↔ Memory Manager ↔ File System (.cache/hey)
- CLI ↔ Config Handler ↔ File System (.config/hey)

##### Special Elements

a. Configuration Management:
- Config file location (~/.config/hey)
- Environment variable options
- Supported AI models

b. Memory System:
- 10-message limit
- 24-hour expiry mechanism
- Cache storage location (~/.cache/hey)

##### Key Interactions to Highlight
- User command processing flow
- AI model selection and management
- Message storage and retrieval
- Configuration updates
- Proxy handling

##### Technical Details
- Supported AI models (Claude 3 Haiku, GPT-4o Mini, etc.)
- Storage formats (TOML for config, JSON for messages)
- Cache management system
- Proxy support (HTTP/SOCKS)

##### Notes for important features like
- Real-time streaming
- Rich markdown support
- Auto-expiry mechanism
- Proxy configuration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef interface fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef note fill:#ecf0f1,stroke:#bdc3c7,color:black

    %% Interface Layer
    subgraph Interface
        CLI["CLI Interface"]:::interface
        CMD["Command Processing"]:::interface
        IO["Input/Output Handler"]:::interface
    end

    %% Core Layer
    subgraph Core
        API["API Client"]:::core
        MEM["Memory Manager"]:::core
        CONF["Configuration Handler"]:::core
        MOD["Models Definition"]:::core
    end

    %% Storage Layer
    subgraph Storage
        CACHE[("Cache Storage<br/>~/.cache/hey")]:::storage
        CONFIG[("Config Storage<br/>~/.config/hey")]:::storage
    end

    %% External Services
    DDGAI["DuckDuckGo AI Service"]:::external

    %% Relationships
    CLI --> CMD
    CMD --> IO
    CMD --> API
    API --> DDGAI
    MEM --> CACHE
    CONF --> CONFIG
    CMD --> MEM
    CMD --> CONF
    API --> MOD

    %% Notes
    note1["• Real-time streaming<br/>• Rich markdown support"]:::note
    note2["• 10-message limit<br/>• 24-hour expiry"]:::note
    note3["• HTTP/SOCKS proxy support<br/>• Multiple AI models"]:::note

    %% Click Events
    click CLI "https://github.com/leen2233/hey-py/blob/main/hey/cli.py"
    click CMD "https://github.com/leen2233/hey-py/blob/main/hey/__main__.py"
    click API "https://github.com/leen2233/hey-py/blob/main/hey/api.py"
    click MEM "https://github.com/leen2233/hey-py/blob/main/hey/memory.py"
    click CONF "https://github.com/leen2233/hey-py/blob/main/hey/config.py"
    click MOD "https://github.com/leen2233/hey-py/blob/main/hey/models.py"

    %% Legend
    subgraph Legend
        L1["Interface Components"]:::interface
        L2["Core Components"]:::core
        L3["Storage Components"]:::storage
        L4["External Services"]:::external
    end
```
