# awslabs/mls-rs architecture

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

- Interactive diagram: https://gitdiagram.com/awslabs/mls-rs
- Repository: https://github.com/awslabs/mls-rs

## Overview

##### Project Type and Purpose
- The project is a cryptographic protocol library (specifically for MLS) written in Rust.
- It provides implementations for serialization (codecs), core MLS logic, and various pluggable cryptographic backends.
- Additional components (like identity management with X509, persistent storage via SQLite, and FFI/uniffi bindings) suggest that it is intended both for native Rust usage and integration with other environments.

##### Analysis of the File Structure
- The top-level directory includes the root “mls-rs” crate along with many sub-crates such as:
- mls-rs-codec and mls-rs-codec-derive for encoding and decoding.
- mls-rs-core for the core protocol logic (e.g., group management, proposals, key schedule, cryptographic context, etc.).
- A cluster of mls-rs-crypto-* crates (awslc, cryptokit, hpke, openssl, rustcrypto, webcrypto) that provide alternative implementations or adapters for cryptography. There’s also a mls-rs-crypto-traits crate that defines common interfaces.
- Additional supportive modules like mls-rs-identity-x509 (for X509-based identity extraction), mls-rs-provider-sqlite (for persistent group state management), and mls-rs-uniffi/ffi (for cross-language integration).
- There are also directories for integration testing, benchmarks, fuzzing, and various GitHub configurations for CI/CD.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Interfaces
    Client["Client/Application Interface (mls-rs)"]:::protocol

    %% Core Layer
    Core["Core Protocol Logic (mls-rs-core)"]:::protocol
    CodecImpl["Codec Implementation (mls-rs-codec)"]:::protocol
    CodecDerive["Codec Derive Macros (mls-rs-codec-derive)"]:::protocol
    Identity["Identity Management (mls-rs-identity-x509)"]:::protocol
    Persistence["Persistence Provider (mls-rs-provider-sqlite)"]:::protocol

    %% Cryptographic Components
    CryptoAbs["Crypto Abstraction (mls-rs-crypto-traits)"]:::crypto
    AWSLC["AWSLC (mls-rs-crypto-awslc)"]:::crypto
    CryptoKit["CryptoKit (mls-rs-crypto-cryptokit)"]:::crypto
    HPKE["HPKE (mls-rs-crypto-hpke)"]:::crypto
    OpenSSL["OpenSSL (mls-rs-crypto-openssl)"]:::crypto
    RustCrypto["RustCrypto (mls-rs-crypto-rustcrypto)"]:::crypto
    WebCrypto["WebCrypto (mls-rs-crypto-webcrypto)"]:::crypto

    %% External Bindings
    FFI["FFI Layer (mls-rs-ffi)"]:::integration
    UniFFI["UniFFI Bindings (mls-rs-uniffi)"]:::integration

    %% Testing & CI/CD
    IntegrationTest["Integration Testing (mls-rs/test_harness_integration)"]:::integration
    Fuzz["Fuzz Testing (mls-rs/fuzz)"]:::integration
    UnitTests["Unit Tests (mls-rs/tests)"]:::integration
    CICD["CI/CD & Workflows (.github/workflows)"]:::integration

    %% Connections
    Client -->|"calls"| Core
    Core -->|"serializes"| CodecImpl
    Core -->|"derives"| CodecDerive
    Core -->|"abstracts"| CryptoAbs
    CryptoAbs -->|"implements"| AWSLC
    CryptoAbs -->|"implements"| CryptoKit
    CryptoAbs -->|"implements"| HPKE
    CryptoAbs -->|"implements"| OpenSSL
    CryptoAbs -->|"implements"| RustCrypto
    CryptoAbs -->|"implements"| WebCrypto
    Core -->|"handles"| Identity
    Core -->|"persists"| Persistence
    Core -->|"exposes"| FFI
    Core -->|"exposes"| UniFFI
    %% External validation connections (dashed lines)
    IntegrationTest ---|"validates"| Core
    Fuzz ---|"tests"| Core
    UnitTests ---|"verifies"| Core
    CICD ---|"automates"| Core
    Client ---|"integrates"| FFI
    Client ---|"integrates"| UniFFI

    %% Click Events
    click Client "https://github.com/awslabs/mls-rs/blob/main/mls-rs/src/client.rs"
    click Core "https://github.com/awslabs/mls-rs/tree/main/mls-rs-core/"
    click CodecImpl "https://github.com/awslabs/mls-rs/blob/main/mls-rs-codec/src/lib.rs"
    click CodecDerive "https://github.com/awslabs/mls-rs/tree/main/mls-rs-codec-derive/"
    click CryptoAbs "https://github.com/awslabs/mls-rs/tree/main/mls-rs-crypto-traits/"
    click AWSLC "https://github.com/awslabs/mls-rs/tree/main/mls-rs-crypto-awslc/"
    click CryptoKit "https://github.com/awslabs/mls-rs/tree/main/mls-rs-crypto-cryptokit/"
    click HPKE "https://github.com/awslabs/mls-rs/tree/main/mls-rs-crypto-hpke/"
    click OpenSSL "https://github.com/awslabs/mls-rs/tree/main/mls-rs-crypto-openssl/"
    click RustCrypto "https://github.com/awslabs/mls-rs/tree/main/mls-rs-crypto-rustcrypto/"
    click WebCrypto "https://github.com/awslabs/mls-rs/tree/main/mls-rs-crypto-webcrypto/"
    click Identity "https://github.com/awslabs/mls-rs/tree/main/mls-rs-identity-x509/"
    click Persistence "https://github.com/awslabs/mls-rs/tree/main/mls-rs-provider-sqlite/"
    click FFI "https://github.com/awslabs/mls-rs/tree/main/mls-rs-ffi/"
    click UniFFI "https://github.com/awslabs/mls-rs/tree/main/mls-rs-uniffi/"
    click IntegrationTest "https://github.com/awslabs/mls-rs/tree/main/mls-rs/test_harness_integration/"
    click Fuzz "https://github.com/awslabs/mls-rs/tree/main/mls-rs/fuzz/"
    click UnitTests "https://github.com/awslabs/mls-rs/tree/main/mls-rs/tests/"
    click CICD "https://github.com/awslabs/mls-rs/tree/main/.github/workflows/"

    %% Styles
    classDef protocol fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef crypto fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef integration fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
```
