# sigil-wen/visioncraft architecture

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

- Interactive diagram: https://gitdiagram.com/sigil-wen/visioncraft
- Repository: https://github.com/sigil-wen/visioncraft

## Overview

##### Main Components
- Application Core – This is centered on the VisionCraftApp (the entry point) and the Xcode project (VisionCraft.xcodeproj) that orchestrates the build and deployment.
- UI/Presentation Layer – Components such as ContentView.swift and ImmersiveView.swift represent the user interface. They are responsible for rendering the app’s visuals and managing user interactions.
- Game Model Layer – The VisionCraftWorldModel.swift holds the game’s world state or logic that drives the Minecraft clone gameplay.
- Reality and Immersive Content – The Packages/RealityKitContent folder, which contains RealityKit assets and supporting Swift code, represents a dedicated module for immersive 3D content. This package encapsulates assets (like .rkassets files) and likely contains configuration for RealityKit scenes.
- Assets & Resources – Folders like VisionCraft/Assets.xcassets and various media (images, usdz, scn files) provide the graphical resources used by both the UI and immersive engine.

##### Relationships and Interactions
- The VisionCraftApp (entry point) initializes the main UI (ContentView) and sets up the environment.
- ContentView connects with ImmersiveView to trigger the immersive experience when necessary.
- The ImmersiveView leverages RealityKitContent assets from the dedicated package to render the 3D world.
- VisionCraftWorldModel acts as the underlying game state manager, feeding data and state changes into the UI components.
- Build scripts and Xcode configurations (found in VisionCraft.xcodeproj) tie all these modules together.

##### Architectural Patterns and Technologies
- There is a clear separation of concerns—dividing the project into a UI layer (SwiftUI-based), Game/World logic, and an immersive content module (RealityKit package). This could follow an MVVM (Model-View-ViewModel) style where the WorldModel is the “model,” the views are in ContentView/ImmersiveView, and app-specific logic might be distributed as needed.
- Use of Swift Packages, especially for the RealityKitContent, suggests a modular design for handling immersive 3D assets.
- The project leverages Apple’s native frameworks: SwiftUI for the UI, RealityKit for immersive content, and possibly SceneKit given the presence of a .scn file.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Core
    subgraph "Application Core"
        A1["VisionCraftApp – Entry Point"]:::core
        A2["VisionCraft.xcodeproj – Project Config"]:::core
    end

    %% UI / Presentation Layer
    subgraph "UI / Presentation Layer"
        U1["ContentView – UI"]:::ui
        U2["ImmersiveView – AR/VR Renderer"]:::ui
    end

    %% Game Model Layer
    subgraph "Game Model Layer"
        G1["VisionCraftWorldModel – Game Logic"]:::gamelogic
    end

    %% Reality & Immersive Content Module
    subgraph "Reality & Immersive Content Module"
        R1["RealityKitContent – Immersive Assets"]:::immersive
    end

    %% Assets & Resources
    subgraph "Assets & Resources"
        AR1["Assets.xcassets & Media"]:::assets
    end

    %% External Dependency: Apple Frameworks
    E1["Apple Frameworks (SwiftUI,RealityKit,SceneKit)"]:::external

    %% Connections
    A1 -->|"initializes"| U1
    A1 -->|"launches"| U2
    A1 --> A2
    G1 -->|"updates"| U1
    U2 -->|"requestsAssets"| R1
    AR1 -->|"providesAssets"| U1
    AR1 -->|"providesAssets"| U2
    AR1 -->|"providesAssets"| R1
    A1 ---|"uses"| E1

    %% Click Events
    click A1 "https://github.com/sigil-wen/visioncraft/blob/main/VisionCraft/VisionCraftApp.swift"
    click A2 "https://github.com/sigil-wen/visioncraft/blob/main/VisionCraft.xcodeproj"
    click U1 "https://github.com/sigil-wen/visioncraft/blob/main/VisionCraft/ContentView.swift"
    click U2 "https://github.com/sigil-wen/visioncraft/blob/main/VisionCraft/ImmersiveView.swift"
    click G1 "https://github.com/sigil-wen/visioncraft/blob/main/VisionCraft/VisionCraftWorldModel.swift"
    click R1 "https://github.com/sigil-wen/visioncraft/tree/main/Packages/RealityKitContent"
    click AR1 "https://github.com/sigil-wen/visioncraft/blob/main/VisionCraft/Assets.xcassets"

    %% Styles
    classDef core fill:#f9d6bd,stroke:#cc3300,stroke-width:2px;
    classDef ui fill:#cfe2f3,stroke:#0066cc,stroke-width:2px;
    classDef gamelogic fill:#e2efda,stroke:#228B22,stroke-width:2px;
    classDef immersive fill:#ead1dc,stroke:#993366,stroke-width:2px;
    classDef assets fill:#ffe599,stroke:#b8860b,stroke-width:2px;
    classDef external fill:#f4cccc,stroke:#ea9999,stroke-width:2px;
```
