# contentauth/c2pa-js architecture

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

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

## Overview

##### Project Type and Purpose
- This is a monorepo for a JavaScript SDK with the primary goal of making it easy to view and verify C2PA metadata directly in the browser.
- The SDK is designed to support different integration scenarios (e.g., standard web components, React integrations, toolkit utilities, and detection logic) while sharing a core implementation.
- It uses Rush for monorepo management, which centralizes configuration, dependency management, and build orchestration across multiple packages.

##### File Structure
- The top-level directories include:
– Common: Contains shared APIs, autoinstallers, configuration files, and git hooks. These are reusable across packages.
– Examples: Provides multiple sample applications or configurations (e.g., minimal TypeScript setups with Rollup, Vite, Webpack, and React integrations) that demonstrate how to integrate the SDK.
– Packages: Contains several packages, each focusing on a specific aspect:
▪ packages/c2pa – The core library managing metadata, manifest handling, and core algorithms.
▪ packages/c2pa-wc – A web component implementation exposing UI parts such as badges, headers, and tooltips, with Storybook support for visual demonstrations.
▪ packages/detector – Likely responsible for detecting and analyzing media content for authenticity.
▪ packages/react – Provides React hooks and components for integrating the SDK into React applications.
▪ packages/toolkit – Contains additional utilities and CLI tools to work with or extend the SDK functionality.
– Tools: Contains additional tooling (like c2pa-wc-storykit) and testing utilities.
– Configurations: Numerous build, lint, and workflow configuration files that show the integration with CI/CD (GitHub Workflows) and packaging rules.
- The structure also shows language integrations (TypeScript, Rust for toolkit parts, WebAssembly) and multiple bundler configurations (Rollup, Webpack, Vite).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Monorepo (Rush Managed)"
        direction TB
        A["Rush Manager (rush.json)"]:::monorepo
        B["Shared Utilities (common)"]:::shared
        
        subgraph "Core Layer"
            direction TB
            C["Core SDK (packages/c2pa)"]:::core
        end
        
        subgraph "UI Components"
            direction TB
            D["Web Components (packages/c2pa-wc)"]:::ui
            E["React Integration (packages/react)"]:::ui
        end
        
        subgraph "Auxiliary Modules"
            direction TB
            F["Detector (packages/detector)"]:::aux
            G["Toolkit (packages/toolkit)"]:::aux
        end
        
        subgraph "Usage and CI/CD"
            direction TB
            H["Examples (examples)"]:::example
            I["CI/CD Workflows (.github/workflows)"]:::ci
        end
    end

    A -->|"manages"| B
    B -->|"shared_config"| C
    B -->|"shared_config"| D
    B -->|"shared_config"| E
    B -->|"shared_config"| F
    B -->|"shared_config"| G
    C -->|"provides_core"| D
    C -->|"provides_core"| E
    C -->|"provides_core"| F
    C -->|"provides_core"| G
    H -->|"demonstrates_usage"| C
    H -->|"demonstrates_usage"| D
    H -->|"demonstrates_usage"| E
    H -->|"demonstrates_usage"| F
    H -->|"demonstrates_usage"| G
    I -->|"triggers_builds"| A
    I -->|"runs_tests_on"| H

    click A "https://github.com/contentauth/c2pa-js/blob/main/rush.json"
    click C "https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa"
    click D "https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wc"
    click E "https://github.com/contentauth/c2pa-js/tree/main/packages/react"
    click F "https://github.com/contentauth/c2pa-js/tree/main/packages/detector"
    click G "https://github.com/contentauth/c2pa-js/tree/main/packages/toolkit"
    click B "https://github.com/contentauth/c2pa-js/tree/main/common"
    click H "https://github.com/contentauth/c2pa-js/tree/main/examples"
    click I "https://github.com/contentauth/c2pa-js/tree/main/.github/workflows"

    classDef monorepo fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef core fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef ui fill:#f5b7b1,stroke:#943126,stroke-width:2px;
    classDef aux fill:#fcf3cf,stroke:#b7950b,stroke-width:2px;
    classDef shared fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef example fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef ci fill:#f5cba7,stroke:#d35400,stroke-width:2px;
```
