# brucedeity/pwhexparser architecture

> Architecture diagram of the GitHub repository brucedeity/pwhexparser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brucedeity/pwhexparser
- Repository: https://github.com/brucedeity/pwhexparser

## Overview

pwhexparser is a PHP library that turns Perfect World hexadecimal item data into structured arrays, with optional mask-based type selection and field translation. The principal workflow is to configure a Decoder with a type or mask and hex string, validate and decode using that type’s field structure, then return decoded data or a translated view. The graph reflects documented features and sampled calls; unsampled item-type implementations are represented by their existing directory, and no web service or persistent store is evidenced.

Main entry points: [`app/Decoder.php`](https://github.com/brucedeity/pwhexparser/blob/main/app/Decoder.php) (Decoder), [`app/Types`](https://github.com/brucedeity/pwhexparser/tree/main/app/Types) (Item structures), [`app/Contracts/Translate.php`](https://github.com/brucedeity/pwhexparser/blob/main/app/Contracts/Translate.php) (Translation base), [`app/Types/Weapon.php`](https://github.com/brucedeity/pwhexparser/blob/main/app/Types/Weapon.php) (Weapon structure)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Decode API"]
  node_decoder["Decoder<br/>[Decoder.php]"]
  node_result["Decoded array"]
  node_translated["Translated fields"]
end

subgraph group_catalog["Type Catalog"]
  node_item_types["Item structures"]
  node_weapon["Weapon structure<br/>[Weapon.php]"]
  node_jewelry["Jewelry structure<br/>[Jewelry.php]"]
  node_property["Role properties<br/>[Property.php]"]
end

subgraph group_support["Decode Support"]
  node_mask["Mask mapping<br/>[Mask.php]"]
  node_item_contract["Item contract<br/>[Item.php]"]
end

subgraph group_locale["Translations"]
  node_translator["Translation base<br/>[Translate.php]"]
  node_lang_files["Portuguese labels"]
end

node_user(("Library caller"))

node_user -->|"configures and invokes"| node_decoder
node_decoder -->|"guesses type via"| node_mask
node_decoder -->|"selects type from"| node_item_types
node_decoder -->|"reads structure"| node_weapon
node_decoder -->|"reads structure"| node_jewelry
node_decoder -->|"reads structure"| node_property
node_item_types -->|"implements"| node_item_contract
node_decoder -->|"returns decoded data"| node_result
node_decoder -->|"uses for translation"| node_translator
node_translator -->|"loads labels"| node_lang_files
node_decoder -->|"returns translated data"| node_translated
node_user -->|"receives"| node_result

click node_decoder "https://github.com/brucedeity/pwhexparser/blob/main/app/Decoder.php"
click node_mask "https://github.com/brucedeity/pwhexparser/blob/main/app/Mask.php"
click node_item_types "https://github.com/brucedeity/pwhexparser/tree/main/app/Types"
click node_weapon "https://github.com/brucedeity/pwhexparser/blob/main/app/Types/Weapon.php"
click node_jewelry "https://github.com/brucedeity/pwhexparser/blob/main/app/Types/Jewelry.php"
click node_property "https://github.com/brucedeity/pwhexparser/blob/main/app/Types/Property.php"
click node_item_contract "https://github.com/brucedeity/pwhexparser/blob/main/app/Contracts/Item.php"
click node_translator "https://github.com/brucedeity/pwhexparser/blob/main/app/Contracts/Translate.php"
click node_lang_files "https://github.com/brucedeity/pwhexparser/tree/main/lang/pt-BR"

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_decoder,node_result,node_translated toneBlue
class node_item_types,node_weapon,node_jewelry,node_property toneAmber
class node_mask,node_item_contract toneMint
class node_translator,node_lang_files toneRose
class node_user toneIndigo
```

## Components

### Decode API

- [Decoder](https://github.com/brucedeity/pwhexparser/blob/main/app/Decoder.php): `app/Decoder.php`
- **Decoded array**
- **Translated fields**

### Type Catalog

- [Item structures](https://github.com/brucedeity/pwhexparser/tree/main/app/Types): `app/Types`
- [Weapon structure](https://github.com/brucedeity/pwhexparser/blob/main/app/Types/Weapon.php): `app/Types/Weapon.php`
- [Jewelry structure](https://github.com/brucedeity/pwhexparser/blob/main/app/Types/Jewelry.php): `app/Types/Jewelry.php`
- [Role properties](https://github.com/brucedeity/pwhexparser/blob/main/app/Types/Property.php): `app/Types/Property.php`

### Decode Support

- [Mask mapping](https://github.com/brucedeity/pwhexparser/blob/main/app/Mask.php): `app/Mask.php`
- [Item contract](https://github.com/brucedeity/pwhexparser/blob/main/app/Contracts/Item.php): `app/Contracts/Item.php`

### Translations

- [Translation base](https://github.com/brucedeity/pwhexparser/blob/main/app/Contracts/Translate.php): `app/Contracts/Translate.php`
- [Portuguese labels](https://github.com/brucedeity/pwhexparser/tree/main/lang/pt-BR): `lang/pt-BR`

### Other components

- **Library caller**

## Connections

- Library caller → Decoder: configures and invokes
- Decoder → Mask mapping: guesses type via
- Decoder → Item structures: selects type from
- Decoder → Weapon structure: reads structure
- Decoder → Jewelry structure: reads structure
- Decoder → Role properties: reads structure
- Item structures → Item contract: implements
- Decoder → Decoded array: returns decoded data
- Decoder → Translation base: uses for translation
- Translation base → Portuguese labels: loads labels
- Decoder → Translated fields: returns translated data
- Library caller → Decoded array: receives
