# dimensionhq/fleet architecture

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

- Interactive diagram: https://gitdiagram.com/dimensionhq/fleet
- Repository: https://github.com/dimensionhq/fleet

## Overview

Based on our analysis of the file tree and README, Fleet is a Rust build tool designed to significantly speed up Rust compilations by leveraging and optimizing existing Rust ecosystem tools such as sccache, lld, zld, and even features like ramdisks. Rather than being a typical full-stack application, it’s a command-line build accelerator with specialized modules for CLI interaction, core build logic, configuration, and installation.

##### Main Components
- CLI Layer: Represented by the files and directories inside src/cli (such as app.rs, help.rs, prompt modules). This is the user-facing component that receives command-line instructions.
- Configuration Management: The core/config subdirectory (and parts from src/utils) handles reading and manipulating configuration files (e.g., Cargo integration details, global settings). This is central to ensuring the build tool interfaces properly with existing cargo workspaces.
- Installation Module: There’s an installer directory that contains its own Cargo.toml, source in installer/src (main.rs) and a shell script (install.sh). This component deals with the distribution and installation of Fleet.
- External Tools & Environment: Although these aren’t directly part of the source code, highlight the integration with external Rust ecosystem tools (sccache, lld, zld, ramdisks) as they are critical to how Fleet accelerates builds.
- CI/CD and Repo Management: The .github directory indicates that there’s an integration with GitHub Actions workflows for building and testing across multiple platforms (Linux, macOS, Windows). This is less core to the build tool’s runtime behavior but is essential to the project’s maintenance and deployment.

##### Relationships and Interactions Between Components
- User commands enter through the CLI interface, which then invokes the appropriate command in the Core Build Logic layer.
- Core commands depend on configuration modules to fetch and apply settings, affecting how builds are executed (for instance, reading Cargo configurations).
- When a build command is initiated, the core module guarantees integration with and optimization over external build tools, suggesting a directional dependency from the core to external tooling.
- The Installer module acts as a separate entry point that packages and deploys Fleet on a target system, interfacing closely with the same core build logic.
- The CI/CD workflows ensure that any changes to these components are validated across environments, driving a feedback loop between development and integration testing.

##### Architectural Patterns and Design Principles
- Modularity and Layering: The separation between CLI, Core, and Utility modules implies a layered design with clear responsibilities. This separation helps in testing and maintenance.
- Command Pattern: Within the core commands (e.g., build.rs, run.rs, init.rs) there might be an implementation of a command pattern, enabling the addition of new commands easily.
- Configuration Management: A uniform approach to configuration through files (like fleet.toml, Cargo.toml) is present, suggesting a consistent mechanism across the codebase.

##### Final Reminders
- Every component is clearly labelled.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Input
    U["User Commands"]:::external

    %% CLI Layer
    subgraph "CLI Layer"
        CLI["CLI Interface (src/cli)"]:::cli
    end

    %% Core Build Logic Layer
    subgraph "Core Build Logic"
        CORE["Core Build Logic (src/core)"]:::core
        CONFIG["Configuration Management (src/core/config)"]:::config
        UTILS_CONFIG["Utility Config (src/utils/configure.rs)"]:::config
        CORE -->|"uses"| CONFIG
        CORE -->|"accesses"| UTILS_CONFIG
    end

    %% Installer Module
    subgraph "Installer Module"
        INSTALLER["Installer Module (installer)"]:::installer
    end

    %% External Tools
    subgraph "External Tools"
        SCCAACHE["sccache"]:::external
        LLD["lld"]:::external
        ZLD["zld"]:::external
        RAMDISK["ramdisks"]:::external
    end

    %% CI/CD and Repo Management
    subgraph "CI/CD & Repo Management"
        CICD["GitHub Workflows (.github)"]:::cicd
    end

    %% Connections
    U -->|"triggers"| CLI
    CLI -->|"invokes"| CORE
    CORE -->|"integrates"| SCCAACHE
    CORE -->|"integrates"| LLD
    CORE -->|"integrates"| ZLD
    CORE -->|"integrates"| RAMDISK
    INSTALLER -->|"deploys"| CORE
    CICD -->|"tests"| CLI
    CICD -->|"tests"| CORE
    CICD -->|"tests"| INSTALLER

    %% Click Events
    click CLI "https://github.com/dimensionhq/fleet/tree/master/src/cli"
    click CORE "https://github.com/dimensionhq/fleet/tree/master/src/core"
    click CONFIG "https://github.com/dimensionhq/fleet/tree/master/src/core/config"
    click UTILS_CONFIG "https://github.com/dimensionhq/fleet/blob/master/src/utils/configure.rs"
    click INSTALLER "https://github.com/dimensionhq/fleet/tree/master/installer"
    click CICD "https://github.com/dimensionhq/fleet/blob/master/.github"

    %% Styles
    classDef cli fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef core fill:#ccf,stroke:#333,stroke-width:2px;
    classDef config fill:#cfc,stroke:#333,stroke-width:2px;
    classDef installer fill:#fc9,stroke:#333,stroke-width:2px;
    classDef external fill:#9cf,stroke:#333,stroke-width:2px;
    classDef cicd fill:#efe,stroke:#333,stroke-width:2px;
```
