# hcavarsan/kftray architecture

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

- Interactive diagram: https://gitdiagram.com/hcavarsan/kftray
- Repository: https://github.com/hcavarsan/kftray

## Overview

##### Main Components Identification

a. Core Applications:
- kftray (Desktop Application)
- kftui (Terminal UI Application)
- kftray-server (Proxy Relay Server)

b. Shared Components:
- kftray-commons (Shared utilities and models)
- kftray-portforward (Port forwarding functionality)

**┌─────────────────────────────────────────────────────────┐**
- Client Layer                        │
- ┐            ┌────────────────────────┤
- kftray GUI     │            │      kftui CLI         │
- (Tauri + React)  │            │   (Terminal Interface) │
- ┬───────┘            └──────────┬─────────────┘

- ┬───────────────┘
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Common Layer                         │
- ┤
- kftray-commons       │    kftray-portforward      │
- (Shared Functionality)  │  (Port Forward Logic)      │
- ┘

- ▼
**┌─────────────────────────────────────────────────────────┐**
- Server Layer                         │
- ┤
- kftray-server                         │
- (Proxy Relay Server)                       │
- ┘

- ▼
**┌─────────────────────────────────────────────────────────┐**
- Kubernetes Cluster                      │
- ┘

##### Component Details

For each component, include:

a. kftray GUI:
- Frontend (React + TypeScript)
- Tauri backend integration
- GitHub sync functionality
- HTTP logs tracing
- Configuration management

b. kftui:
- Terminal UI components
- Configuration management
- Port forward management

c. Common Layer:
- Configuration models
- Database utilities
- GitHub integration
- Logging functionality
- Migration utilities

d. kftray-server:
- TCP/UDP proxy functionality
- Connection management
- Error handling
- Server configuration

##### Data Flow Indicators

- Configuration synchronization
- Port forwarding connections
- HTTP log collection
- GitHub synchronization
- Kubernetes API communication

##### Additional Elements

Annotations for:
- Supported protocols (TCP/UDP)
- Configuration storage locations
- Authentication flows
- Error handling paths
- Auto-reconnection logic

##### Notes

Technical notes about:
- Cross-platform compatibility
- Kubernetes API integration
- GitHub integration requirements
- Configuration file formats
- Security considerations

Remember to highlight the key features:
- Resilient port forwarding
- Multi-protocol support
- Independent kubectl operation
- GitHub sync capabilities
- HTTP logs tracing
- Auto-import functionality

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        KFTray["kftray Desktop\n(Tauri + React)"]
        KFTrayFE["Frontend Components"]
        KFTrayBE["Backend Commands"]
        KFTUI["kftui Terminal\nInterface"]
        TUIComponents["Terminal UI\nComponents"]
        TUICore["Core Logic"]
        
        KFTray --> KFTrayFE
        KFTray --> KFTrayBE
        KFTUI --> TUIComponents
        KFTUI --> TUICore
    end

    subgraph Common
        Commons["Commons Package"]
        PortForward["Port Forward Logic"]
        ConfigModels["Configuration Models"]
        SharedUtils["Shared Utilities"]
        
        Commons --> ConfigModels
        Commons --> SharedUtils
        PortForward --> Commons
    end

    subgraph Server
        KFServer["kftray-server\nProxy Relay"]
        ProxyLogic["Proxy Logic"]
        TCPHandler["TCP Handler"]
        UDPHandler["UDP Handler"]
        
        KFServer --> ProxyLogic
        ProxyLogic --> TCPHandler
        ProxyLogic --> UDPHandler
    end

    subgraph Features
        GitHub["GitHub Integration"]
        Config["Configuration Management"]
        HTTPLogs["HTTP Logs"]
        PortForwardCore["Port Forward Core"]
    end

    subgraph Frontend
        PortForwardUI["Port Forward UI"]
        ConfigUI["Configuration UI"]
        GitHubSyncUI["GitHub Sync UI"]
        AutoImportUI["Auto Import UI"]
    end

    KFTray --> Commons
    KFTUI --> Commons
    Commons --> KFServer
    KFServer --> K8s[("Kubernetes\nCluster")]

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef client fill:#d4e6f1,stroke:#2874a6
    classDef common fill:#d5f5e3,stroke:#196f3d
    classDef server fill:#fadbd8,stroke:#943126
    classDef feature fill:#fef9e7,stroke:#b7950b
    classDef frontend fill:#e8daef,stroke:#6c3483

    class KFTray,KFTrayFE,KFTrayBE,KFTUI,TUIComponents,TUICore client
    class Commons,PortForward,ConfigModels,SharedUtils common
    class KFServer,ProxyLogic,TCPHandler,UDPHandler server
    class GitHub,Config,HTTPLogs,PortForwardCore feature
    class PortForwardUI,ConfigUI,GitHubSyncUI,AutoImportUI frontend

    click KFTray "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-tauri/"
    click KFTrayFE "https://github.com/hcavarsan/kftray/tree/main/frontend/src/"
    click KFTrayBE "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-tauri/src/commands/"
    click KFTUI "https://github.com/hcavarsan/kftray/tree/main/crates/kftui/"
    click TUIComponents "https://github.com/hcavarsan/kftray/tree/main/crates/kftui/src/tui/"
    click TUICore "https://github.com/hcavarsan/kftray/tree/main/crates/kftui/src/core/"
    click Commons "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-commons/"
    click ConfigModels "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-commons/src/models/"
    click SharedUtils "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-commons/src/utils/"
    click PortForward "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-portforward/"
    click KFServer "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-server/"
    click ProxyLogic "https://github.com/hcavarsan/kftray/tree/main/crates/kftray-server/src/proxy/"
    click TCPHandler "https://github.com/hcavarsan/kftray/blob/main/crates/kftray-server/src/proxy/tcp.rs"
    click UDPHandler "https://github.com/hcavarsan/kftray/blob/main/crates/kftray-server/src/proxy/udp.rs"
    click GitHub "https://github.com/hcavarsan/kftray/blob/main/crates/kftray-commons/src/utils/github.rs"
    click Config "https://github.com/hcavarsan/kftray/blob/main/crates/kftray-commons/src/utils/config.rs"
    click HTTPLogs "https://github.com/hcavarsan/kftray/blob/main/crates/kftray-tauri/src/commands/httplogs.rs"
    click PortForwardCore "https://github.com/hcavarsan/kftray/blob/main/crates/kftray-portforward/src/port_forward.rs"
    click PortForwardUI "https://github.com/hcavarsan/kftray/tree/main/frontend/src/components/PortForwardTable/"
    click ConfigUI "https://github.com/hcavarsan/kftray/tree/main/frontend/src/components/AddConfigModal/"
    click GitHubSyncUI "https://github.com/hcavarsan/kftray/tree/main/frontend/src/components/GitSyncModal/"
    click AutoImportUI "https://github.com/hcavarsan/kftray/tree/main/frontend/src/components/AutoImportModal/"
```
