# chriskalix/hades architecture

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

- Interactive diagram: https://gitdiagram.com/chriskalix/hades
- Repository: https://github.com/chriskalix/hades

## Overview

##### Project type and purpose
- Hades is a distributed Host‐based Intrusion Detection System (HIDS) that consists of:
- An Agent component (runs on each monitored host, uses eBPF and netlink to collect system events).
- A Plugin subsystem (drivers, collectors, network control, egress guard) for modular data acquisition and enforcement.
- A Server component that receives events (via gRPC/transfer), persists them (MongoDB, Redis), analyzes the data, and exposes a Web Console/UI.

##### File structure
- Top‐level dirs:
- SDK (Go & Rust libraries for clock, config, logger, transport, hashing, downloading).
- agent (Go agent code, plugins manager, metrics, transport, proto definitions, deploy scripts).
- plugins (collector in Go, edriver in Go, eguard in Rust, ncp in Go, libs).
- server (Webconsole API & static assets, gRPC handlers, transfer service, pkg for Mongo/Redis, config).
- Key patterns:
- “agent → transport → transfer → gRPC server → storage → webconsole.”
- Plugin‐based architecture (each plugin under plugins/ is an independent module).
- SDK abstracts cross‐cutting concerns (logging, transport, config).

##### README for additional insights
- Agent data‐flow: kernel probes → BPF programs → user‐space plugin hooks → transport client.
- Data Analysis: transfer pool → gRPC server → handlers → data persistence → UI/analytics.

##### Elements
- Clear labels for each component (e.g., “Agent Core,” “Collector Plugin,” “gRPC Transfer Service”)
Host → Transport → Transfer Server → gRPC → Storage → API → UI
- Important config & cert files near gRPC Transfer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level User
    Browser["User Browser / Dashboard"]:::static

    %% Agent Host
    subgraph "Agent Host" 
        direction TB
        subgraph "SDK Libraries" 
            direction TB
            SDKGoClock["Go Clock Lib"]:::agent
            SDKGoConfig["Go Config Lib"]:::agent
            SDKGoLogger["Go Logger Lib"]:::agent
            SDKGoTransClient["Go Transport Client"]:::transport
            SDKGoTransPool["Go Transport Pool"]:::transport
            SDKGoProtocol["Go Transfer Protocol"]:::transport
            SDKGoTransServer["Go Transport Server"]:::transport
            SDKGoUtils["Go Utilities"]:::agent
            SDKRust["Rust SDK Lib"]:::agent
        end
        subgraph "Agent Core" 
            direction TB
            AgentCore["Agent Core"]:::agent
            AgentTransport["Agent Transport"]:::transport
            AgentUtils["Agent Utils"]:::agent
            AgentPluginMgr["Plugin Manager"]:::agent
        end
        subgraph "Agent Plugins Framework"
            direction TB
            Collector["Collector Plugin"]:::agent
            EDriverGo["eDriver Plugin (Go)"]:::agent
            EDriverRust["eDriver Plugin (Rust)"]:::agent
            EGuard["EGuard Plugin"]:::agent
            NCP["NCP Plugin"]:::agent
        end
    end

    %% Network Transport
    subgraph "Network Transport" 
        direction TB
        TransClient["Transport Client"]:::transport
        TransPool["Transfer Pool"]:::transport
        ProtoDef["Protocol Definition"]:::transport
    end

    %% Server Side
    subgraph "Server"
        direction TB
        subgraph "gRPC Transfer Service"
            direction TB
            GRPCTransferServ["gRPC Transfer Service"]:::server
            TransferHandler["Transfer Handler"]:::server
            TransferPool["Transfer Pool"]:::transport
        end
        subgraph "gRPC Main Service"
            direction TB
            GRPCMainServ["gRPC Main Service"]:::server
            MainHandlers["Handlers & Registry"]:::server
        end
        subgraph "HTTP API Layer"
            direction TB
            HTTPAPI["HTTP API"]:::server
            APIRouter["API Router & Middleware"]:::server
        end
        StaticAssets["Static Frontend Assets"]:::static
        WebCmd["Web Console Main App"]:::server
        TransferCLI["Transfer Server CLI"]:::server
        ConfigFiles["Configuration Files"]:::server
        subgraph "Data Stores"
            direction TB
            MongoDB["MongoDB"]:::db
            Redis["Redis"]:::db
        end
    end

    %% Connections
    Browser -->|"HTTP Requests"| HTTPAPI
    HTTPAPI -->|routes| MainHandlers
    MainHandlers -->|read/write| MongoDB
    MainHandlers -->|cache| Redis
    MainHandlers -->|calls| GRPCMainServ

    AgentPluginsFramework -->|emit events| AgentCore
    AgentCore -->|uses| SDKGoClock
    AgentCore -->|uses| SDKGoConfig
    AgentCore -->|uses| SDKGoLogger
    AgentCore -->|uses| SDKGoUtils
    AgentCore -->|calls| AgentTransport

    AgentTransport -->|connects| TransClient
    TransClient -->|sends events| TransPool
    TransPool -->|over| ProtoDef
    TransPool -->|to| GRPCTransferServ

    GRPCTransferServ -->|forwards| TransferHandler
    TransferHandler -->|routes| MainHandlers

    WebCmd -->|serves| StaticAssets
    WebCmd -->|loads config| ConfigFiles
    TransferCLI -->|starts| GRPCTransferServ

    %% Click Events - SDK Go
    click SDKGoClock "https://github.com/chriskalix/hades/blob/main/SDK/go/clock/clock.go"
    click SDKGoConfig "https://github.com/chriskalix/hades/blob/main/SDK/go/config/config.go"
    click SDKGoLogger "https://github.com/chriskalix/hades/blob/main/SDK/go/logger/logger.go"
    click SDKGoTransClient "https://github.com/chriskalix/hades/blob/main/SDK/go/transport/client/client.go"
    click SDKGoTransPool "https://github.com/chriskalix/hades/blob/main/SDK/go/transport/pool/pool.go"
    click SDKGoProtocol "https://github.com/chriskalix/hades/blob/main/SDK/go/transport/protocol/transfer.pb.go"
    click SDKGoTransServer "https://github.com/chriskalix/hades/blob/main/SDK/go/transport/server/server.go"
    click SDKGoUtils "https://github.com/chriskalix/hades/blob/main/SDK/go/utils/decompress.go"
    click SDKRust "https://github.com/chriskalix/hades/blob/main/SDK/rust/src/lib.rs"

    %% Click Events - Agent Core
    click AgentCore "https://github.com/chriskalix/hades/blob/main/agent/agent/agent.go"
    click AgentTransport "https://github.com/chriskalix/hades/blob/main/agent/transport/client.go"
    click AgentUtils "https://github.com/chriskalix/hades/blob/main/agent/utils/decompress.go"
    click AgentPluginMgr "https://github.com/chriskalix/hades/blob/main/agent/plugin/manager.go"

    %% Click Events - Plugins
    click Collector "https://github.com/chriskalix/hades/blob/main/plugins/collector/main.go"
    click EDriverGo "https://github.com/chriskalix/hades/blob/main/plugins/edriver/main.go"
    click EDriverRust "https://github.com/chriskalix/hades/blob/main/plugins/edriver-rust/Cargo.toml"
    click EGuard "https://github.com/chriskalix/hades/tree/main/plugins/eguard/src/manager"
    click NCP "https://github.com/chriskalix/hades/blob/main/plugins/ncp/main.go"

    %% Click Events - Transport Protocol
    click ProtoDef "https://github.com/chriskalix/hades/blob/main/SDK/transfer.proto"

    %% Click Events - Server
    click GRPCTransferServ "https://github.com/chriskalix/hades/blob/main/server/webconsole/grpc/transfer/server.go"
    click TransferHandler "https://github.com/chriskalix/hades/blob/main/server/webconsole/grpc/transfer/handler/handler.go"
    click TransferPool "https://github.com/chriskalix/hades/blob/main/server/webconsole/grpc/transfer/pool/pool.go"
    click GRPCMainServ "https://github.com/chriskalix/hades/blob/main/server/webconsole/grpc/handler/handler.go"
    click MainHandlers "https://github.com/chriskalix/hades/blob/main/server/webconsole/grpc/registry/registry.go"
    click TransferCLI "https://github.com/chriskalix/hades/blob/main/server/webconsole/cmd/grpc/grpc.go"
    click HTTPAPI "https://github.com/chriskalix/hades/blob/main/server/webconsole/api/api/router.go"
    click StaticAssets "https://github.com/chriskalix/hades/blob/main/server/webconsole/api/static/frontend/index.html"
    click MongoDB "https://github.com/chriskalix/hades/blob/main/server/webconsole/pkg/basic/mongo/mongo.go"
    click Redis "https://github.com/chriskalix/hades/blob/main/server/webconsole/pkg/basic/redis/redis.go"
    click ConfigFiles "https://github.com/chriskalix/hades/blob/main/server/webconsole/config/conf.yaml"
    click WebCmd "https://github.com/chriskalix/hades/blob/main/server/webconsole/cmd/main.go"

    %% Styles
    classDef agent fill:#e0f8e0,stroke:#0a0
    classDef transport fill:#e0f0ff,stroke:#00a
    classDef server fill:#fff0e0,stroke:#a50
    classDef db fill:#f3e2a9,stroke:#a36
    classDef static fill:#d0d0d0,stroke:#666
```
