# shiroyashik/sculptor architecture

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

- Interactive diagram: https://gitdiagram.com/shiroyashik/sculptor
- Repository: https://github.com/shiroyashik/sculptor

## Overview

##### Project Context
- This project is an unofficial backend for the Minecraft mod “Figura,” implemented in Rust.
- It provides game-related services (such as player data and real-time communication via WebSocket) and integrates third‐party authentication (Mojang/Microsoft and Ely.By) for player identification.
- Deployment is containerized (Docker, docker-compose) and expects a reverse proxy that supports WebSockets (e.g., using Traefik or NGINX).

##### Main Components from the File Tree & README
- API Layer: Located under src/api, it is divided into submodules:
– "figura": Contains the primary endpoints, assets handling, profile management, and error management.
– "sculptor": Provides additional endpoints related to avatars, HTTP2ws conversion, and user management.
- WebSocket Handling: Under src/api/figura/websocket, you have modules for handling real-time communication (handler, session, and message types between client to server and vice versa).
- Authentication: The src/auth directory has its own modules for processing authentication logic and types.
- Core State & Configuration: The “state” module (src/state) holds configuration handling and state management logic.
- Utilities & Metrics: Additional utility functions (src/utils) aid with auxiliary tasks, update checks, and message-of-the-day (motd). Metrics logging seems to be centralized in src/metrics.
- Deployment & Infrastructure:
– The Dockerfile and docker-compose.example.yml indicate containerization.
– Configuration is controlled via a Config.toml (template provided as Config.example.toml), and a reverse proxy is needed to support WebSocket connections.
- Build & CI/CD: The GitHub workflows (in .github/workflows) and Cargo files hint at automated builds/testing, emphasizing continuous integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients and Deployment
    Client("Client"):::client
    ReverseProxy("Reverse Proxy (Traefik/NGINX)"):::reverseproxy
    CI("CI/CD (GitHub Actions)"):::ci

    %% Deployment & Config Subgraph
    subgraph "Deployment & Config"
        DockerSetup("Docker Setup"):::config
        ConfigTemplate("Configuration Template"):::config
    end

    %% Docker Container hosting the Rust Application
    subgraph "Docker Container"
        direction TB
        subgraph "Rust Application"
            Figura("Figura API"):::api
            Sculptor("Sculptor API"):::api
            WebSocket("WebSocket Handler"):::websocket
            Auth("Authentication Service"):::auth
            State("State/Configuration Manager"):::state
            Utils("Utilities"):::utils
            Metrics("Metrics"):::metrics
        end
    end

    %% External Authentication Providers
    subgraph "External Authentication Providers"
        Mojang("Mojang/Microsoft"):::external
        Ely("Ely.By"):::external
    end

    %% Connections from Client to Reverse Proxy and through to Docker Container
    Client -->|"HTTP/WebSocket"| ReverseProxy
    ReverseProxy --> Docker
    DockerSetup --> Docker
    CI -->|"deploys"| DockerSetup
    ConfigTemplate -->|"provides config"| State

    %% Internal Interactions within the Docker Container (Rust Application)
    Docker --> Figura
    Docker --> Sculptor
    Docker --> WebSocket
    Docker --> Auth
    Docker --> State
    Docker --> Utils
    Docker --> Metrics

    Figura -->|"uses"| WebSocket
    Figura -->|"reads"| State
    Sculptor -->|"reads"| State
    Figura -->|"authcalls"| Auth
    Sculptor -->|"authcalls"| Auth
    Auth -->|"verifies"| Mojang
    Auth -->|"verifies"| Ely
    Utils -->|"reportsTo"| Metrics

    %% CI/CD interaction (optional)
    CI -->|"builds"| Docker

    %% Click Events
    click Figura "https://github.com/shiroyashik/sculptor/tree/master/src/api/figura"
    click Sculptor "https://github.com/shiroyashik/sculptor/tree/master/src/api/sculptor"
    click WebSocket "https://github.com/shiroyashik/sculptor/tree/master/src/api/figura/websocket"
    click Auth "https://github.com/shiroyashik/sculptor/tree/master/src/auth"
    click State "https://github.com/shiroyashik/sculptor/tree/master/src/state"
    click Utils "https://github.com/shiroyashik/sculptor/tree/master/src/utils"
    click Metrics "https://github.com/shiroyashik/sculptor/blob/master/src/metrics.rs"
    click DockerSetup "https://github.com/shiroyashik/sculptor/tree/master/Dockerfile"
    click ConfigTemplate "https://github.com/shiroyashik/sculptor/blob/master/Config.example.toml"
    click CI "https://github.com/shiroyashik/sculptor/tree/master/.github/workflows"

    %% Styles
    classDef client fill:#ccebff,stroke:#333,stroke-width:2px;
    classDef reverseproxy fill:#cccccc,stroke:#333,stroke-width:2px;
    classDef docker fill:#f2f2f2,stroke:#333,stroke-width:2px;
    classDef api fill:#b3cde0,stroke:#000,stroke-width:1px;
    classDef auth fill:#fff2cc,stroke:#000,stroke-width:1px;
    classDef state fill:#d9e1f2,stroke:#000,stroke-width:1px;
    classDef utils fill:#e2d0f3,stroke:#000,stroke-width:1px;
    classDef metrics fill:#f4cccc,stroke:#000,stroke-width:1px;
    classDef websocket fill:#b3d9b3,stroke:#000,stroke-width:1px;
    classDef external fill:#f4cccc,stroke:#000,stroke-width:1px;
    classDef ci fill:#ffe599,stroke:#000,stroke-width:1px;
    classDef config fill:#d9ead3,stroke:#000,stroke-width:1px;
```
