BOT-anist
At a glance
| Item | Summary |
|---|---|
| Purpose | Build a multiplatform app that uses windows, volumes, and animations to create a robot botanist’s greenhouse. |
| App architecture | A Swift sample with the source-visible chain BOTanistApp → ContentView → PlantAnimationProvider → RealityKit / SwiftUI APIs. |
| Main patterns | No named application pattern supported by the extracted structure |
| Project style | 30 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
| Execution model | Source-visible boundaries: @MainActor, Task closure isolated to MainActor, Task, Sendable or @Sendable, async declaration or closure; none alone proves a background thread. |
| State/event model | Source-visible mechanisms: @Observable, SwiftUI state property wrapper. |
| Key frameworks/packages | RealityKit, SwiftUI, Foundation, BOTanistAssets, Spatial; these are source dependencies, not architecture labels. |
Project structure
Source bundle/
├── BOT-anist/
│ ├── BOTanistApp.swift
│ ├── Robot/
│ │ └── RobotData.swift
│ ├── Views/
│ │ ├── RobotView.swift
│ │ ├── SelectorViews.swift
│ │ ├── ContentView.swift
│ │ ├── ExplorationView.swift
│ │ ├── OrnamentView.swift
│ │ └── RobotCustomizationView.swift
│ ├── PlantAnimationProvider.swift
│ ├── Components/
│ │ └── JointPinComponent.swift
│ └── Systems/
│ └── JointPinSystem.swift
└── Packages/
└── BOTanistAssets/
└── Sources/
└── BOTanistAssets/
└── Components/
└── PlantComponent.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 4 project/configuration file(s) and 34 source declaration(s).
Overall architecture
flowchart LR
N1["BOTanistApp"]
N2["ContentView"]
N3["PlantAnimationProvider"]
N4["RealityKit / SwiftUI APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
Reference code
BOT-anist/BOTanistApp.swift:15 — architecture anchor
@main
struct BOTanistApp: App {
@Environment(\.dismissWindow) var dismissWindow
// ...
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into visionOS.
Ownership and state
classDiagram
BOTanistApp *-- Logger : logger
BOTanistApp *-- AppState : appState
BOTanistApp *-- Size3D : initialVolumeSize
BOTanistApp *-- CGSize : initialWindowSize
Ownership evidence
BOT-anist/BOTanistApp.swift:13 — stored dependency or nearest verified ownership anchor
let logger = Logger(subsystem: "com.apple-samplecode.BOTanist", category: "general")| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
BOTanistApp |
Logger (logger) |
creates and retains | Initialized by the owner; the binding is immutable |
BOTanistApp |
AppState (appState) |
owns wrapper-managed state | Owning lexical scope |
BOTanistApp |
Size3D (initialVolumeSize) |
creates and retains | Owning lexical scope |
BOTanistApp |
CGSize (initialWindowSize) |
owns value state | Owning lexical scope |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Concurrency, scheduling, and thread safety
Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.
| Concern | Source mechanism | Verified placement or handoff | Evidence |
|---|---|---|---|
| Main isolation | @MainActor |
The cited annotation marks its attached declaration or closure as main-actor isolated. | BOT-anist/AppState+Exploration.swift:74 |
| Main isolation | Task closure isolated to MainActor |
The cited operation explicitly enters a main-actor-isolated region. | BOT-anist/AppState+Exploration.swift:74 |
| Task creation | Task |
The source creates an unstructured task; surrounding context determines inherited actor isolation. | BOT-anist/AppState+Exploration.swift:74 |
| Transfer contract | Sendable or @Sendable |
The source declares a sendability boundary; this alone does not synchronize mutable state. | BOT-anist/AppState.swift:15 |
| Suspension boundary | async declaration or closure |
The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. | BOT-anist/Extensions/Preview+AppStateEnvironment.swift:10 |
@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.
Reference code
BOT-anist/AppState+Exploration.swift:74 — representative execution boundary
Task { @MainActor [entity] in
entity.components[BlendShapeWeightsComponent.self]!.weightSet[0].weights = BlendShapeWeights([0, 1, 0, 0, 0, 0, 0])
}State propagation, frameworks, and dependencies
Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.
| Category | Mechanism or module | Verified role | Evidence |
|---|---|---|---|
| State propagation | @Observable |
Observation macro publishes source-visible changes. | BOT-anist/AppState.swift:25 |
| State propagation | SwiftUI state property wrapper |
A SwiftUI property wrapper supplies or observes UI state. | BOT-anist/BOTanistApp.swift:17 |
| Source import | RealityKit |
The cited file imports this module; runtime use and architectural role are not inferred. | BOT-anist/AppState+Exploration.swift:9 |
| Source import | SwiftUI |
The cited file imports this module; runtime use and architectural role are not inferred. | BOT-anist/AppState+Exploration.swift:11 |
| Source import | Foundation |
The cited file imports this module; runtime use and architectural role are not inferred. | BOT-anist/AppState+Exploration.swift:8 |
| Source import | BOTanistAssets |
The cited file imports this module; runtime use and architectural role are not inferred. | BOT-anist/AppState+Exploration.swift:10 |
| Source import | Spatial |
The cited file imports this module; runtime use and architectural role are not inferred. | BOT-anist/AppState+Exploration.swift:12 |
| Source import | Combine |
The cited file imports this module; runtime use and architectural role are not inferred. | BOT-anist/Robot/RobotCharacter+Movement.swift:9 |
receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.
Class and protocol design
BOT-anist/BOTanistApp.swift:16 — representative type boundary
@main
struct BOTanistApp: App {
@Environment(\.dismissWindow) var dismissWindow
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
BOTanistApp |
Application entry and top-level composition | App |
PlantComponent |
Stores entity-component data or behavior | Component, Codable |
RobotView |
User-interface presentation and input forwarding | View |
ResizableRealityView |
User-interface presentation and input forwarding | View |
StartPlantingButtonView |
User-interface presentation and input forwarding | View |
PlantAnimationProvider |
Supplies a capability or framework resource | Concrete collaborators/imported frameworks |
TypeSelectorView |
User-interface presentation and input forwarding | View |
FaceSelectorView |
User-interface presentation and input forwarding | View |
MaterialColorSelectView |
User-interface presentation and input forwarding | View |
MaterialSelectView |
User-interface presentation and input forwarding | View |
No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
prepareForExploration (BOT-anist/AppState+Exploration.swift:17) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
resetExploration (BOT-anist/AppState+Exploration.swift:63) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
exitExploration (BOT-anist/AppState+Exploration.swift:82) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
id (BOT-anist/AppState.swift:21) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
Reference code
BOT-anist/AppState+Exploration.swift:17 — representative boundary
public func prepareForExploration() {
// ...
let map = try Entity.load(named: "scenes/volume", in: BOTanistAssetsBundle)
// ...
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Application entry and top-level composition | BOTanistApp |
The source’s App suffix makes this role explicit. |
| Stores entity-component data or behavior | JointPinComponent, PlantComponent |
The source’s Component suffix makes this role explicit. |
| Supplies a capability or framework resource | PlantAnimationProvider |
The source’s Provider suffix makes this role explicit. |
| Runs entity-component-system update logic | JointPinSystem |
The source’s System suffix makes this role explicit. |
| User-interface presentation and input forwarding | ContentView, ExplorationView, FaceSelectorView, LightColorSelectView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| No named application pattern | BOT-anist/BOTanistApp.swift:15 |
The verified source directly composes concrete framework types; this document avoids forcing a pattern name. |
Main application flow
sequenceDiagram
participant RobotProvider
participant Entity
participant rootEntity
participant animationEntity
participant entity
RobotProvider->>RobotProvider: loadEntityFromRCPro()
RobotProvider->>Entity: Entity()
RobotProvider->>rootEntity: findEntity()
RobotProvider->>animationEntity: animationLibraryComponent()
RobotProvider->>entity: set()
Reference code
BOT-anist/Robot/RobotProvider+Loading.swift:72 — loadRobotParts()
func loadRobotParts(taskGroup: inout TaskGroup<RobotPartLoadResult>) async {
RobotPart.allCases.forEach { part in
for (index, sceneName) in part.sceneNames.enumerated() {
taskGroup.addTask {
do {
let partName = part.partNames[index]
logger.info("Loading scene \(sceneName), part: \(partName) for part type \(part.rawValue)")
if let entity = try await self.loadEntityFromRCPro(named: partName, fromSceneNamed: sceneName) {
if part == .body {
var libComponent = AnimationLibraryComponent()
let animationDirectory = "Assets/Robot/animations/\(partName)/"
for animationType in AnimationState.allCases {
if let rootEntity = try? await Entity(named: "\(animationDirectory)\(partName)\(animationType.fileSuffix())",
in: BOTanistAssetsBundle) {
if let animationEntity = await rootEntity.findEntity(named: "rig_grp") {
if let animationLibraryComponent = await animationEntity.animationLibraryComponent {
libComponent.animations[animationType.rawValue] = animationLibraryComponent.defaultAnimation
}
}
}
}
await entity.components.set(libComponent)
}
return RobotPartLoadResult(entity: entity, type: part, index: index)
} else {
fatalError("Error loading robot part \(partName) from scene \(sceneName)")
}
} catch {
fatalError("Error loading scene \(sceneName) for part \(part.rawValue)")
}
}
}
}
}Naming conventions
- Types: App: BOTanistApp; Component: JointPinComponent, PlantComponent; Provider: PlantAnimationProvider; System: JointPinSystem; View: ContentView, ExplorationView, FaceSelectorView, LightColorSelectView, MaterialColorSelectView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
partForMaterialName,color,randomColor,face,hash,handleDrag,adjustRobotToFillCenterOfView,generateGrowAnimationResource. - Files:
BOT-anist/BOTanistApp.swift,Packages/BOTanistAssets/Sources/BOTanistAssets/Components/PlantComponent.swift,BOT-anist/Robot/RobotData.swift,BOT-anist/Views/RobotView.swift,BOT-anist/PlantAnimationProvider.swift,BOT-anist/Components/JointPinComponent.swift.
Architecture takeaways
BOTanistAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches RealityKit, SwiftUI, BOTanistAssets, Spatial through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- The source does not justify labeling the design protocol-oriented.
Source map
| Source file | Relevant symbols |
|---|---|
BOT-anist/BOTanistApp.swift |
Cited implementation, BOTanistApp, SwiftUI state property wrapper |
BOT-anist/AppState+Exploration.swift |
Cited implementation, @MainActor, Task closure isolated to MainActor, Task, RealityKit, SwiftUI, Foundation, BOTanistAssets, Spatial, Feature implementation |
BOT-anist/AppState.swift |
Cited implementation, Sendable or @Sendable, @Observable, AppPhase, AppState |
BOT-anist/Extensions/Preview+AppStateEnvironment.swift |
async declaration or closure, SampleAppStateEnvironment |
BOT-anist/Robot/RobotCharacter+Movement.swift |
Combine, Feature implementation |
Packages/BOTanistAssets/Sources/BOTanistAssets/Components/PlantComponent.swift |
PlantComponent, PlantTypeKey |
BOT-anist/Robot/RobotData.swift |
RobotData, RobotMaterial, BodyType, RobotPart, RobotLightColor, RobotFace, RobotPartLoadResult, RobotMaterialResult |
BOT-anist/Views/RobotView.swift |
RobotView, ResizableRealityView, StartPlantingButtonView |
BOT-anist/PlantAnimationProvider.swift |
PlantAnimationProvider, PlantAnimationResult |
BOT-anist/Views/SelectorViews.swift |
TypeSelectorView, FaceSelectorView, MaterialColorSelectView, MaterialSelectView, LightColorSelectView |
BOT-anist/Components/JointPinComponent.swift |
JointPinComponent |
BOT-anist/Systems/JointPinSystem.swift |
JointPinSystem |
BOT-anist/Views/ContentView.swift |
ContentView |
BOT-anist/Views/ExplorationView.swift |
ExplorationView |
BOT-anist/Views/OrnamentView.swift |
OrnamentView |
BOT-anist/Views/RobotCustomizationView.swift |
RobotCustomizationView |
BOT-anist/Robot/RobotProvider+Loading.swift |
loadRobotParts |