# davidkingzyb/blenderslot architecture

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

- Interactive diagram: https://gitdiagram.com/davidkingzyb/blenderslot
- Repository: https://github.com/davidkingzyb/blenderslot

## Overview

##### Project type and purpose
- This is a Blender add‑on (a plugin) rather than a traditional front‑end/back‑end web app. Its purpose is to:
- Record user operations in Blender
- Let users name, edit, save, and execute those recorded scripts
- Integrate with an external AI service (Ollama) to generate new scripts

##### File structure
- Top level:
- __init__.py – Blender add‑on registration
- ui.py – UI panels and buttons in the Blender interface
- operators.py – Definitions of custom Blender operators (record, stop, execute, add)
- ollama_op.py – Logic for sending prompts to Ollama and retrieving AI‑generated scripts
- slot/ – Folder holding script management code
– exportFbx.py – A utility operator to export FBX (optional feature)
- No separate “backend” or “frontend” folders because everything lives as part of the Blender process.

##### README for additional insights
- Describes the workflow: name script → record operations → stop → edit → execute → save
- Calls out AI integration via Ollama as an optional “generate script” feature

a. Main components:
1. Blender Host Application (API)
2. BlenderSlot Add‑on
- UI Module (ui.py)
- Operator Module (operators.py)
- Slot Manager (slot/ __init__.py plus any storage mechanism)
- Export Utility (slot/exportFbx.py)
- AI Integration Module (ollama_op.py)
3. External Ollama Service
4. Script Storage (could be in‑memory, on‑disk, or Blender’s Text DataBlocks)
b. Relationships and interactions:
- UI Panel → invokes custom Operators
- Operators talk to Blender API to record or replay actions
- Slot Manager persists recorded scripts and retrieves them for execution
- “Generate with AI” operator calls Ollama service over HTTP/CLI → receives code → sends back to Slot Manager/UI
- Export module can pull Blender scene data and write an FBX file
c. Architectural patterns and principles:
- Modular separation: UI vs. business logic vs. external integration
- Single responsibility: Each operator handles one user action
- Event‑driven: Buttons trigger operators
d. Key technologies:
- Blender Python API
- Ollama CLI/HTTP endpoint
- Python standard library for file I/O

##### Putting it all together
1. UI Module (ui.py) – Blue
2. Operators Module (operators.py) – Green
3. Slot Manager + exportFbx (slot/) – Green
4. AI Integration (ollama_op.py) – Orange
- UI → Operators
- Operators → Blender API
- Operators ↔ Slot Manager → Storage
- AI Integration ↔ Ollama

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Blender Host
    subgraph "Blender Application (Host)"
        direction TB
        Registration["Add‑on Registration (__init__.py)"]
        UI["UI Module (ui.py)"]:::ui
        Operators["Operators Module (operators.py)"]:::core
        subgraph "Slot Manager & Export Utility"
            direction TB
            SlotManager["Slot Manager (slot/__init__.py)"]:::core
            ExportUtility["Export Utility (slot/exportFbx.py)"]:::core
        end
        AIIntegration["AI Integration Module (ollama_op.py)"]:::ext
        BlenderAPI["Blender API"]:::host
    end

    %% External Components
    OllamaService(["Ollama Service"]):::ext
    ScriptStorage[(Script Storage)]:::storage

    %% Connections
    Registration --> UI
    UI -->|"invoke operator"| Operators
    Operators -->|"record/replay actions"| BlenderAPI
    Operators -->|"store/retrieve scripts"| SlotManager
    SlotManager -->|"persist/retrieve scripts"| ScriptStorage
    ExportUtility -->|"pull scene data"| BlenderAPI
    AIIntegration -->|"call generate script"| OllamaService
    OllamaService -->|"return code"| AIIntegration
    AIIntegration -->|"save generated script"| SlotManager

    %% Click Events
    click UI "https://github.com/davidkingzyb/blenderslot/blob/main/ui.py"
    click Operators "https://github.com/davidkingzyb/blenderslot/blob/main/operators.py"
    click AIIntegration "https://github.com/davidkingzyb/blenderslot/blob/main/ollama_op.py"
    click SlotManager "https://github.com/davidkingzyb/blenderslot/blob/main/slot/__init__.py"
    click ExportUtility "https://github.com/davidkingzyb/blenderslot/blob/main/slot/exportFbx.py"
    click Registration "https://github.com/davidkingzyb/blenderslot/blob/main/__init__.py"

    %% Styles
    classDef ui fill:#DAE8FC,stroke:#6C8EBF,color:#000
    classDef core fill:#D5E8D4,stroke:#82B366,color:#000
    classDef ext fill:#F8CECC,stroke:#B85450,color:#000
    classDef host fill:#E1E1E1,stroke:#999999,color:#000
    classDef storage fill:#FFF2CC,stroke:#D6B656,color:#000
```
