# scufflecloud/scuffle architecture

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

- Interactive diagram: https://gitdiagram.com/scufflecloud/scuffle
- Repository: https://github.com/scufflecloud/scuffle

## Overview

Based on our analysis of both the file tree and the README, it’s clear that Scuffle is an open‐source cloud provider with a strong emphasis on multimedia and video streaming capabilities. The project is organized as a multi-crate Rust workspace, where each crate encapsulates a specific piece of functionality—from core utilities and HTTP services to specialized multimedia processing (handling codecs, transmuxing, and media formats) and even build/development tools.

- Core Services & Utilities: Include components like scuffle-bootstrap (for creating binaries and telemetry), scuffle-context (context management), scuffle-future-ext (asynchronous utilities), scuffle-settings (configuration management), and scuffle-metrics (metrics collection, including the derive macros).
- HTTP & API Layer: Represent scuffle-http, which is styled as a high-performance HTTP server supporting HTTP/1.1, HTTP/2, and HTTP/3. This core component exposes APIs to manage interactions with external clients and services.
- Streaming & Protocol Handling: Include components such as scuffle-rtmp (for streaming protocols) and others (even if partially commented in the documentation) that are designed to handle live video streaming, media ingestion, and protocol control.
- Development & Automation Tools: Represent the dev-tools/xtask project and the CI/CD workflows (as seen in the .github directory) which handle tasks like testing, formatting, building, and releasing. This illustrates how the project maintains quality and rapid iteration.

##### Interactions and data flows
- Data flow between the HTTP service and multimedia processing components – for instance, incoming HTTP requests triggering media encoding/decoding operations.
- How metrics (scuffle-metrics) and telemetry (from scuffle-bootstrap-telemetry) are connected to downstream monitoring and logging services.
- Tie in the CI/CD pipelines (GitHub Actions components, workflows) that trigger builds, tests, and deployments.

##### Architectural patterns and principles
- Modular structure: each crate functions as an independent module contributing to the larger system. Mark these modules as distinct but interconnected blocks.
- Layered approach: configuration/loading at the base, core service and utilities in the middle layer, and presentation/API endpoints on top.
- Use of abstractions (e.g., derive macros in bootstrap and metrics, context propagation for cancellation and timeouts) to maintain clean separation of concerns.

##### Relevant technologies and frameworks
- Explicitly label that the project is written in Rust and highlight how the Rust ecosystem (e.g., Cargo workspace) is being utilized.
- Use of GitHub Actions for CI/CD work (with specific workflows, such as cargo testing, linting, formatting, and releases) as a separate supporting subsystem.
- Mention that parts of the system integrate external libraries (for instance, FFmpeg through scuffle-ffmpeg, and networking protocols through scuffle-http and scuffle-rtmp).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Services & Utilities
    subgraph "Core Services & Utilities"
        settings["scuffle-settings"]:::core
        bootstrap["scuffle-bootstrap"]:::core
        bootstrapDerive["bootstrap derive macros"]:::core
        context["scuffle-context"]:::core
        future["scuffle-future-ext"]:::core
        metrics["scuffle-metrics"]:::core
        metricsDerive["metrics derive macros"]:::core
    end

    %% HTTP & API Layer
    subgraph "HTTP & API Layer"
        http["HTTP Server – scuffle-http"]:::http
    end

    %% Multimedia Processing
    subgraph "Multimedia Processing"
        aac["scuffle-aac"]:::media
        av1["scuffle-av1"]:::media
        ffmpeg["scuffle-ffmpeg"]:::media
        flv["scuffle-flv"]:::media
        amf0["scuffle-amf0"]:::media
        expgolomb["scuffle-expgolomb"]:::media
    end

    %% Streaming & Protocol Handling
    subgraph "Streaming & Protocol Handling"
        rtmp["scuffle-rtmp"]:::streaming
    end

    %% Development & Automation Tools
    subgraph "Development & Automation Tools"
        xtask["dev-tools/xtask"]:::dev
        github["CI/CD workflows (.github)"]:::dev
    end

    %% Relationships: Core Layer
    settings -->|"configures"| bootstrap
    bootstrap -->|"utilizes"| bootstrapDerive
    metrics -->|"provides macros to"| metricsDerive
    bootstrap -->|"integrates telemetry with"| metrics
    bootstrap -->|"uses context"| context
    bootstrap -->|"leverages"| future

    %% Relationships: HTTP & Multimedia
    http -->|"triggers"| aac
    http -->|"triggers"| av1
    http -->|"triggers"| ffmpeg
    http -->|"triggers"| flv
    http -->|"triggers"| amf0
    http -->|"triggers"| expgolomb
    http -->|"coordinates"| rtmp

    %% CI/CD integration: triggering builds/tests across layers
    github ---|"builds/tests"| settings
    github ---|"builds/tests"| bootstrap
    github ---|"builds/tests"| http
    github ---|"builds/tests"| aac
    github ---|"builds/tests"| rtmp
    xtask ---|"executes tasks for"| bootstrap

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef http fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef media fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef streaming fill:#FFCCCB,stroke:#000,stroke-width:1px;
    classDef dev fill:#D3D3D3,stroke:#000,stroke-width:1px;

    %% Click Events for Core Services & Utilities
    click settings "https://github.com/scufflecloud/scuffle/tree/main/crates/settings"
    click bootstrap "https://github.com/scufflecloud/scuffle/tree/main/crates/bootstrap"
    click bootstrapDerive "https://github.com/scufflecloud/scuffle/tree/main/crates/bootstrap/derive"
    click context "https://github.com/scufflecloud/scuffle/tree/main/crates/context"
    click future "https://github.com/scufflecloud/scuffle/tree/main/crates/future-ext"
    click metrics "https://github.com/scufflecloud/scuffle/tree/main/crates/metrics"
    click metricsDerive "https://github.com/scufflecloud/scuffle/tree/main/crates/metrics/derive"

    %% Click Events for HTTP & API Layer
    click http "https://github.com/scufflecloud/scuffle/tree/main/crates/http"

    %% Click Events for Multimedia Processing
    click aac "https://github.com/scufflecloud/scuffle/tree/main/crates/aac"
    click av1 "https://github.com/scufflecloud/scuffle/tree/main/crates/av1"
    click ffmpeg "https://github.com/scufflecloud/scuffle/tree/main/crates/ffmpeg"
    click flv "https://github.com/scufflecloud/scuffle/tree/main/crates/flv"
    click amf0 "https://github.com/scufflecloud/scuffle/tree/main/crates/amf0"
    click expgolomb "https://github.com/scufflecloud/scuffle/tree/main/crates/expgolomb"

    %% Click Events for Streaming & Protocol Handling
    click rtmp "https://github.com/scufflecloud/scuffle/tree/main/crates/rtmp"

    %% Click Events for Development & Automation Tools
    click xtask "https://github.com/scufflecloud/scuffle/tree/main/dev-tools/xtask"
    click github "https://github.com/scufflecloud/scuffle/blob/main/.github"
```
