# sketchfab/blender-plugin architecture

> Architecture diagram of the GitHub repository sketchfab/blender-plugin, 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/sketchfab/blender-plugin
- Repository: https://github.com/sketchfab/blender-plugin

## Overview

##### Main Components

a. Client-side Components:
- Blender Application
- Sketchfab Addon UI (Properties Panel)
- Authentication Module
- Import Pipeline
- Export Pipeline
- Local Storage System

b. External Services:
- Sketchfab API
- Sketchfab Platform
- Sketchfab Organization/Teams API (for team features)

##### Authentication Flow
- Connection between Addon → Sketchfab API for both email/password and API token authentication
- Local credential storage for session management

##### Import Pipeline
- Search/Browse Flow: Addon UI → Sketchfab API → Model Discovery
- Download Flow: Selected Model → Local Storage → Blender Scene
- Format conversion (glTF → Blender)

##### Export Pipeline
- Material/Scene Processing: Blender Scene → glTF Conversion
- Upload Flow: Processed Data → Sketchfab API
- Settings Flow: Export Options → Model Properties on Sketchfab

Use these visual elements:

- Use rectangles for main components

Specific Implementation Details to Include:

##### Local Components
- Temporary file storage for downloads
- CSV history tracking
- Local credential cache
- Material conversion system

##### External Interfaces
- Sketchfab REST API endpoints
- Authentication endpoints
- Model processing service

##### Error Handling
- Validation points for material compatibility
- Scale/transformation checkpoints
- Texture processing limitations

##### Processing Stages
- Material conversion pipeline
- Animation processing
- Texture handling

##### Configuration Points
- User preferences storage
- Download directory settings
- Search filters

Level of Detail:

##### Import/Export Conversion Process

- Top Layer: User Interface and Blender Integration
- Middle Layer: Core Processing and Conversion Logic
- Bottom Layer: API Communication and Storage

- Symbols used for different components
- Indicators for known limitation points

This will create a comprehensive visualization of how the addon integrates with both Blender and Sketchfab while handling various data transformations and user interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        BL[Blender Application]
        UI[Sketchfab Addon UI]:::ui
        click UI "https://github.com/sketchfab/blender-plugin/blob/master/__init__.py"
    end

    subgraph "Core Processing Layer"
        Auth[Authentication Module]
        Import[Import Pipeline]
        Export[Export Pipeline]:::export
        click Export "https://github.com/sketchfab/blender-plugin/blob/master/pack_for_export.py"
        MatConv[Material Conversion]
        AnimProc[Animation Processing]
        TexHandle[Texture Handler]
    end

    subgraph "Storage Layer"
        LocalStore[(Local Storage)]
        TempFiles[(Temporary Files)]
        CredCache[(Credential Cache)]
        CSV[(CSV History)]
    end

    subgraph "External Services"
        SketchAPI["Sketchfab API"]
        SketchPlat["Sketchfab Platform"]
        OrgAPI["Organization API"]
    end

    %% Authentication Flows
    Auth -->|"Authenticate"| SketchAPI
    Auth -->|"Cache"| CredCache
    UI -->|"Login"| Auth

    %% Import Flows
    UI -->|"Search"| Import
    Import -->|"Query"| SketchAPI
    Import -->|"Download"| TempFiles
    Import -->|"Convert"| MatConv
    MatConv -->|"Process"| BL
    Import -->|"Track"| CSV

    %% Export Flows
    BL -->|"Export"| Export
    Export -->|"Convert"| MatConv
    Export -->|"Process"| AnimProc
    Export -->|"Handle"| TexHandle
    Export -->|"Upload"| SketchAPI
    Export -->|"Track"| CSV

    %% Storage Flows
    LocalStore -->|"Load"| Import
    Export -->|"Save"| LocalStore

    %% Organization Access
    SketchAPI -.->|"Team Access"| OrgAPI
    SketchAPI -->|"Models"| SketchPlat

    classDef ui fill:#f9f,stroke:#333
    classDef export fill:#bfb,stroke:#333
    classDef storage fill:#ff9,stroke:#333
    classDef api fill:#9cf,stroke:#333

    %% Legend
    subgraph Legend
        L1[UI Components]:::ui
        L2[Export Components]:::export
        L3[(Storage)]:::storage
        L4[API Services]:::api
    end
```
