# contentauth/c2c2pa architecture

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

- Interactive diagram: https://gitdiagram.com/contentauth/c2c2pa
- Repository: https://github.com/contentauth/c2c2pa

## Overview

##### Project type and purpose
- This is a minimal hybrid-language “example” project demonstrating how to call a Rust-based C2PA SDK (c2pa-rs crate) from a C application.
- The README confirms it is not a full‐blown microservice or web app but a language‐binding proof‐of‐concept that uses Cargo, a Makefile, and a single C source file.

##### File structure
- Top‐level artifacts:
- Cargo.toml            – defines the Rust crate (dependencies, build config)
- Makefile              – orchestrates the build (cargo + gcc) and the run
- src/lib.rs            – Rust library source (the SDK wrapper exposing C FFI)
- src/main.c            – C application that calls into the Rust FFI
- rsc/es256_*.pem/key   – resource files (certificates/keys used at runtime)
- No “frontend” or “backend” directories: this is a single executable comprised of two language components.

##### Key insights from the README
- Build and run with `make run` (Makefile invokes cargo build + gcc link).
- This is purely local, no network services or databases involved.

##### Elements
- Makefile → Cargo build → Rust library artifact
- Makefile → GCC compile/link → C executable
- C Executable → (FFI) → Rust Library
- Rust Library → loads → PEM/KEY files
- Another for runtime components (C Executable, Rust Library)
- A third for external resources (cert/key)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build Tools
    subgraph "Build Tools"
        MF["Makefile"]:::build
        CI["Cargo"]:::build
        GCC["GCC"]:::build
    end

    %% Build Artifacts & Runtime
    subgraph "Artifacts & Runtime"
        subgraph "Rust Library (c2pa-rs)"
            CT["Cargo.toml"]:::build
            LR["src/lib.rs"]:::runtime
        end
        subgraph "C Executable"
            MC["src/main.c"]:::runtime
        end
    end

    %% Runtime Resources
    subgraph "Runtime Resources"
        PEM["es256_certs.pem"]:::resource
        KEY["es256_private.key"]:::resource
    end

    %% Connections
    MF -->|"invoke cargo build"| CI
    CI -->|"build library"| CT
    CI -->|"build library"| LR
    MF -->|"invoke gcc compile & link"| GCC
    GCC -->|"produce executable"| MC
    MC -->|"FFI call"| LR
    LR -->|"load certs"| PEM
    LR -->|"load key"| KEY

    %% Click Events
    click MF "https://github.com/contentauth/c2c2pa/tree/main/Makefile"
    click CT "https://github.com/contentauth/c2c2pa/blob/main/Cargo.toml"
    click LR "https://github.com/contentauth/c2c2pa/blob/main/src/lib.rs"
    click MC "https://github.com/contentauth/c2c2pa/blob/main/src/main.c"
    click PEM "https://github.com/contentauth/c2c2pa/blob/main/rsc/es256_certs.pem"
    click KEY "https://github.com/contentauth/c2c2pa/blob/main/rsc/es256_private.key"

    %% Styles
    classDef build fill:#f9f,stroke:#333,stroke-width:1px
    classDef runtime fill:#bbf,stroke:#333,stroke-width:1px
    classDef resource fill:#bfb,stroke:#333,stroke-width:1px
```
