# readyplayerme/rpm-react-avatar-creator architecture

> Architecture diagram of the GitHub repository readyplayerme/rpm-react-avatar-creator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/readyplayerme/rpm-react-avatar-creator
- Repository: https://github.com/readyplayerme/rpm-react-avatar-creator

## Overview

This React library embeds Ready Player Me’s avatar editor in an iframe and delivers its events to the host application. The main path is a host rendering AvatarCreator, which delegates to the raw iframe component; that component builds the editor URL, subscribes to iframe events, and forwards them through typed callbacks. The raw component also supports a single custom event callback. The event contracts are shown individually; source excerpts do not establish further behavior for them.

Main entry points: [`src/components/avatar-creator-raw.tsx`](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/components/avatar-creator-raw.tsx) (AvatarCreatorRaw), [`src/events/index.ts`](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/index.ts) (Event union), [`src/components/avatar-creator.tsx`](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/components/avatar-creator.tsx) (AvatarCreator), [`src/types.ts`](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/types.ts) (Shared event types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_components["React components"]
  node_avatar_creator["AvatarCreator<br/>[avatar-creator.tsx]"]
  node_raw_creator["AvatarCreatorRaw"]
end

subgraph group_url["Editor URL"]
  node_url_hook["URL hook"]
end

subgraph group_events["Event contracts"]
  node_event_union["Event union<br/>[index.ts]"]
  node_asset_event["Asset unlocked"]
  node_export_event["Avatar exported"]
  node_authorized_event["User authorized"]
  node_user_set_event["User set<br/>[user-set.event.ts]"]
end

subgraph group_support["Parsing and API"]
  node_parser["JSON parser<br/>[utils.ts]"]
  node_types["Shared event types<br/>[types.ts]"]
  node_public_api["Public exports<br/>[index.tsx]"]
end

node_host(("Host application"))
node_rpm_editor["Ready Player Me editor"]

node_host -->|"renders"| node_avatar_creator
node_avatar_creator -->|"renders"| node_raw_creator
node_avatar_creator -->|"calls callbacks"| node_host
node_raw_creator -->|"builds URL"| node_url_hook
node_raw_creator -->|"parses messages"| node_parser
node_raw_creator -->|"embeds iframe"| node_rpm_editor
node_rpm_editor -->|"posts events"| node_raw_creator
node_raw_creator -->|"forwards events"| node_event_union
node_avatar_creator -->|"routes events"| node_event_union
node_event_union -->|"includes type"| node_asset_event
node_event_union -->|"includes type"| node_export_event
node_event_union -->|"includes type"| node_authorized_event
node_event_union -->|"includes type"| node_user_set_event
node_asset_event -->|"uses event shape"| node_types
node_export_event -->|"uses event shape"| node_types
node_authorized_event -->|"uses event shape"| node_types
node_user_set_event -->|"uses event shape"| node_types
node_public_api -->|"exports"| node_avatar_creator

click node_avatar_creator "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/components/avatar-creator.tsx"
click node_raw_creator "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/components/avatar-creator-raw.tsx"
click node_url_hook "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/hooks/use-avatar-creator-url.ts"
click node_parser "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/utils.ts"
click node_event_union "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/index.ts"
click node_asset_event "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/asset-unlocked.event.ts"
click node_export_event "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/avatar-exported.event.ts"
click node_authorized_event "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/user-authorized.event.ts"
click node_user_set_event "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/user-set.event.ts"
click node_types "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/types.ts"
click node_public_api "https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/index.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_avatar_creator,node_raw_creator toneBlue
class node_url_hook toneAmber
class node_event_union,node_asset_event,node_export_event,node_authorized_event,node_user_set_event toneMint
class node_parser,node_types,node_public_api toneRose
class node_host,node_rpm_editor toneIndigo
```

## Components

### React components

- [AvatarCreator](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/components/avatar-creator.tsx): `src/components/avatar-creator.tsx`
- [AvatarCreatorRaw](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/components/avatar-creator-raw.tsx): `src/components/avatar-creator-raw.tsx`

### Editor URL

- [URL hook](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/hooks/use-avatar-creator-url.ts): `src/hooks/use-avatar-creator-url.ts`

### Event contracts

- [Event union](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/index.ts): `src/events/index.ts`
- [Asset unlocked](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/asset-unlocked.event.ts): `src/events/asset-unlocked.event.ts`
- [Avatar exported](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/avatar-exported.event.ts): `src/events/avatar-exported.event.ts`
- [User authorized](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/user-authorized.event.ts): `src/events/user-authorized.event.ts`
- [User set](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/events/user-set.event.ts): `src/events/user-set.event.ts`

### Parsing and API

- [JSON parser](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/utils.ts): `src/utils.ts`
- [Shared event types](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/types.ts): `src/types.ts`
- [Public exports](https://github.com/readyplayerme/rpm-react-avatar-creator/blob/master/src/index.tsx): `src/index.tsx`

### Other components

- **Host application**
- **Ready Player Me editor**

## Connections

- Host application → AvatarCreator: renders (evidence: `README.md`)
- AvatarCreator → AvatarCreatorRaw: renders (evidence: `src/components/avatar-creator.tsx`)
- AvatarCreator → Host application: calls callbacks (evidence: `src/components/avatar-creator.tsx`)
- AvatarCreatorRaw → URL hook: builds URL (evidence: `src/components/avatar-creator-raw.tsx`)
- AvatarCreatorRaw → JSON parser: parses messages (evidence: `src/components/avatar-creator-raw.tsx`)
- AvatarCreatorRaw → Ready Player Me editor: embeds iframe (evidence: `src/components/avatar-creator-raw.tsx`)
- Ready Player Me editor → AvatarCreatorRaw: posts events (evidence: `src/components/avatar-creator-raw.tsx`)
- AvatarCreatorRaw → Event union: forwards events (evidence: `src/components/avatar-creator-raw.tsx`)
- AvatarCreator → Event union: routes events (evidence: `src/components/avatar-creator.tsx`)
- Event union → Asset unlocked: includes type (evidence: `src/events/index.ts`)
- Event union → Avatar exported: includes type (evidence: `src/events/index.ts`)
- Event union → User authorized: includes type (evidence: `src/events/index.ts`)
- Event union → User set: includes type (evidence: `src/events/index.ts`)
- Asset unlocked → Shared event types: uses event shape (evidence: `src/events/asset-unlocked.event.ts`)
- Avatar exported → Shared event types: uses event shape (evidence: `src/events/avatar-exported.event.ts`)
- User authorized → Shared event types: uses event shape (evidence: `src/events/user-authorized.event.ts`)
- User set → Shared event types: uses event shape (evidence: `src/events/user-set.event.ts`)
- Public exports → AvatarCreator: exports (evidence: `src/index.tsx`)
