# dphfox/fusion architecture

> Architecture diagram of the GitHub repository dphfox/fusion, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dphfox/fusion
- Repository: https://github.com/dphfox/fusion

## Overview

Fusion is a portable Luau companion library, with batteries-included Roblox support. Its principal workflow is composing reactive state and logic, then using that logic to interact with Roblox or other environments. The tree identifies distinct state, graph, scope, instance, and animation subsystems, but the supplied source excerpts contain no runtime implementation. Accordingly, subsystem links are dashed and unverified; the graph preserves the documented capabilities without asserting specific call paths.

Main entry points: [`src/init.luau`](https://github.com/dphfox/fusion/blob/main/src/init.luau) (Fusion API), [`src/State`](https://github.com/dphfox/fusion/tree/main/src/State) (State values), [`src/Instances/New.luau`](https://github.com/dphfox/fusion/blob/main/src/Instances/New.luau) (Instance creation), [`src/Graph`](https://github.com/dphfox/fusion/tree/main/src/Graph) (Dependency graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Library API"]
  node_fusion["Fusion API<br/>[init.luau]"]
end

subgraph group_reactivity["Reactive Runtime"]
  node_state["State values"]
  node_computed["Computed state<br/>[Computed.luau]"]
  node_graph["Dependency graph"]
  node_observers["Observers<br/>[Observer.luau]"]
  node_scopes["Scopes and cleanup"]
end

subgraph group_roblox["Roblox Integration"]
  node_instances["Instance creation<br/>[New.luau]"]
  node_hydration["Instance hydration<br/>[Hydrate.luau]"]
  node_instanceprops["Reactive properties"]
  node_instanceevents["Events and attributes"]
  node_outputs["Instance outputs<br/>[Out.luau]"]
end

subgraph group_capabilities["Additional Capabilities"]
  node_animation["Animation"]
  node_utilities["Utilities and context"]
  node_colour["Colour conversion"]
  node_errors["Error formatting"]
  node_external["External integration<br/>[External.luau]"]
end

node_developer(("Luau developer"))
node_roblox(("Roblox environment"))

node_developer -->|"uses"| node_fusion
node_fusion -.->|"composes logic"| node_state
node_fusion -.->|"composes logic"| node_computed
node_fusion -.->|"offers"| node_animation
node_fusion -.->|"supports Roblox"| node_instances
node_fusion -.->|"supports extension"| node_external
node_state -.->|"tracks dependencies"| node_graph
node_computed -.->|"uses dependencies"| node_graph
node_observers -.->|"observes changes"| node_graph
node_scopes -.->|"manages lifetime"| node_state
node_instances -.->|"creates instances"| node_roblox
node_hydration -.->|"updates instances"| node_roblox
node_instanceprops -.->|"applies properties"| node_instances
node_instanceevents -.->|"integrates events"| node_roblox
node_outputs -.->|"exposes outputs"| node_roblox

click node_fusion "https://github.com/dphfox/fusion/blob/main/src/init.luau"
click node_state "https://github.com/dphfox/fusion/tree/main/src/State"
click node_computed "https://github.com/dphfox/fusion/blob/main/src/State/Computed.luau"
click node_graph "https://github.com/dphfox/fusion/tree/main/src/Graph"
click node_observers "https://github.com/dphfox/fusion/blob/main/src/Graph/Observer.luau"
click node_scopes "https://github.com/dphfox/fusion/tree/main/src/Memory"
click node_instances "https://github.com/dphfox/fusion/blob/main/src/Instances/New.luau"
click node_hydration "https://github.com/dphfox/fusion/blob/main/src/Instances/Hydrate.luau"
click node_instanceprops "https://github.com/dphfox/fusion/blob/main/src/Instances/applyInstanceProps.luau"
click node_instanceevents "https://github.com/dphfox/fusion/tree/main/src/Instances"
click node_outputs "https://github.com/dphfox/fusion/blob/main/src/Instances/Out.luau"
click node_animation "https://github.com/dphfox/fusion/tree/main/src/Animation"
click node_utilities "https://github.com/dphfox/fusion/tree/main/src/Utility"
click node_colour "https://github.com/dphfox/fusion/tree/main/src/Colour"
click node_errors "https://github.com/dphfox/fusion/tree/main/src/Logging"
click node_external "https://github.com/dphfox/fusion/blob/main/src/External.luau"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fusion toneBlue
class node_state,node_computed,node_graph,node_observers,node_scopes toneAmber
class node_instances,node_hydration,node_instanceprops,node_instanceevents,node_outputs toneMint
class node_animation,node_utilities,node_colour,node_errors,node_external toneRose
class node_developer,node_roblox toneIndigo
```

## Components

### Library API

- [Fusion API](https://github.com/dphfox/fusion/blob/main/src/init.luau): `src/init.luau`

### Reactive Runtime

- [State values](https://github.com/dphfox/fusion/tree/main/src/State): `src/State`
- [Computed state](https://github.com/dphfox/fusion/blob/main/src/State/Computed.luau): `src/State/Computed.luau`
- [Dependency graph](https://github.com/dphfox/fusion/tree/main/src/Graph): `src/Graph`
- [Observers](https://github.com/dphfox/fusion/blob/main/src/Graph/Observer.luau): `src/Graph/Observer.luau`
- [Scopes and cleanup](https://github.com/dphfox/fusion/tree/main/src/Memory): `src/Memory`

### Roblox Integration

- [Instance creation](https://github.com/dphfox/fusion/blob/main/src/Instances/New.luau): `src/Instances/New.luau`
- [Instance hydration](https://github.com/dphfox/fusion/blob/main/src/Instances/Hydrate.luau): `src/Instances/Hydrate.luau`
- [Reactive properties](https://github.com/dphfox/fusion/blob/main/src/Instances/applyInstanceProps.luau): `src/Instances/applyInstanceProps.luau`
- [Events and attributes](https://github.com/dphfox/fusion/tree/main/src/Instances): `src/Instances`
- [Instance outputs](https://github.com/dphfox/fusion/blob/main/src/Instances/Out.luau): `src/Instances/Out.luau`

### Additional Capabilities

- [Animation](https://github.com/dphfox/fusion/tree/main/src/Animation): `src/Animation`
- [Utilities and context](https://github.com/dphfox/fusion/tree/main/src/Utility): `src/Utility`
- [Colour conversion](https://github.com/dphfox/fusion/tree/main/src/Colour): `src/Colour`
- [Error formatting](https://github.com/dphfox/fusion/tree/main/src/Logging): `src/Logging`
- [External integration](https://github.com/dphfox/fusion/blob/main/src/External.luau): `src/External.luau`

### Other components

- **Luau developer**
- **Roblox environment**

## Connections

- Luau developer → Fusion API: uses (evidence: `README.md`)
- Fusion API → State values: composes logic
- Fusion API → Computed state: composes logic
- Fusion API → Animation: offers
- Fusion API → Instance creation: supports Roblox
- Fusion API → External integration: supports extension
- State values → Dependency graph: tracks dependencies
- Computed state → Dependency graph: uses dependencies
- Observers → Dependency graph: observes changes
- Scopes and cleanup → State values: manages lifetime
- Instance creation → Roblox environment: creates instances
- Instance hydration → Roblox environment: updates instances
- Reactive properties → Instance creation: applies properties
- Events and attributes → Roblox environment: integrates events
- Instance outputs → Roblox environment: exposes outputs
