# openwallet-foundation-labs/oid4vc-ts architecture

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

- Interactive diagram: https://gitdiagram.com/openwallet-foundation-labs/oid4vc-ts
- Repository: https://github.com/openwallet-foundation-labs/oid4vc-ts

## Overview

##### Project type and purpose
- This is a TypeScript monorepo (pnpm workspace) that publishes three related libraries under the “@openid4vc” scope plus a shared “utils” package.
- It implements OAuth 2.0 (client, authorization server, resource server) plus two OpenID extensions:
- OpenID for Verifiable Credential Issuance (openid4vci)
- OpenID for Verifiable Presentations (openid4vp)
- Each package exports classes and functions to be embedded in Node, browser or React Native apps.

##### File structure
- Root
- pnpm-workspace.yaml, package.json, tsconfig.json, Vite config, CI workflows
- .changeset folder—release notes for changeset-based versioning
- /packages
- /oauth2 — RFC-compliant OAuth 2.0 framework (AuthorizationServer, ResourceServer, Oauth2Client)
- /openid4vci — credential-issuance client + issuer flows, built atop OAuth 2.0
- /openid4vp — presentation request + response client + verifier, independent flows
- /utils — shared helpers (fetcher, error types, parsing, validation)
- Each package follows the same pattern: src/, __tests__/, tsconfig.json, package.json.

##### Insights from the README
- oauth2 implements core OAuth 2.0 RFCs (PKCE, DPoP, token introspection, pushed requests).
- openid4vci depends on oauth2 + utils to run the OpenID issuance flows.
- openid4vp depends on utils to perform the OpenID presentation flows (JAR, JARM, direct_post, dc_api).
- All packages are environment-agnostic: users provide fetch, crypto, random callbacks.

##### Summary
- External entities (Wallet, Issuer, Verifier, AuthZ Server) around the modules to show integration points
1) Shows internal module dependencies and
2) Illustrates the end-to-end data flows for each supported protocol

## Diagram (Mermaid)

```mermaid
graph TD
    %% Layers
    subgraph "Utilities Layer"
        Utils["Utils Library"]:::utilsLayer
    end

    subgraph "Protocol Core (OAuth2)"
        AuthServer["Authorization Server"]:::core
        ResourceServer["Resource Server"]:::core
        OAuth2Client["OAuth2 Client"]:::core
    end

    subgraph "Protocol Extensions"
        subgraph "OpenID4VC Issuance"
            VCIssuer["Openid4vci Issuer"]:::issuance
            VCClient["Openid4vci Client"]:::issuance
            WalletProv["Wallet Provider"]:::issuance
        end
        subgraph "OpenID4VP Presentation"
            VPVerifier["Openid4vp Verifier"]:::presentation
            VPClient["Openid4vp Client"]:::presentation
        end
    end

    %% External Entities
    ExtAuthZ["Identity Provider/Authorization Server"]:::external
    ExtIssuerService["Credential Issuer Service"]:::external
    ExtWallet["Verifiable Credential Wallet"]:::external
    ExtVerifier["Verifier Service / Relying Party"]:::external

    %% Dependencies
    Utils --> AuthServer
    Utils --> ResourceServer
    Utils --> OAuth2Client
    Utils --> VCIssuer
    Utils --> VCClient
    Utils --> WalletProv
    Utils --> VPVerifier
    Utils --> VPClient

    OAuth2Client --> ExtAuthZ
    OAuth2Client --> ResourceServer

    %% Issuance Flows
    VCClient --> AuthServer
    VCClient --> ExtIssuerService
    VCClient --> VCIssuer
    VCIssuer --> ExtIssuerService

    %% Presentation Flows
    ExtVerifier --> VPVerifier
    VPVerifier --> VPClient
    VPClient --> ExtVerifier

    %% Click Events
    click Utils "https://github.com/openwallet-foundation-labs/oid4vc-ts/tree/main/packages/utils/src"
    click AuthServer "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/oauth2/src/Oauth2AuthorizationServer.ts"
    click ResourceServer "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/oauth2/src/Oauth2ResourceServer.ts"
    click OAuth2Client "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/oauth2/src/Oauth2Client.ts"
    click VCIssuer "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/openid4vci/src/Openid4vciIssuer.ts"
    click VCClient "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/openid4vci/src/Openid4vciClient.ts"
    click WalletProv "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/openid4vci/src/Openid4vciWalletProvider.ts"
    click VPVerifier "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/openid4vp/src/Openid4vpVerifier.ts"
    click VPClient "https://github.com/openwallet-foundation-labs/oid4vc-ts/blob/main/packages/openid4vp/src/Openid4vpClient.ts"

    %% Styles
    classDef utilsLayer fill:#BBDEFB,stroke:#000
    classDef core fill:#C8E6C9,stroke:#000
    classDef issuance fill:#FFE0B2,stroke:#000
    classDef presentation fill:#D1C4E9,stroke:#000
    classDef external fill:#CFD8DC,stroke:#000
```
