# embarkstudios/cargo-about architecture

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

- Interactive diagram: https://gitdiagram.com/embarkstudios/cargo-about
- Repository: https://github.com/embarkstudios/cargo-about

## Overview

##### Project type and purpose
- This is a Rust-based CLI tool and Cargo plugin called “cargo-about,” whose job is to scan a crate’s dependency graph, collect license metadata (using SPDX), and render a formatted license listing via a Handlebars template.
- It’s not a web app or microservice—its architecture centers on command dispatch, license-resolution logic, and template-based output generation.

##### File structure
- Top-level: Cargo.toml/Cargo.lock, src/, tests/, docs/, resources/ (templates, default.hbs), and .github/ (CI, issue/pr templates).
- src/:
- cargo-about/ – three sub-modules (init.rs, generate.rs, clarify.rs) plus main.rs.
- licenses/ – modules for scanning, fetching, resolution, plus per-crate workaround code.
- win_bindings.rs & bindings.toml – Windows FFI support.
- lib.rs – the core library entrypoint.
- tests/: end-to-end CLI tests and unit-test helpers under tests/utils.
- docs/: the book for user-facing documentation.

##### README
- Confirms use cases (“cargo about init”, “cargo about generate”).

##### Detail is key
- Module names (e.g., `src/licenses/scan.rs`, `src/cargo-about/generate.rs`).
- Workaround sub-modules as part of the License Engine.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation" 
        direction TB
        User(["User"]):::external
        CLI["cargo-about\n(main.rs)"]:::frontend
        click CLI "https://github.com/embarkstudios/cargo-about/blob/main/src/cargo-about/main.rs"
        Init["init handler\n(init.rs)"]:::frontend
        click Init "https://github.com/embarkstudios/cargo-about/blob/main/src/cargo-about/init.rs"
        Gen["generate handler\ngenerate.rs"]:::frontend
        click Gen "https://github.com/embarkstudios/cargo-about/blob/main/src/cargo-about/generate.rs"
        Clarify["clarify handler\nclarify.rs"]:::frontend
        click Clarify "https://github.com/embarkstudios/cargo-about/blob/main/src/cargo-about/clarify.rs"
    end

    %% Application Layer
    subgraph "Application Logic"
        direction TB
        Core["Core Library\n(lib.rs)"]:::application
        click Core "https://github.com/embarkstudios/cargo-about/blob/main/src/lib.rs"
    end

    %% Domain Layer
    subgraph "Domain Logic"
        direction TB
        Engine["License Engine\n(licenses.rs)"]:::domain
        click Engine "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses.rs"
        Scan["scan module\n(scan.rs)"]:::domain
        click Scan "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/scan.rs"
        Fetch["fetch module\n(fetch.rs)"]:::domain
        click Fetch "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/fetch.rs"
        Resolve["resolution module\n(resolution.rs)"]:::domain
        click Resolve "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/resolution.rs"
        ConfigMod["config module\n(config.rs)"]:::domain
        click ConfigMod "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/config.rs"
        Work["workarounds entry\n(workarounds.rs)"]:::domain
        click Work "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds.rs"
        subgraph "Per-crate Workarounds"
            direction TB
            Bitvec["bitvec.rs"]:::domain
            click Bitvec "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/bitvec.rs"
            Chrono["chrono.rs"]:::domain
            click Chrono "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/chrono.rs"
            ClapMod["clap.rs"]:::domain
            click ClapMod "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/clap.rs"
            Cocoa["cocoa.rs"]:::domain
            click Cocoa "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/cocoa.rs"
            GTK["gtk.rs"]:::domain
            click GTK "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/gtk.rs"
            Prost["prost.rs"]:::domain
            click Prost "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/prost.rs"
            Ring["ring.rs"]:::domain
            click Ring "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/ring.rs"
            Rustls["rustls.rs"]:::domain
            click Rustls "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/rustls.rs"
            Sentry["sentry.rs"]:::domain
            click Sentry "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/sentry.rs"
            Tonic["tonic.rs"]:::domain
            click Tonic "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/tonic.rs"
            Tract["tract.rs"]:::domain
            click Tract "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/tract.rs"
            Unicode["unicode_ident.rs"]:::domain
            click Unicode "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/unicode_ident.rs"
            Wasm["wasmtime.rs"]:::domain
            click Wasm "https://github.com/embarkstudios/cargo-about/blob/main/src/licenses/workarounds/wasmtime.rs"
        end
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        Renderer["Template Renderer\n(about.hbs,\nabout_list_by_crate_example.hbs,\nresources/default.hbs)"]:::infra
        click Renderer "https://github.com/embarkstudios/cargo-about/blob/main/about.hbs"
        IO["Config & I/O\n(about.toml,\nresources/about.toml,\ndeny.toml)"]:::infra
        click IO "https://github.com/embarkstudios/cargo-about/blob/main/about.toml"
        Bindings["Windows FFI\n(win_bindings.rs,\nbindings.toml)"]:::infra
        click Bindings "https://github.com/embarkstudios/cargo-about/blob/main/src/win_bindings.rs"
    end

    %% External Dependencies
    subgraph "External Interfaces"
        direction TB
        CargoMeta["Cargo Metadata API"]:::external
        CratesIO["crates.io / SPDX"]:::external
        FS["Local File System"]:::external
    end

    %% Flow
    User -->|"runs command"| CLI
    CLI -->|"parse args"| Init
    CLI -->|"parse args"| Gen
    CLI -->|"parse args"| Clarify
    Init -->|"calls"| Core
    Gen -->|"calls"| Core
    Clarify -->|"calls"| Core
    Core -->|"invokes"| Engine
    Engine -->|"uses"| Scan
    Engine -->|"uses"| Fetch
    Engine -->|"uses"| Resolve
    Engine -->|"reads config"| ConfigMod
    Engine -->|"delegates"| Work
    Scan -->|"query graph"| CargoMeta
    Fetch -->|"lookup licenses"| CratesIO
    Core -->|"returns data model"| Renderer
    Renderer -->|"render template"| IO
    IO -->|"write output"| FS

    %% Styling
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef application fill:#E2F0D9,stroke:#2E7D32,color:#2E7D32;
    classDef domain fill:#FFE5B4,stroke:#FB8C00,color:#E65100;
    classDef infra fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C;
    classDef external fill:#E0E0E0,stroke:#616161,color:#424242;
```
