# google/draco architecture

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

- Interactive diagram: https://gitdiagram.com/google/draco
- Repository: https://github.com/google/draco

## Overview

##### Project type and purpose
- Draco is a C++ library and tool suite for compressing/decompressing 3D geometric meshes and point clouds.
- It provides command-line applications (`draco_encoder`, `draco_decoder`, `draco_transcoder`), C++ and JavaScript/WASM APIs for integration, plus Unity and Maya plugins.

##### File structure
Top-level directories and their roles:
- cmake / CMakeLists.txt / BUILDING.md / CMAKE.md – build configuration and custom toolchains.
- src/draco – the core C++ library, subdivided into modules:
– core (common utilities, buffers, status handling)
– io (file format parsers and writers: OBJ, PLY, glTF, STL, images)
– compression (encoder/decoder pipelines for attributes, bit coders, entropy, mesh, point clouds)
– mesh, point_cloud, metadata, scene, material, texture – data structures and metadata API
– javascript/emscripten – WebIDL bindings for generating WASM + JS modules
– tools – CLI apps and fuzzers
– unity, maya – native plugins for game engines
- javascript – prebuilt WASM/JS decoder and encoder wrappers plus NPM packages and examples.
- unity / maya – C# wrappers and native archives for engine integration.
- third_party – bundled dependencies (Eigen, googletest, tinygltf).
- docs – user documentation, website content, specification.
- testdata – geometry assets used by tests and examples.

##### README for additional insights
- Describes build steps (CMake), release artifacts (WASM + JS decoders on GStatic), and supported use cases: CLI, C++ API, JS API, Unity, glTF transcoding, metadata.
- Points out key architectural elements: modular library, Emscripten binding, separate encoder/decoder, plugin support.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build System
    subgraph "Build System" 
        direction TB
        CMakeLists["CMakeLists.txt"]:::build
        CMakeDir["cmake/"]:::build
        BUILDING["BUILDING.md"]:::build
        CMAKEmd["CMAKE.md"]:::build
    end

    %% Core C++ Library Modules
    subgraph "Core C++ Library" 
        direction TB
        CoreUtils["core utilities"]:::core
        IO["io parsers/writers"]:::core
        Compression["compression pipelines"]:::core
        MeshModel["mesh data structures"]:::core
        PointCloud["point cloud model"]:::core
        Metadata["metadata API"]:::core
        Scene["scene graph"]:::core
        Material["material utils"]:::core
        Texture["texture I/O"]:::core
    end

    %% Command-Line Tools
    subgraph "CLI Tools" 
        direction TB
        Encoder["draco_encoder.cc"]:::cli
        Decoder["draco_decoder.cc"]:::cli
        Transcoder["draco_transcoder.cc"]:::cli
        TranscoderLib["draco_transcoder_lib.*"]:::cli
        Fuzzers["fuzz/"]:::cli
    end

    %% Emscripten Bindings & WASM
    subgraph "Emscripten & WASM Module" 
        direction TB
        Emscripten["emscripten bindings"]:::wasm
        WASMEnc["draco_encoder.js/.wasm"]:::wasm
        WASMDec["draco_decoder.js/.wasm"]:::wasm
    end

    %% JavaScript API & NPM
    subgraph "JavaScript API & NPM" 
        direction TB
        NPMPkg1["npm/draco3d/"]:::js
        NPMPkg2["npm/draco3dgltf/"]:::js
        Examples["javascript/example/"]:::js
    end

    %% Unity & Maya Plugins
    subgraph "Engine Plugins" 
        direction TB
        UnityNative["draco_unity_plugin.cc/.h"]:::plugin
        MayaNative["draco_maya_plugin.cc/.h"]:::plugin
        UnityWrappers["unity/"]:::plugin
        MayaArchives["maya/"]:::plugin
    end

    %% Third-Party Dependencies
    subgraph "Third-Party Dependencies" 
        direction TB
        Eigen["eigen/"]:::third
        GTest["googletest/"]:::third
        TinyGLTF["tinygltf/"]:::third
    end

    %% Test Data & Examples
    subgraph "Test Data & Examples" 
        direction TB
        TestData["testdata/"]:::test
        UnitTests["*_test.cc"]:::test
    end

    %% Build Dependencies
    CMakeLists --> CoreUtils
    CMakeLists --> IO
    CMakeLists --> Compression
    CMakeLists --> MeshModel
    CMakeLists --> PointCloud
    CMakeLists --> Metadata
    CMakeLists --> Scene
    CMakeLists --> Material
    CMakeLists --> Texture
    CMakeLists --> Encoder
    CMakeLists --> Decoder
    CMakeLists --> Transcoder
    CMakeLists --> UnityNative
    CMakeLists --> MayaNative
    CMakeLists --> Emscripten
    CMakeLists --> Eigen
    CMakeLists --> GTest
    CMakeLists --> TinyGLTF

    %% Runtime Data Flow CLI
    Encoder -->|reads formats| IO
    Decoder -->|writes formats| IO
    IO -->|uses| Compression
    Compression -->|operates on| MeshModel
    Compression -->|operates on| PointCloud
    Metadata -->|attached to| MeshModel
    Metadata -->|attached to| PointCloud

    %% Runtime Data Flow WASM
    NPMPkg1 -->|loads| WASMEnc
    NPMPkg1 -->|loads| WASMDec
    Emscripten -->|generates| WASMEnc
    Emscripten -->|generates| WASMDec

    %% Engine Plugins usage
    UnityWrappers -->|calls| UnityNative
    MayaArchives -->|calls| MayaNative

    %% Tests
    GTest -->|runs| UnitTests
    UnitTests -->|use| TestData

    %% Click Events
    click CMakeLists "https://github.com/google/draco/blob/main/CMakeLists.txt"
    click CMakeDir "https://github.com/google/draco/tree/main/cmake/"
    click BUILDING "https://github.com/google/draco/blob/main/BUILDING.md"
    click CMAKEmd "https://github.com/google/draco/blob/main/CMAKE.md"
    click CoreUtils "https://github.com/google/draco/tree/main/src/draco/core/"
    click IO "https://github.com/google/draco/tree/main/src/draco/io/"
    click Compression "https://github.com/google/draco/tree/main/src/draco/compression/"
    click MeshModel "https://github.com/google/draco/tree/main/src/draco/mesh/"
    click PointCloud "https://github.com/google/draco/tree/main/src/draco/point_cloud/"
    click Metadata "https://github.com/google/draco/tree/main/src/draco/metadata/"
    click Scene "https://github.com/google/draco/tree/main/src/draco/scene/"
    click Material "https://github.com/google/draco/tree/main/src/draco/material/"
    click Texture "https://github.com/google/draco/tree/main/src/draco/texture/"
    click Encoder "https://github.com/google/draco/blob/main/src/draco/tools/draco_encoder.cc"
    click Decoder "https://github.com/google/draco/blob/main/src/draco/tools/draco_decoder.cc"
    click Transcoder "https://github.com/google/draco/blob/main/src/draco/tools/draco_transcoder.cc"
    click TranscoderLib "https://github.com/google/draco/blob/main/src/draco/tools/draco_transcoder_lib.*"
    click Fuzzers "https://github.com/google/draco/tree/main/src/draco/tools/fuzz/"
    click Emscripten "https://github.com/google/draco/tree/main/src/draco/javascript/emscripten/"
    click NPMPkg1 "https://github.com/google/draco/tree/main/javascript/npm/draco3d/"
    click NPMPkg2 "https://github.com/google/draco/tree/main/javascript/npm/draco3dgltf/"
    click Examples "https://github.com/google/draco/tree/main/javascript/example/"
    click UnityNative "https://github.com/google/draco/blob/main/src/draco/unity/draco_unity_plugin.cc"
    click MayaNative "https://github.com/google/draco/blob/main/src/draco/maya/draco_maya_plugin.cc"
    click UnityWrappers "https://github.com/google/draco/tree/main/unity/"
    click MayaArchives "https://github.com/google/draco/tree/main/maya/"
    click Eigen "https://github.com/google/draco/tree/main/third_party/eigen/"
    click GTest "https://github.com/google/draco/tree/main/third_party/googletest/"
    click TinyGLTF "https://github.com/google/draco/tree/main/third_party/tinygltf/"
    click TestData "https://github.com/google/draco/tree/main/testdata/"

    %% Styles
    classDef build fill:#cccccc,stroke:#333,stroke-width:1px
    classDef core fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef cli fill:#bbdefb,stroke:#1565c0,stroke-width:1px
    classDef wasm fill:#fff9c4,stroke:#f9a825,stroke-width:1px
    classDef js fill:#ffe0b2,stroke:#ef6c00,stroke-width:1px
    classDef plugin fill:#e1bee7,stroke:#7b1fa2,stroke-width:1px
    classDef third fill:#f5f5f5,stroke:#9e9e9e,stroke-width:1px,stroke-dasharray: 5 5
    classDef test fill:#fce4ec,stroke:#c2185b,stroke-width:1px.merge
```
