# pixelicc/mowojang-js architecture

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

- Interactive diagram: https://gitdiagram.com/pixelicc/mowojang-js
- Repository: https://github.com/pixelicc/mowojang-js

## Overview

##### Main Components

a) Client Layer:
- MowojangClient class as the main entry point
- Core client methods (getProfiles, getUUID, etc.)

b) Network Layer:
- Axios instance with caching interceptor
- Connection to the external Mowojang API

c) Utility Layers:
- UUID manipulation utilities
- Validation services
- Type definitions

##### Core Architecture
- Use a layered architecture approach with clear separation of concerns
- Axios instance as a middleware layer
- Utilities and validators as supporting services

##### Component Relationships

**[Client Interface Layer]**
- ↓
**[Axios Instance Layer]**
- ↓
**[External Mowojang API]**

**[Supporting Services]**
- UUID Utils
- Validators
- Type Definitions

##### Specific Implementation Details

- Rectangle: Main components (Client, Axios Instance)
- Hexagon: External API
- Rounded Rectangle: Utility services
- Blue: Core components
- Green: External services
- Gray: Utility functions

##### Important Features to Highlight
- Custom caching mechanism
- Type safety (TypeScript implementation)
- Input validation flow
- Image buffer handling for skins/capes

**[Client Layer]**
- getProfiles()
- getUUID()
- getUsername()
- getSkin()
- getCape()
- ↓
**[Axios Instance]**
- Cache Interceptor
- Request/Response Handling
- ↓
**[Mowojang API]**
- External Service

**[Utilities]          [Validators]**
- dashUUID()         - UUID()
- undashUUID()       - username()
- player()

Additional Considerations:

##### Cache Flow
- A cache component showing the configurable caching mechanism

##### Type System
- Type definitions integration
- TypeScript interfaces

##### Error Handling
- Error propagation paths
- Validation failure flows

This structure accurately represents the library's purpose as a type-safe API wrapper with built-in caching, validation, and utility functions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        MC[MowojangClient]
        MC --> |getProfiles| M1["Method: getProfiles()"]
        MC --> |getUUID| M2["Method: getUUID()"]
        MC --> |getUsername| M3["Method: getUsername()"]
        MC --> |getSkin| M4["Method: getSkin()"]
        MC --> |getCape| M5["Method: getCape()"]
    end

    subgraph Network
        AX[Axios Instance]
        CI[Cache Interceptor]
        AX --> CI
    end

    subgraph "External API"
        API[Mowojang API]
    end

    subgraph "Type System"
        TD1[Main Types]
        TD2[Player Types]
        TD3[Structure Types]
        TD4[Misc Types]
    end

    subgraph "Utility Services"
        UV1[UUID Utils]
        UV2[Validators]
    end

    MC --> AX
    AX --> API
    UV1 --> MC
    UV2 --> MC
    TD1 --> MC
    TD2 --> MC
    TD3 --> MC
    TD4 --> MC

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef client fill:#d4e6f1,stroke:#2874a6
    classDef network fill:#d5f5e3,stroke:#196f3d
    classDef external fill:#fadbd8,stroke:#943126
    classDef utils fill:#fdebd0,stroke:#b9770e
    classDef types fill:#ebdef0,stroke:#6c3483

    class MC,M1,M2,M3,M4,M5 client
    class AX,CI network
    class API external
    class UV1,UV2 utils
    class TD1,TD2,TD3,TD4 types

    click MC "https://github.com/pixelicc/mowojang-js/blob/main/src/client.ts"
    click AX "https://github.com/pixelicc/mowojang-js/blob/main/src/axiosInstance.ts"
    click UV1 "https://github.com/pixelicc/mowojang-js/blob/main/src/utils.ts"
    click UV2 "https://github.com/pixelicc/mowojang-js/blob/main/src/validators.ts"
    click TD1 "https://github.com/pixelicc/mowojang-js/blob/main/types/index.d.ts"
    click TD2 "https://github.com/pixelicc/mowojang-js/blob/main/types/player.d.ts"
    click TD3 "https://github.com/pixelicc/mowojang-js/blob/main/types/structures.d.ts"
    click TD4 "https://github.com/pixelicc/mowojang-js/blob/main/types/misc.d.ts"
    click CI "https://github.com/pixelicc/mowojang-js/blob/main/docs/custom-caching.md"
```
