# ilya-zlobintsev/lact architecture

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

- Interactive diagram: https://gitdiagram.com/ilya-zlobintsev/lact
- Repository: https://github.com/ilya-zlobintsev/lact

## Overview

##### Main Components
- Daemon (lact-daemon): Acts as the central service that runs as a systemd service (and/or via OpenRC) and directly interacts with the Linux system interfaces (SysFS, libdrm, kernel drivers) for GPU configuration. It reads a configuration file (e.g. /etc/lact/config.yaml) and listens on a Unix socket and optionally a TCP port.
- GUI Client (lact-gui): Provides the graphical user interface (using GTK4 and optionally libadwaita) to allow users to view GPU stats, adjust overclocking settings, control fan curves, etc.
- CLI Utility (lact & lact-cli): Offers a command-line interface to query or change settings, often for scripting or remote access.
- Client Library (lact-client): Abstracts the communication layer between clients (GUI/CLI) and the daemon by encapsulating the details of exchanging messages.
- Shared Schema (lact-schema): Contains common API definitions, types (request/response formats), and serialization logic used by both the daemon and client libraries to maintain consistency.
- Packaging/Deployment Module (pkg directory): Contains build scripts (Makefile), Dockerfiles, Fedora spec files, and packaging recipes—highlighting that the application is designed to be distributed across various Linux distributions.

##### Relationships and Interactions
- The daemon itself performs hardware interactions using system libraries (libdrm, hwdata) by reading SysFS and issuing commands to enable/control features. This direct link with underlying Linux system interfaces is a critical design aspect.
- The packaging components (scripts, spec files, Dockerfiles) are used to build and distribute the application and can be represented as a separate module that “feeds into” all of these deployed artifacts.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The user interface (lact-gui) is completely decoupled from the GPU control logic that resides in the daemon. Likewise, the lact-schema and lact-client encapsulate the communication protocol, reducing tight coupling.
- Extensibility: The file structure and modular design make it evident that new features (or support for additional GPUs) may be added by extending the existing libraries or client modules.

##### Relevant Technologies and Frameworks
- Rust programming language with Cargo for dependency management.
- GTK4 (and libadwaita in lact-gui) for the graphical interface.
- Systemd for service management (as referenced by the usage instructions in the README).
- Linux system interfaces (SysFS, libdrm, kernel drivers) for GPU control.
- Dockerfiles and packaging recipes for multi-distro support.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Applications
    subgraph "Client Applications"
        GU["lact-gui (GUI Client)"]:::green
        CLI1["lact-cli (CLI Utility)"]:::green
        CLI2["lact (CLI Tool)"]:::green
    end

    %% Communication Layer
    subgraph "Communication Layer"
        CL["lact-client (Client Library)"]:::grey
        LS["lact-schema (Shared Schema)"]:::grey
    end

    %% Server / Daemon
    subgraph "Server"
        DA["lact-daemon (Daemon)\n(Read: /etc/lact/config.yaml)"]:::blue
    end

    %% Packaging & Deployment Module
    subgraph "Packaging & Deployment"
        PK["pkg (Packaging/Deployment Module)"]:::orange
    end

    %% Underlying Linux System Interfaces
    SI["Linux System Interfaces\n(SysFS, libdrm, Kernel Drivers)"]:::system

    %% Connections between components
    GU -->|"API_calls"| CL
    CLI1 -->|"API_calls"| CL
    CLI2 -->|"API_calls"| CL
    CL -->|"UnixSocket/TCP"| DA
    CL -->|"uses"| LS
    DA -->|"Hardware_control"| SI

    %% Packaging builds/distributes components
    PK -->|"builds"| DA
    PK -->|"builds"| GU
    PK -->|"builds"| CLI1
    PK -->|"builds"| CLI2
    PK -->|"builds"| CL
    PK -->|"builds"| LS

    %% Click Events
    click DA "https://github.com/ilya-zlobintsev/lact/tree/master/lact-daemon/"
    click GU "https://github.com/ilya-zlobintsev/lact/tree/master/lact-gui/"
    click CLI1 "https://github.com/ilya-zlobintsev/lact/tree/master/lact-cli/"
    click CLI2 "https://github.com/ilya-zlobintsev/lact/tree/master/lact/"
    click CL "https://github.com/ilya-zlobintsev/lact/tree/master/lact-client/"
    click LS "https://github.com/ilya-zlobintsev/lact/tree/master/lact-schema/"
    click PK "https://github.com/ilya-zlobintsev/lact/tree/master/pkg/"

    %% Styles
    classDef blue fill:#a0c4ff,stroke:#00008b,stroke-width:2px;
    classDef green fill:#caffbf,stroke:#008000,stroke-width:2px;
    classDef grey fill:#d3d3d3,stroke:#696969,stroke-width:2px;
    classDef orange fill:#ffcc99,stroke:#ff8c00,stroke-width:2px;
    classDef system fill:#f4cccc,stroke:#b22222,stroke-width:2px;
```
