# skamranahmed/estimatex architecture

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

- Interactive diagram: https://gitdiagram.com/skamranahmed/estimatex
- Repository: https://github.com/skamranahmed/estimatex

## Overview

##### Main Components

a. Client-Side Components (EstimateX CLI):
- Command Line Interface Layer
- Event Management System
- WebSocket Client Handler
- Prompt Management System

b. External Components:
- EstimateX Server (WebSocket Server)
- User's Terminal

**┌─ User's Terminal ─────────────────────────────────────────┐**

- ┌─ EstimateX CLI Client ──────────────────────────┐     │

- ┌─ Prompt Layer ─┐    ┌─ Event System ─┐      │     │

- User Input   │    │ - Event Types  │      │     │
- CLI Display  │◄─►│ - Event Handler│      │     │
- Interactions │    │ - Event Sender │      │     │
- ┘    └───────┬────────┘      │     │
- ▲                    │               │     │
- ▼               │     │
- ┌─ WebSocket Client Handler ─┐             │     │

- Connection Management   │             │     │
- Message Processing      │             │     │
- ┬───────────────┘             │     │
- ┼─────────────────────────────┘     │
- ┼──────────────────────────────────┘

- ▼
**┌─ EstimateX Server ──┐**
- (External System)  │
- ┘

##### Component Details to Highlight

a. Prompt Layer (prompt/prompt.go):
- Handles user input/output
- Manages CLI interactions
- Displays estimation results

b. Event System (event/*.go):
- event.go: Defines event types and structures
- handler.go: Manages event processing
- send.go: Handles event transmission

c. WebSocket Client Handler:
- Manages WebSocket connection to server
- Handles real-time communication
- Processes incoming/outgoing messages

##### Key Interactions

a. User Flow:
- Terminal input → Prompt Layer → Event System → WebSocket Handler → Server
- Server → WebSocket Handler → Event System → Prompt Layer → Terminal output

b. Real-time Communication:
- Bidirectional WebSocket connection
- Event propagation paths
- Room management flow

##### Technical Details to Note

- Go-based implementation
- WebSocket protocol for real-time communication
- CLI-based user interface
- Event-driven architecture
- Room-based collaboration model

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Terminal["User's Terminal"]
        subgraph CLI["EstimateX CLI Client"]
            subgraph PromptLayer["Prompt Layer"]
                UI["User Input/Output"]:::ui
                CD["CLI Display"]:::ui
                INT["Interactions"]:::ui
            end

            subgraph EventSystem["Event System"]
                ET["Event Types"]:::event
                EH["Event Handler"]:::event
                ES["Event Sender"]:::event
            end

            subgraph WSClient["WebSocket Client Handler"]
                CM["Connection Management"]:::ws
                MP["Message Processing"]:::ws
            end
        end
    end

    subgraph Server["EstimateX Server"]
        WS["WebSocket Server"]:::external
    end

    %% Connections
    UI --> INT
    INT --> EH
    CD --> UI
    ET --> EH
    EH --> ES
    ES --> MP
    MP --> CM
    CM <--> WS

    %% Reverse Flow
    WS --> CM
    CM --> MP
    MP --> ES
    ES --> EH
    EH --> INT
    INT --> CD

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef event fill:#2ecc71,stroke:#27ae60,color:white
    classDef ws fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#f39c12,stroke:#d35400,color:white

    %% Click Events
    click CLI "https://github.com/skamranahmed/estimatex/blob/main/main.go"
    click EventSystem "https://github.com/skamranahmed/estimatex/tree/main/event/"
    click ET "https://github.com/skamranahmed/estimatex/blob/main/event/event.go"
    click EH "https://github.com/skamranahmed/estimatex/blob/main/event/handler.go"
    click ES "https://github.com/skamranahmed/estimatex/blob/main/event/send.go"
    click PromptLayer "https://github.com/skamranahmed/estimatex/blob/main/prompt/prompt.go"

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Event Components"]:::event
        L3["WebSocket Components"]:::ws
        L4["External Systems"]:::external
    end
```
