# towsifkafi/mcpfp architecture

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

- Interactive diagram: https://gitdiagram.com/towsifkafi/mcpfp
- Repository: https://github.com/towsifkafi/mcpfp

## Overview

##### Main Components

A. Client Layer:
- Web Frontend (SvelteKit application)
- External API Consumers

B. API Server Layer:
- Hono Framework running on Bun Runtime
- Profile Picture Generation Service
- Asset Management System

C. External Services:
- Minecraft Skin API (for fetching player skins)

##### Key Architectural Elements

**[Client Tier]**
- ↓ ↑
**[API Server Tier]**
- ↓ ↑
**[External Services Tier]**

##### Detailed Component Breakdown

Frontend (web/):
- SvelteKit Runtime
- Static Assets
- Route Handler

API Server (api/):
- Profile Generator Service (src/rendering/generateProfile.ts)
- Skin Fetcher Service (src/rendering/getSkin.ts)
- Gradient Generator (src/rendering/gradient.ts)
- URL Validator (src/utils/checkURL.ts)

Asset Management:
- Cosmetics Storage (api/assets/cosmetics)
- Overlay Storage (api/assets/overlays)

##### Data Flow Representation

- Client requests → API Server
- API Server → Minecraft Skin API
- Internal flow between components:
1. URL Validation
2. Skin Fetching
3. Profile Generation
4. Asset Application
5. Response Delivery

##### Technology Stack Indicators

Technology badges or labels for:
- Bun Runtime
- Hono Framework
- @napi-rs/canvas
- SvelteKit
- Docker

##### Additional Elements

A section showing:
- Docker container boundary
- Load balancing capability (indicated by pm2 config)
- Asset pipeline flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        WF["Web Frontend (SvelteKit)"]
        EAC["External API Consumers"]
        FU["Frontend Utils"]
        FL["Frontend Layout"]
    end

    subgraph APIServer
        HF["Hono Framework (Bun)"]
        PG["Profile Generator"]
        SF["Skin Fetcher"]
        GG["Gradient Generator"]
        UV["URL Validator"]
    end

    subgraph AssetManagement
        CS["Cosmetics Storage"]
        OS["Overlays Storage"]
    end

    subgraph Infrastructure
        DC["Docker Container"]
        PM["PM2 Process Manager"]
        LT["Load Testing"]
    end

    subgraph ExternalServices
        MSA["Minecraft Skin API"]
    end

    %% Relationships
    WF --> HF
    EAC --> HF
    HF --> UV
    UV --> SF
    SF --> MSA
    SF --> PG
    PG --> GG
    CS --> PG
    OS --> PG
    DC --> APIServer
    PM --> DC
    LT --> HF

    %% Click Events
    click WF "https://github.com/towsifkafi/mcpfp/blob/rewrite/web/src/routes/+page.svelte"
    click FU "https://github.com/towsifkafi/mcpfp/blob/rewrite/web/src/lib/scripts/utils.ts"
    click FL "https://github.com/towsifkafi/mcpfp/blob/rewrite/web/src/routes/+layout.js"
    click HF "https://github.com/towsifkafi/mcpfp/blob/rewrite/api/src/index.ts"
    click PG "https://github.com/towsifkafi/mcpfp/blob/rewrite/api/src/rendering/generateProfile.ts"
    click SF "https://github.com/towsifkafi/mcpfp/blob/rewrite/api/src/rendering/getSkin.ts"
    click GG "https://github.com/towsifkafi/mcpfp/blob/rewrite/api/src/rendering/gradient.ts"
    click UV "https://github.com/towsifkafi/mcpfp/blob/rewrite/api/src/utils/checkURL.ts"
    click CS "https://github.com/towsifkafi/mcpfp/tree/rewrite/api/assets/cosmetics"
    click OS "https://github.com/towsifkafi/mcpfp/tree/rewrite/api/assets/overlays"
    click DC "https://github.com/towsifkafi/mcpfp/tree/rewrite/Dockerfile"
    click PM "https://github.com/towsifkafi/mcpfp/blob/rewrite/pm2.config.js"
    click LT "https://github.com/towsifkafi/mcpfp/blob/rewrite/load-test/api.js"

    %% Styling
    classDef client fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px
    classDef asset fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px

    class WF,EAC,FU,FL client
    class HF,PG,SF,GG,UV api
    class CS,OS asset
    class DC,PM,LT infra
    class MSA external
```
