# logdyhq/logdy-core architecture

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

- Interactive diagram: https://gitdiagram.com/logdyhq/logdy-core
- Repository: https://github.com/logdyhq/logdy-core

## Overview

##### Main Components

a) Core Components:
- Log Input Sources
- STDIN/STDOUT streams
- File system (for file following)
- Socket connections
- Demo mode generator
- Log Processing Engine
- Web Server
- Web UI
- Storage Buffer

b) Supporting Components:
- Configuration Management
- Authentication System
- File Management
- Analytics Collection (optional)

##### Component Relationships

**[Input Sources] -> [Processing Engine] -> [Buffer Storage] -> [Web Server] -> [Web UI]**

##### Detailed Component Breakdown

Input Layer:
- Multiple input modes (identified in /modes directory):
- stdin/stderr handler
- file follower
- socket listener
- demo generator
- forward handler

Processing Layer:
- Ring buffer implementation (from /ring directory)
- Message processing pipeline
- ANSI code handling
- Log parsing system

Storage Layer:
- In-memory message buffer
- File append capability (when configured)

Web Layer:
- HTTP server (from /http directory)
- WebSocket connections
- API endpoints
- Static asset serving

UI Layer:
- Monaco editor integration
- Real-time log viewing
- Filtering and parsing capabilities

##### Technical Details to Highlight

- Go-based implementation
- WebSocket-based real-time communication
- Embedded static assets
- Cross-platform compatibility
- Single binary distribution

##### Implementation Notes

- The modular nature of the input sources
- The pipeline-based processing approach
- The separation between core processing and UI
- The configurable nature of components
- The embedded nature of the UI assets

##### Interactions

Clear data flow paths:
##### File system interactions

This system design should reflect Logdy's nature as a standalone tool that bridges terminal outputs with web-based visualization, emphasizing its simplicity of deployment while showing the sophistication of its internal architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        style Legend fill:#f5f5f5,stroke:#333
        L1[Core Component]:::core
        L2([Input Source]):::input
        L3[(Storage)]:::storage
        L4{{Processing}}:::processing
        L5[/API Endpoint/]:::api
        L6[Web Component]:::web
    end

    subgraph "Input Layer"
        STDIN([STDIN/STDOUT Handler]):::input
        FILE([File Follower]):::input
        SOCKET([Socket Listener]):::input
        DEMO([Demo Generator]):::input
        FORWARD([Forward Handler]):::input
    end

    subgraph "Processing Layer"
        PROC{{Log Processing Engine}}:::processing
        PARSE{{Log Parser}}:::processing
        ANSI{{ANSI Handler}}:::processing
    end

    subgraph "Storage Layer"
        RING[(Ring Buffer)]:::storage
        FSTORAGE[(File Storage)]:::storage
    end

    subgraph "Web Server Layer"
        HTTP[HTTP Server]:::core
        WS[WebSocket Handler]:::core
        AUTH[Authentication]:::core
        API[/API Endpoints/]:::api
    end

    subgraph "UI Layer"
        MONACO[Monaco Editor]:::web
        VIEWER[Log Viewer]:::web
        FILTER[Filter Controls]:::web
        ASSETS[Static Assets]:::web
    end

    subgraph "Supporting Services"
        CONFIG[Configuration Manager]:::core
        UPDATE[Update Checker]:::core
        ANALYTICS[Analytics Collector]:::core
    end

    %% Connections
    STDIN --> PROC
    FILE --> PROC
    SOCKET --> PROC
    DEMO --> PROC
    FORWARD --> PROC

    PROC --> PARSE
    PROC --> ANSI
    PARSE --> RING
    ANSI --> RING

    RING --> HTTP
    RING --> WS
    FSTORAGE --> HTTP

    HTTP --> MONACO
    HTTP --> VIEWER
    WS --> VIEWER
    AUTH --> HTTP
    API --> HTTP

    CONFIG --> HTTP
    UPDATE --> HTTP
    ANALYTICS --> HTTP

    %% Styles
    classDef core fill:#4a90e2,stroke:#333,stroke-width:2px
    classDef input fill:#82c91e,stroke:#333,stroke-width:2px
    classDef processing fill:#ffa94d,stroke:#333,stroke-width:2px
    classDef storage fill:#be4bdb,stroke:#333,stroke-width:2px
    classDef api fill:#ff6b6b,stroke:#333,stroke-width:2px
    classDef web fill:#15aabf,stroke:#333,stroke-width:2px

    %% Click events
    click STDIN "https://github.com/logdyhq/logdy-core/blob/main/modes/stdinerr.go"
    click FILE "https://github.com/logdyhq/logdy-core/blob/main/modes/follow.go"
    click SOCKET "https://github.com/logdyhq/logdy-core/blob/main/modes/socket.go"
    click DEMO "https://github.com/logdyhq/logdy-core/blob/main/modes/demo.go"
    click FORWARD "https://github.com/logdyhq/logdy-core/blob/main/modes/forward.go"
    click RING "https://github.com/logdyhq/logdy-core/blob/main/ring/ring.go"
    click HTTP "https://github.com/logdyhq/logdy-core/blob/main/http/http.go"
    click AUTH "https://github.com/logdyhq/logdy-core/blob/main/http/middleware_api_key.go"
    click ASSETS "https://github.com/logdyhq/logdy-core/tree/main/http/assets"
    click UPDATE "https://github.com/logdyhq/logdy-core/blob/main/utils/update.go"
    click PROC "https://github.com/logdyhq/logdy-core/blob/main/utils/process.go"
```
